diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
commit | 1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch) | |
tree | a3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/ruby/shared/kernel/object_id.rb | |
parent | 75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff) |
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory.
[Misc #13792] [ruby-core:82287]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/shared/kernel/object_id.rb')
-rw-r--r-- | spec/ruby/shared/kernel/object_id.rb | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/spec/ruby/shared/kernel/object_id.rb b/spec/ruby/shared/kernel/object_id.rb new file mode 100644 index 0000000000..7acdb27554 --- /dev/null +++ b/spec/ruby/shared/kernel/object_id.rb @@ -0,0 +1,80 @@ +# These examples hold for both BasicObject#__id__ and Kernel#object_id. +describe :object_id, shared: true do + it "returns an integer" do + o1 = @object.new + o1.__send__(@method).should be_kind_of(Integer) + end + + it "returns the same value on all calls to id for a given object" do + o1 = @object.new + o1.__send__(@method).should == o1.__send__(@method) + end + + it "returns different values for different objects" do + o1 = @object.new + o2 = @object.new + o1.__send__(@method).should_not == o2.__send__(@method) + end + + it "returns the same value for two Fixnums with the same value" do + o1 = 1 + o2 = 1 + o1.send(@method).should == o2.send(@method) + end + + it "returns the same value for two Symbol literals" do + o1 = :hello + o2 = :hello + o1.send(@method).should == o2.send(@method) + end + + it "returns the same value for two true literals" do + o1 = true + o2 = true + o1.send(@method).should == o2.send(@method) + end + + it "returns the same value for two false literals" do + o1 = false + o2 = false + o1.send(@method).should == o2.send(@method) + end + + it "returns the same value for two nil literals" do + o1 = nil + o2 = nil + o1.send(@method).should == o2.send(@method) + end + + 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) + end + + it "returns a different value for an object and its dup" do + o1 = mock("object") + o2 = o1.dup + o1.send(@method).should_not == o2.send(@method) + end + + 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 Fixnum limit" do + o1 = -1 + o2 = 2 ** 62 - 1 + + o1.send(@method).should_not == o2.send(@method) + end +end |