Skip to content

Commit

Permalink
Add spec for String#to_f with non-ascii compatible encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
herwinw authored and eregon committed Feb 21, 2025
1 parent 09e23dc commit 08a1161
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/string/to_f_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,12 @@
"\2001.2".b.to_f.should == 0
"\3771.2".b.to_f.should == 0
end

ruby_version_is "3.2" do
it "raises Encoding::CompatibilityError if String is in not ASCII-compatible encoding" do
-> {
'1.2'.encode("UTF-16").to_f
}.should raise_error(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16")
end
end
end

0 comments on commit 08a1161

Please sign in to comment.