From 585f03217c1d20cb52ebb6c2fe1bffbe7c1319b7 Mon Sep 17 00:00:00 2001 From: Herwin Date: Thu, 13 Feb 2025 20:08:19 +0100 Subject: [PATCH] Add test for String#to_r with leading plus sign --- core/string/to_r_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/string/to_r_spec.rb b/core/string/to_r_spec.rb index 7e1d635d3b..4ffbb10d98 100644 --- a/core/string/to_r_spec.rb +++ b/core/string/to_r_spec.rb @@ -33,6 +33,10 @@ "-20".to_r.should == Rational(-20, 1) end + it "accepts leading plus signs" do + "+20".to_r.should == Rational(20, 1) + end + it "does not treat a leading period without a numeric prefix as a decimal point" do ".9".to_r.should_not == Rational(8106479329266893, 9007199254740992) end