0xMiden / 0xMiden/compiler

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

Aperta Adatta ai principianti
#1,338 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
115
Fork
84
Merge medio
1g 8h
PR unite (30g)
15

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
testing
Tipo di issue
Documentazione
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
75/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.