Skip to content

test: add missing tests for signed/field numeric generics and fix proptest bug#22413

Draft
AztecBot wants to merge 1 commit intonextfrom
claudebox/c192b26735dbc607-2
Draft

test: add missing tests for signed/field numeric generics and fix proptest bug#22413
AztecBot wants to merge 1 commit intonextfrom
claudebox/c192b26735dbc607-2

Conversation

@AztecBot
Copy link
Copy Markdown
Collaborator

@AztecBot AztecBot commented Apr 8, 2026

Summary

Adds comprehensive test coverage for signed integer and Field arithmetic in numeric generics, which were identified as having near-zero test coverage. Also fixes a bug in the existing proptests.

Changes

Bug fix — proptest never generated negative signed values:

  • In types/arithmetic.rs line 592, integral_maximum_size() was called instead of integral_minimum_size() for signed types. For i8, this meant the proptest only generated values in [127, 127] instead of [-128, 127]. All three proptests (instantiate_before_or_after_canonicalize, instantiate_before_or_after_canonicalize_checked_cast, compare_to_comptime) were affected.

New Integer unit tests (39 tests):

  • Signed addition/subtraction/multiplication/division with negative values
  • Overflow and underflow detection for signed types
  • Signed negation (including i8::MIN overflow case)
  • Signed comparison with negatives
  • Type mismatch returns None
  • Wider signed types (i32, i64) with negative arithmetic
  • Field arithmetic (addition, subtraction wrapping, division by zero, remainder rejection, negation, comparison)
  • is_negative behavior for signed, unsigned, and Field
  • as_field vs as_field_twos_complement encoding of negative values

New numeric generic frontend tests (8 tests):

  • Signed numeric generics in function signatures, structs, traits, where clauses
  • Signed generics with i8, i64 types
  • Negative value turbofish syntax (foo::<-5i32>())

New arithmetic generic frontend tests (14 tests):

  • Signed: addition, subtraction producing negatives, multiplication with negatives, division with negatives, variable cancellation, constant folding, overflow detection, underflow detection
  • Field: addition, subtraction, multiplication, variable cancellation, constant folding, large values (> u32::MAX)

Context

See discussion in the Slack thread — Tom French noticed that Field and signed types were allowed in numeric generics (likely as a result of the Integer refactor making everything more uniform). Jake Fecher suggested adding tests rather than restricting the types. This PR addresses the identified coverage gaps.

Previous analysis: https://gist.github.com/AztecBot/2801f88caf43211a3df05774bff9886b

ClaudeBox log: https://claudebox.work/s/c192b26735dbc607?run=2

@AztecBot AztecBot added ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR. labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant