summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/uminus_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/uminus_spec.rb')
-rw-r--r--spec/ruby/core/string/uminus_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/ruby/core/string/uminus_spec.rb b/spec/ruby/core/string/uminus_spec.rb
index 53e73b7e67..f18e6b1234 100644
--- a/spec/ruby/core/string/uminus_spec.rb
+++ b/spec/ruby/core/string/uminus_spec.rb
@@ -17,5 +17,30 @@ ruby_version_is "2.3" do
output.frozen?.should == true
output.should == 'foo'
end
+
+ ruby_version_is "2.5" do
+ it "returns the same object for equal unfrozen strings" do
+ origin = "this is a string"
+ dynamic = %w(this is a string).join(' ')
+
+ origin.should_not equal(dynamic)
+ (-origin).should equal(-dynamic)
+ end
+
+ it "returns the same object when it's called on the same String literal" do
+ (-"unfrozen string").should equal(-"unfrozen string")
+ (-"unfrozen string").should_not equal(-"another unfrozen string")
+ end
+
+ it "is an identity function if the string is frozen" do
+ dynamic = %w(this string is frozen).join(' ').freeze
+
+ (-dynamic).should equal(dynamic)
+
+ 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
end
end