Add specs for Kernel.Float with hex strings#1251
Conversation
|
https://bugs.ruby-lang.org/issues/21163 is a related upstream case where I pointed out the inconsistencies. |
6535421 to
64d18ba
Compare
|
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
endI'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. |
If not likely to be backported then yes a version guard is correct.
Regardless it's good to test it, and indeed report weird behavior upstream. |
|
Ah actually it got backport, but only to 3.4.3. Yeah, what you did is right. |
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.