0xMiden / 0xMiden/compiler

Increase arithmetic op test coverage for `div_euclid` and `rem_euclid`

未關閉 適合新手
#1,338 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Rust
星號
115
分支
84
平均合併
1 天 8 小時
30 天內合併 PR
15

描述

These tests should be added to `tests/integration/src/end_to_end/arithmetic.rs`.

Signed Euclidean division rounds the quotient toward −∞ and yields an always-non-negative remainder, unlike the `/` and `%` operators, e.g. `(-7).div_euclid(2) == -4` / `(-7).rem_euclid(2) == 1` vs `-7 / 2 == -3` / `-7 % 2 == -1`. Truncating signed `/`/`%` is already covered (`case_i32_sdiv`); the Euclidean family has no coverage.

### div_euclid

- [ ] `div_euclid` (signed i32/i64, all four sign combinations)
- [ ] `div_euclid` (unsigned u32/u64)
- [ ] `checked_div_euclid`
- [ ] `overflowing_div_euclid`
- [ ] `wrapping_div_euclid`

### rem_euclid

- [ ] `rem_euclid` (signed i32/i64) — result is always in `[0, |d|)`
- [ ] `rem_euclid` (unsigned u32/u64)
- [ ] `checked_rem_euclid`
- [ ] `overflowing_rem_euclid`
- [ ] `wrapping_rem_euclid`

Note the trap surface: `div_euclid`/`rem_euclid` panic on divisor 0 and on the `MIN / -1` overflow (`i32::MIN.div_euclid(-1)`). Keep the plain arms panic-free by range-limiting divisors and excluding MIN/-1 (as `case_i32_sdiv` does), and exercise those edges through the `checked_*`/`overflowing_*` arms (`None` / `(MIN, true)`).

I'd like to be assigned to this.

貢獻指南

開啟貢獻指南

研究方向

The tests go in tests/integration/src/end_to_end/arithmetic.rs. Start by reading the existing case_i32_sdiv test to understand the pattern. For each function listed (div_euclid, rem_euclid, and their checked/overflowing/wrapping variants), write test cases for signed i32/i64 and unsigned u32/u64, ensuring to avoid panic cases like division by zero and MIN/-1 overflow in the plain arms, and test those edges in the checked/overflowing arms. Run the test suite to verify coverage.

由索引模型根據 Issue 內容生成。

評估

領域
testing
Issue 類型
文件
難度
2/5
預估耗時
1-3 小時
活躍度
活躍
描述清晰度
描述清楚
新手友好度
75/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。