summaryrefslogtreecommitdiff
path: root/spec/rubyspec/shared/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/shared/kernel')
-rw-r--r--spec/rubyspec/shared/kernel/equal.rb54
-rw-r--r--spec/rubyspec/shared/kernel/object_id.rb80
-rw-r--r--spec/rubyspec/shared/kernel/raise.rb68
3 files changed, 0 insertions, 202 deletions
diff --git a/spec/rubyspec/shared/kernel/equal.rb b/spec/rubyspec/shared/kernel/equal.rb
deleted file mode 100644
index 0a70aec639..0000000000
--- a/spec/rubyspec/shared/kernel/equal.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# These examples hold for BasicObject#equal?, BasicObject#== and Kernel#eql?
-describe :object_equal, shared: true do
- it "returns true if other is identical to self" do
- obj = Object.new
- obj.__send__(@method, obj).should be_true
- end
-
- it "returns false if other is not identical to self" do
- a = Object.new
- b = Object.new
- a.__send__(@method, b).should be_false
- end
-
- it "returns true only if self and other are the same object" do
- o1 = mock('o1')
- o2 = mock('o2')
- o1.__send__(@method, o1).should == true
- o2.__send__(@method, o2).should == true
- o1.__send__(@method, o2).should == false
- end
-
- it "returns true for the same immediate object" do
- o1 = 1
- o2 = :hola
- 1.__send__(@method, o1).should == true
- :hola.__send__(@method, o2).should == true
- end
-
- it "returns false for nil and any other object" do
- o1 = mock('o1')
- nil.__send__(@method, nil).should == true
- o1.__send__(@method, nil).should == false
- nil.__send__(@method, o1).should == false
- end
-
- it "returns false for objects of different classes" do
- :hola.__send__(@method, 1).should == false
- end
-
- it "returns true only if self and other are the same boolean" do
- true.__send__(@method, true).should == true
- false.__send__(@method, false).should == true
-
- true.__send__(@method, false).should == false
- false.__send__(@method, true).should == false
- end
-
- it "returns true for integers of initially different ranges" do
- big42 = (bignum_value * 42 / bignum_value)
- 42.__send__(@method, big42).should == true
- long42 = (1 << 35) * 42 / (1 << 35)
- 42.__send__(@method, long42).should == true
- end
-end
diff --git a/spec/rubyspec/shared/kernel/object_id.rb b/spec/rubyspec/shared/kernel/object_id.rb
deleted file mode 100644
index 7acdb27554..0000000000
--- a/spec/rubyspec/shared/kernel/object_id.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-# 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
diff --git a/spec/rubyspec/shared/kernel/raise.rb b/spec/rubyspec/shared/kernel/raise.rb
deleted file mode 100644
index 70d638fff9..0000000000
--- a/spec/rubyspec/shared/kernel/raise.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-describe :kernel_raise, shared: true do
- before :each do
- ScratchPad.clear
- end
-
- it "aborts execution" do
- lambda do
- @object.raise Exception, "abort"
- ScratchPad.record :no_abort
- end.should raise_error(Exception, "abort")
-
- ScratchPad.recorded.should be_nil
- end
-
- it "raises RuntimeError if no exception class is given" do
- lambda { @object.raise }.should raise_error(RuntimeError)
- end
-
- it "raises a given Exception instance" do
- error = RuntimeError.new
- lambda { @object.raise(error) }.should raise_error(error)
- end
-
- it "raises a RuntimeError if string given" do
- lambda { @object.raise("a bad thing") }.should raise_error(RuntimeError)
- end
-
- it "raises a TypeError when passed a non-Exception object" do
- lambda { @object.raise(Object.new) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed true" do
- lambda { @object.raise(true) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed false" do
- lambda { @object.raise(false) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed nil" do
- lambda { @object.raise(nil) }.should raise_error(TypeError)
- end
-
- it "re-raises the rescued exception" do
- lambda do
- begin
- raise Exception, "outer"
- ScratchPad.record :no_abort
- rescue
- begin
- raise StandardError, "inner"
- rescue
- end
-
- @object.raise
- ScratchPad.record :no_reraise
- end
- end.should raise_error(Exception, "outer")
-
- ScratchPad.recorded.should be_nil
- end
-
- it "allows Exception, message, and backtrace parameters" do
- lambda do
- @object.raise(ArgumentError, "message", caller)
- end.should raise_error(ArgumentError, "message")
- end
-end