Skip to content

Commit 0912e58

Browse files
committed
Update specs to new behaviour
It the whole string is valid ASCII, it returns US-ASCII encoding. Otherwise, it is BINARY.
1 parent 5f23192 commit 0912e58

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

optional/capi/string_spec.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,9 +1380,7 @@ def inspect
13801380
result = @s.rb_interned_str(str, str.bytesize)
13811381
result.should.is_a?(String)
13821382
result.should.frozen?
1383-
ruby_bug "21842", ""..."4.1" do
1384-
result.encoding.should == Encoding::BINARY
1385-
end
1383+
result.encoding.should == Encoding::US_ASCII
13861384
end
13871385

13881386
it "returns the same frozen string" do
@@ -1399,12 +1397,11 @@ def inspect
13991397
end
14001398

14011399
ruby_bug "21842", ""..."4.1" do
1402-
it "support binary strings that are invalid in ASCII encoding" do
1400+
it "uses BINARY encoding for strings that are not valid US-ASCII" do
14031401
str = "foo\x81bar\x82baz".b
14041402
result = @s.rb_interned_str(str, str.bytesize)
14051403
result.encoding.should == Encoding::BINARY
14061404
result.should == str
1407-
result.should.valid_encoding?
14081405
end
14091406
end
14101407

@@ -1425,7 +1422,7 @@ def inspect
14251422

14261423
ruby_bug "21842", ""..."4.1" do
14271424
it "returns the same string as String#-@" do
1428-
str = "hello".b
1425+
str = "hello".dup.force_encoding(Encoding::US_ASCII)
14291426
@s.rb_interned_str(str, str.bytesize).should.equal?(-str)
14301427
end
14311428
end
@@ -1437,9 +1434,7 @@ def inspect
14371434
result = @s.rb_interned_str_cstr(str)
14381435
result.should.is_a?(String)
14391436
result.should.frozen?
1440-
ruby_bug "21842", ""..."4.1" do
1441-
result.encoding.should == Encoding::BINARY
1442-
end
1437+
result.encoding.should == Encoding::US_ASCII
14431438
end
14441439

14451440
it "returns the same frozen string" do
@@ -1456,7 +1451,7 @@ def inspect
14561451
end
14571452

14581453
ruby_bug "21842", ""..."4.1" do
1459-
it "support binary strings that are invalid in ASCII encoding" do
1454+
it "uses BINARY encoding for strings that are not valid US-ASCII" do
14601455
str = "foo\x81bar\x82baz".b
14611456
result = @s.rb_interned_str_cstr(str)
14621457
result.encoding.should == Encoding::BINARY
@@ -1482,7 +1477,7 @@ def inspect
14821477

14831478
ruby_bug "21842", ""..."4.1" do
14841479
it "returns the same string as String#-@" do
1485-
str = "hello".b
1480+
str = "hello".dup.force_encoding(Encoding::US_ASCII)
14861481
@s.rb_interned_str_cstr(str).should.equal?(-str)
14871482
end
14881483
end

0 commit comments

Comments
 (0)