From 1fefa444a03d72b400e9b04ef27fe32318ffb4cb Mon Sep 17 00:00:00 2001 From: Kaise Cheng Date: Thu, 30 Oct 2025 11:06:47 +0000 Subject: [PATCH 1/2] add test for negative hex string to float --- core/kernel/Float_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/kernel/Float_spec.rb b/core/kernel/Float_spec.rb index e00fe81572..edb3c2d4ec 100644 --- a/core/kernel/Float_spec.rb +++ b/core/kernel/Float_spec.rb @@ -257,6 +257,10 @@ def to_f() 1.2 end @object.send(:Float, "0x_10", exception: false).should be_nil end + it "parses negative hexadecimal string as negative floats" do + @object.send(:Float, "-0x7b").should == -123.0 + end + ruby_version_is "3.4" do it "accepts a fractional part" do @object.send(:Float, "0x0.8").should == 0.5 From 501127607c0a13ad37158da7ad199c98d0c5ea46 Mon Sep 17 00:00:00 2001 From: kaisecheng <69120390+kaisecheng@users.noreply.github.com> Date: Thu, 30 Oct 2025 11:09:48 +0000 Subject: [PATCH 2/2] Update core/kernel/Float_spec.rb --- core/kernel/Float_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/kernel/Float_spec.rb b/core/kernel/Float_spec.rb index edb3c2d4ec..bb94732235 100644 --- a/core/kernel/Float_spec.rb +++ b/core/kernel/Float_spec.rb @@ -257,7 +257,7 @@ def to_f() 1.2 end @object.send(:Float, "0x_10", exception: false).should be_nil end - it "parses negative hexadecimal string as negative floats" do + it "parses negative hexadecimal string as negative float" do @object.send(:Float, "-0x7b").should == -123.0 end