Add specs for case/when and if with out-of-int-range Integer literals#1357
Open
sampokuokkanen wants to merge 1 commit into
Open
Add specs for case/when and if with out-of-int-range Integer literals#1357sampokuokkanen wants to merge 1 commit into
sampokuokkanen wants to merge 1 commit into
Conversation
Add specs covering case/when and if with Integer literals outside 32-bit int range (10_000_000_000, -3_000_000_000) and beyond 64-bit long range (1 << 100). Existing case/when specs only exercised small Integers, so optimized implementations whose codepaths diverge at the int/long boundary were not covered.
eregon
reviewed
May 13, 2026
| it "matches an arbitrary-precision Integer literal" do | ||
| huge = 1 << 100 | ||
| case huge | ||
| when 1 << 100; true |
Member
There was a problem hiding this comment.
This is not a literal though, so I think you need to paste the actual value here to test what you want
| it "dispatches correctly with mixed small and large Integer literals" do | ||
| pick = -> x { | ||
| case x | ||
| when 1 << 100 then :beyond_long |
Comment on lines
+150
to
+174
| it "compares against an Integer literal whose value does not fit in a 32-bit int" do | ||
| x = 10_000_000_000 | ||
| if x == 10_000_000_000 | ||
| :match | ||
| else | ||
| :miss | ||
| end.should == :match | ||
|
|
||
| y = -3_000_000_000 | ||
| if y == -3_000_000_000 | ||
| :match | ||
| else | ||
| :miss | ||
| end.should == :match | ||
| end | ||
|
|
||
| it "compares against an arbitrary-precision Integer literal" do | ||
| x = 1 << 100 | ||
| if x == 1 << 100 | ||
| :match | ||
| else | ||
| :miss | ||
| end.should == :match | ||
| end | ||
|
|
Member
There was a problem hiding this comment.
I would drop these, correct Integer#== should imply those to pass
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.
Add specs covering case/when and if with Integer literals outside 32-bit int range (10_000_000_000, -3_000_000_000) and beyond 64-bit long range (1 << 100).
Existing case/when specs only exercised small Integers, so optimized implementations whose codepaths diverge at the int/long boundary were not covered.
Found coverage missing when looking at jruby/jruby#9320.