Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shared specs when precision is passed in for Integer#floor, Float#floor and Integer#ceil, Float#ceil #1186

Merged
merged 3 commits into from
Jul 28, 2024

Conversation

peterzhu2118
Copy link
Member

There is poor spec coverage of when precision is passed into Integer#floor, Float#floor, Integer#ceil, Float#ceil. This PR adds some specs for when precision is passed in.

This spec can be shared between Integer#floor and Float#floor and
improves coverage of cases where precision is passed in.
This spec can be shared between Integer#ceil and Float#ceil and
improves coverage of cases where precision is passed in.
@peterzhu2118
Copy link
Member Author

Note that cases where self has fewer digits than precision is omitted, due to issues that is fixed in ruby/ruby#11257.

@eregon
Copy link
Member

eregon commented Jul 27, 2024

Note that cases where self has fewer digits than precision is omitted, due to issues that is fixed in ruby/ruby#11257.

Could you include those too, but under ruby_bug "#20654", ""..."3.4" do?

BTW it's fine if you change specs directly in the ruby/ruby PR for convenience, that ensures the specs are run with the fix and work on ruby-head.

@peterzhu2118
Copy link
Member Author

BTW it's fine if you change specs directly in the ruby/ruby PR for convenience, that ensures the specs are run with the fix and work on ruby-head.

Yep, I'll add the specs for the new behaviour in ruby/ruby#11257 once this PR is merged.


ruby_bug "#20654", ""..."3.4" do
it "returns 0 when the return value overflows fixnum" do
send(@method, -123).ceil(-100).should.eql?(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior under a ruby_bug guard should be the correct behavior, not the buggy behavior (see CONTRIBUTING.md)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. I misunderstood. I've fixed it in the latest commit.

@eregon eregon merged commit 1bd7ae7 into master Jul 28, 2024
28 checks passed
@eregon eregon deleted the pz-floor-ceil-share branch July 28, 2024 18:00
@eregon
Copy link
Member

eregon commented Jul 28, 2024

Thanks for the new specs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants