Skip to content

Commit

Permalink
Add specs for String#to_c
Browse files Browse the repository at this point in the history
  • Loading branch information
AI-Mozi committed May 18, 2023
1 parent a33e563 commit a54627f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/string/to_c_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a54627f

Please sign in to comment.