1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2018-06-13 21:41:45 +00:00
parent 78890babe7
commit 67078e81f5
24 changed files with 1220 additions and 313 deletions

View file

@ -5,7 +5,7 @@ describe 'String#-@' do
input = 'foo'.freeze
output = -input
output.equal?(input).should == true
output.should equal(input)
output.frozen?.should == true
end
@ -14,6 +14,7 @@ describe 'String#-@' do
output = -input
output.frozen?.should == true
output.should_not equal(input)
output.should == 'foo'
end
@ -30,11 +31,25 @@ describe 'String#-@' do
(-"unfrozen string").should equal(-"unfrozen string")
(-"unfrozen string").should_not equal(-"another unfrozen string")
end
end
ruby_version_is "2.5"..."2.6" do
it "does not deduplicate already frozen strings" do
dynamic = %w(this string is frozen).join(' ').freeze
dynamic.should_not equal("this string is frozen".freeze)
(-dynamic).should_not equal("this string is frozen".freeze)
(-dynamic).should_not equal(-"this string is frozen".freeze)
end
end
ruby_version_is "2.6" do
it "deduplicates frozen strings" do
dynamic = %w(this string is frozen).join(' ').freeze
dynamic.should_not equal("this string is frozen".freeze)
(-dynamic).should equal("this string is frozen".freeze)
(-dynamic).should equal(-"this string is frozen".freeze)
end