test: add missing tests for signed/field numeric generics and fix proptest bug#22413
Draft
test: add missing tests for signed/field numeric generics and fix proptest bug#22413
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
types/arithmetic.rsline 592,integral_maximum_size()was called instead ofintegral_minimum_size()for signed types. Fori8, 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
Integerunit tests (39 tests):i8::MINoverflow case)Nonei32,i64) with negative arithmeticis_negativebehavior for signed, unsigned, and Fieldas_fieldvsas_field_twos_complementencoding of negative valuesNew numeric generic frontend tests (8 tests):
i8,i64typesfoo::<-5i32>())New arithmetic generic frontend tests (14 tests):
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
Integerrefactor 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