summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/to_c_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/to_c_spec.rb')
-rw-r--r--spec/ruby/core/string/to_c_spec.rb38
1 files changed, 19 insertions, 19 deletions
diff --git a/spec/ruby/core/string/to_c_spec.rb b/spec/ruby/core/string/to_c_spec.rb
index 9d24f1f56c..9cd0ed4401 100644
--- a/spec/ruby/core/string/to_c_spec.rb
+++ b/spec/ruby/core/string/to_c_spec.rb
@@ -13,18 +13,20 @@ describe "String#to_c" do
it "ignores trailing garbage" do
'79+4iruby'.to_c.should == Complex(79, 4)
- ruby_bug "[Bug #19087]", ""..."3.2" do
- '7__9+4__0i'.to_c.should == Complex(7, 0)
- end
+ '7__9+4__0i'.to_c.should == Complex(7, 0)
end
- it "understands Float::INFINITY" do
- 'Infinity'.to_c.should == Complex(0, 1)
- '-Infinity'.to_c.should == Complex(0, -1)
- end
+ context "it treats special float value strings as characters" do
+ it "parses any string that starts with 'I' as 1i" do
+ 'Infinity'.to_c.should == Complex(0, 1)
+ '-Infinity'.to_c.should == Complex(0, -1)
+ 'Insecure'.to_c.should == Complex(0, 1)
+ '-Insecure'.to_c.should == Complex(0, -1)
+ end
- it "understands Float::NAN" do
- 'NaN'.to_c.should == Complex(0, 0)
+ it "does not parse any numeric information in 'NaN'" do
+ 'NaN'.to_c.should == Complex(0, 0)
+ end
end
it "allows null-byte" do
@@ -36,18 +38,16 @@ describe "String#to_c" do
it "raises Encoding::CompatibilityError if String is in not ASCII-compatible encoding" do
-> {
'79+4i'.encode("UTF-16").to_c
- }.should raise_error(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16")
+ }.should.raise(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)
+ 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
+ "12_3".to_c.should == Complex(123)
+ "12__3".to_c.should == Complex(12)
+ "12___3".to_c.should == Complex(12)
end
end