mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-01 09:31:20 +08:00
add core/fixnum/== spec
This commit is contained in:
34
test/test-android/app/core/fixnum/equal_value_spec.rb
Normal file
34
test/test-android/app/core/fixnum/equal_value_spec.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
class Core_Fixnum_EqualValue_Mock1 < Java::Lang::Object
|
||||
def ==(obj)
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
class Core_Fixnum_EqualValue_Mock2 < Java::Lang::Object
|
||||
def ==(obj)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
describe "Fixnum#==" do
|
||||
it "returns true if self has the same value as other" do
|
||||
(1 == 1).should == true
|
||||
(9 == 5).should == false
|
||||
|
||||
# Actually, these call Float#==, Bignum#== etc.
|
||||
(9 == 9.0).should == true
|
||||
(9 == 9.01).should == false
|
||||
|
||||
(10 == bignum_value).should == false
|
||||
end
|
||||
|
||||
it "calls 'other == self' if the given argument is not a Fixnum" do
|
||||
(1 == '*').should == false
|
||||
|
||||
obj = Core_Fixnum_EqualValue_Mock1.new
|
||||
1.should_not == obj
|
||||
|
||||
obj = Core_Fixnum_EqualValue_Mock2.new
|
||||
2.should == obj
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user