Skip to content

Commit

Permalink
Merge pull request #1034 from AI-Mozi/add_specs_for_string_to_c
Browse files Browse the repository at this point in the history
Add specs for `String#to_c`
  • Loading branch information
andrykonchin authored May 18, 2023
2 parents a33e563 + 03f3e6a commit 0006d19
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 "treats 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 0006d19

Please sign in to comment.