1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-07-27 12:40:09 +02:00
parent a06301b103
commit 5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions

View file

@ -21,24 +21,24 @@ describe :integer_modulo, shared: true do
end
it "raises a ZeroDivisionError when the given argument is 0" do
lambda { 13.send(@method, 0) }.should raise_error(ZeroDivisionError)
lambda { 0.send(@method, 0) }.should raise_error(ZeroDivisionError)
lambda { -10.send(@method, 0) }.should raise_error(ZeroDivisionError)
-> { 13.send(@method, 0) }.should raise_error(ZeroDivisionError)
-> { 0.send(@method, 0) }.should raise_error(ZeroDivisionError)
-> { -10.send(@method, 0) }.should raise_error(ZeroDivisionError)
end
it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
lambda { 0.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
lambda { 10.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
lambda { -10.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
-> { 0.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
-> { 10.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
-> { -10.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
end
it "raises a TypeError when given a non-Integer" do
lambda {
-> {
(obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
13.send(@method, obj)
}.should raise_error(TypeError)
lambda { 13.send(@method, "10") }.should raise_error(TypeError)
lambda { 13.send(@method, :symbol) }.should raise_error(TypeError)
-> { 13.send(@method, "10") }.should raise_error(TypeError)
-> { 13.send(@method, :symbol) }.should raise_error(TypeError)
end
end
@ -56,19 +56,19 @@ describe :integer_modulo, shared: true do
end
it "raises a ZeroDivisionError when the given argument is 0" do
lambda { @bignum.send(@method, 0) }.should raise_error(ZeroDivisionError)
lambda { (-@bignum).send(@method, 0) }.should raise_error(ZeroDivisionError)
-> { @bignum.send(@method, 0) }.should raise_error(ZeroDivisionError)
-> { (-@bignum).send(@method, 0) }.should raise_error(ZeroDivisionError)
end
it "raises a ZeroDivisionError when the given argument is 0 and a Float" do
lambda { @bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
lambda { -@bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
-> { @bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
-> { -@bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError)
end
it "raises a TypeError when given a non-Integer" do
lambda { @bignum.send(@method, mock('10')) }.should raise_error(TypeError)
lambda { @bignum.send(@method, "10") }.should raise_error(TypeError)
lambda { @bignum.send(@method, :symbol) }.should raise_error(TypeError)
-> { @bignum.send(@method, mock('10')) }.should raise_error(TypeError)
-> { @bignum.send(@method, "10") }.should raise_error(TypeError)
-> { @bignum.send(@method, :symbol) }.should raise_error(TypeError)
end
end
end