summaryrefslogtreecommitdiff
path: root/spec/ruby/shared/kernel/object_id.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/shared/kernel/object_id.rb')
-rw-r--r--spec/ruby/shared/kernel/object_id.rb38
1 files changed, 29 insertions, 9 deletions
diff --git a/spec/ruby/shared/kernel/object_id.rb b/spec/ruby/shared/kernel/object_id.rb
index 175f3fb749..6469e49903 100644
--- a/spec/ruby/shared/kernel/object_id.rb
+++ b/spec/ruby/shared/kernel/object_id.rb
@@ -2,7 +2,7 @@
describe :object_id, shared: true do
it "returns an integer" do
o1 = @object.new
- o1.__send__(@method).should be_kind_of(Integer)
+ o1.__send__(@method).should.is_a?(Integer)
end
it "returns the same value on all calls to id for a given object" do
@@ -16,7 +16,7 @@ describe :object_id, shared: true do
o1.__send__(@method).should_not == o2.__send__(@method)
end
- it "returns the same value for two Integers with the same value" do
+ it "returns the same value for two Fixnums with the same value" do
o1 = 1
o2 = 1
o1.send(@method).should == o2.send(@method)
@@ -46,16 +46,36 @@ describe :object_id, shared: true do
o1.send(@method).should == o2.send(@method)
end
- it "returns a different value for two Integer literals" do
+ it "returns a different value for two Bignum literals" do
o1 = 2e100.to_i
o2 = 2e100.to_i
o1.send(@method).should_not == o2.send(@method)
end
- it "returns a different value for two String literals" do
- o1 = "hello"
- o2 = "hello"
- o1.send(@method).should_not == o2.send(@method)
+ guard -> { "test".frozen? && "test".equal?("test") } do # --enable-frozen-string-literal in $RUBYOPT
+ it "returns the same value for two identical String literals" do
+ o1 = "hello"
+ o2 = "hello"
+ o1.send(@method).should == o2.send(@method)
+ end
+ end
+
+ guard -> { "test".frozen? && !"test".equal?("test") } do # chilled string literals
+ it "returns a different frozen value for two String literals" do
+ o1 = "hello"
+ o2 = "hello"
+ o1.send(@method).should_not == o2.send(@method)
+ o1.frozen?.should == true
+ o2.frozen?.should == true
+ end
+ end
+
+ guard -> { !"test".frozen? } do
+ it "returns a different value for two String literals" do
+ o1 = "hello"
+ o2 = "hello"
+ o1.send(@method).should_not == o2.send(@method)
+ end
end
it "returns a different value for an object and its dup" do
@@ -64,14 +84,14 @@ describe :object_id, shared: true do
o1.send(@method).should_not == o2.send(@method)
end
- it "returns a different value for two numbers near the 32 bit Integer limit" do
+ it "returns a different value for two numbers near the 32 bit Fixnum limit" do
o1 = -1
o2 = 2 ** 30 - 1
o1.send(@method).should_not == o2.send(@method)
end
- it "returns a different value for two numbers near the 64 bit Integer limit" do
+ it "returns a different value for two numbers near the 64 bit Fixnum limit" do
o1 = -1
o2 = 2 ** 62 - 1