From a54627fcf29e323b8e603446d1259de79afc9436 Mon Sep 17 00:00:00 2001 From: AI-Mozi Date: Thu, 18 May 2023 08:42:23 +0200 Subject: [PATCH] Add specs for `String#to_c` --- core/string/to_c_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/string/to_c_spec.rb b/core/string/to_c_spec.rb index edc8a4f14..7e38d3e15 100644 --- a/core/string/to_c_spec.rb +++ b/core/string/to_c_spec.rb @@ -38,4 +38,16 @@ '79+4i'.encode("UTF-16").to_c }.should raise_error(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") end + + ruby_version_is "3.2" do + it "treat a sequence of underscores as an end of Complex string" do + "5+3_1i".to_c.should == Complex(5, 31) + "5+3__1i".to_c.should == Complex(5) + "5+3___1i".to_c.should == Complex(5) + + "12_3".to_c.should == Complex(123) + "12__3".to_c.should == Complex(12) + "12___3".to_c.should == Complex(12) + end + end end