Skip to content

Add specs for Kernel.Float with hex strings #1251

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

herwinw
Copy link
Member

@herwinw herwinw commented Feb 28, 2025

They are very much driven by the current (inconsistent) behaviour of MRI. I'm not sure if these should be seen as a specification or as MRI specific implementation quirks.

@herwinw
Copy link
Member Author

herwinw commented Feb 28, 2025

https://bugs.ruby-lang.org/issues/21163 is a related upstream case where I pointed out the inconsistencies.

herwinw added 2 commits April 26, 2025 13:59
This is mostly relevant for the 3.4.2-3.4.3 changees for the
Kernel.Float tests, but there is no reason to keep the other checks on
older Ruby versions.
@herwinw
Copy link
Member Author

herwinw commented Apr 26, 2025

I've updated the PR to reflect the changes in Ruby 3.4.3. It now contains checks like this:

ruby_version_is ""..."3.4.3" do
  it "does not accept embedded _ if the number contains a-f" do
    -> { @object.send(:Float, "0x1_0a") }.should raise_error(ArgumentError)
  end
end

ruby_version_is "3.4.3" do
  it "accepts embedded _ if the number contains a-f" do
    @object.send(:Float, "0x1_0a").should == 0x10a.to_f
  end
end

I'm not sure if this should be checked with a version guard, or with a ruby_bug. It's not the kind of fix I would expect in a patchlevel release.

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.

1 participant