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

@ -53,18 +53,18 @@ describe "Complex#coerce" do
it "raises TypeError when other is a Numeric which responds to #real? with false" do
other = mock_numeric('other')
other.should_receive(:real?).any_number_of_times.and_return(false)
lambda { @one.coerce(other) }.should raise_error(TypeError)
-> { @one.coerce(other) }.should raise_error(TypeError)
end
it "raises a TypeError when other is a String" do
lambda { @one.coerce("20") }.should raise_error(TypeError)
-> { @one.coerce("20") }.should raise_error(TypeError)
end
it "raises a TypeError when other is nil" do
lambda { @one.coerce(nil) }.should raise_error(TypeError)
-> { @one.coerce(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when other is false" do
lambda { @one.coerce(false) }.should raise_error(TypeError)
-> { @one.coerce(false) }.should raise_error(TypeError)
end
end

View file

@ -2,21 +2,21 @@ require_relative '../../spec_helper'
describe "Complex#fdiv" do
it "accepts a numeric argument" do
lambda { Complex(20).fdiv(2) }.should_not raise_error(TypeError)
lambda { Complex(20).fdiv(2.0) }.should_not raise_error(TypeError)
lambda { Complex(20).fdiv(bignum_value) }.should_not raise_error(TypeError)
-> { Complex(20).fdiv(2) }.should_not raise_error(TypeError)
-> { Complex(20).fdiv(2.0) }.should_not raise_error(TypeError)
-> { Complex(20).fdiv(bignum_value) }.should_not raise_error(TypeError)
end
it "accepts a negative numeric argument" do
lambda { Complex(20).fdiv(-2) }.should_not raise_error(TypeError)
lambda { Complex(20).fdiv(-2.0) }.should_not raise_error(TypeError)
lambda { Complex(20).fdiv(-bignum_value) }.should_not raise_error(TypeError)
-> { Complex(20).fdiv(-2) }.should_not raise_error(TypeError)
-> { Complex(20).fdiv(-2.0) }.should_not raise_error(TypeError)
-> { Complex(20).fdiv(-bignum_value) }.should_not raise_error(TypeError)
end
it "raises a TypeError if passed a non-numeric argument" do
lambda { Complex(20).fdiv([]) }.should raise_error(TypeError)
lambda { Complex(20).fdiv(:sym) }.should raise_error(TypeError)
lambda { Complex(20).fdiv('s') }.should raise_error(TypeError)
-> { Complex(20).fdiv([]) }.should raise_error(TypeError)
-> { Complex(20).fdiv(:sym) }.should raise_error(TypeError)
-> { Complex(20).fdiv('s') }.should raise_error(TypeError)
end
it "sets the real part to NaN if self's real part is NaN" do

View file

@ -6,7 +6,7 @@ describe "Complex#negative?" do
c.methods.should_not include(:negative?)
lambda {
-> {
c.negative?
}.should raise_error(NoMethodError)
end

View file

@ -7,8 +7,8 @@ describe "Complex.polar" do
end
it "raises a TypeError when given non real arguments" do
lambda{ Complex.polar(nil) }.should raise_error(TypeError)
lambda{ Complex.polar(nil, nil) }.should raise_error(TypeError)
->{ Complex.polar(nil) }.should raise_error(TypeError)
->{ Complex.polar(nil, nil) }.should raise_error(TypeError)
end
end

View file

@ -6,7 +6,7 @@ describe "Complex#positive?" do
c.methods.should_not include(:positive?)
lambda {
-> {
c.positive?
}.should raise_error(NoMethodError)
end

View file

@ -2,11 +2,11 @@ require_relative '../../spec_helper'
describe "Complex#rationalize" do
it "raises RangeError if self has non-zero imaginary part" do
lambda { Complex(1,5).rationalize }.should raise_error(RangeError)
-> { Complex(1,5).rationalize }.should raise_error(RangeError)
end
it "raises RangeError if self has 0.0 imaginary part" do
lambda { Complex(1,0.0).rationalize }.should raise_error(RangeError)
-> { Complex(1,0.0).rationalize }.should raise_error(RangeError)
end
it "returns a Rational if self has zero imaginary part" do
@ -25,7 +25,7 @@ describe "Complex#rationalize" do
end
it "raises ArgumentError when passed more than one argument" do
lambda { Complex(1,0).rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
lambda { Complex(1,0).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
-> { Complex(1,0).rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
-> { Complex(1,0).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
end
end

View file

@ -19,7 +19,7 @@ describe :complex_divide, shared: true do
end
it "raises a ZeroDivisionError when given zero" do
lambda { Complex(20, 40).send(@method, 0) }.should raise_error(ZeroDivisionError)
-> { Complex(20, 40).send(@method, 0) }.should raise_error(ZeroDivisionError)
end
it "produces Rational parts" do

View file

@ -37,7 +37,7 @@ describe :complex_rect, shared: true do
it "raises an ArgumentError if given any arguments" do
@numbers.each do |number|
lambda { number.send(@method, number) }.should raise_error(ArgumentError)
-> { number.send(@method, number) }.should raise_error(ArgumentError)
end
end
end
@ -57,7 +57,7 @@ describe :complex_rect_class, shared: true do
it "raises TypeError" do
n = mock_numeric('n')
n.should_receive(:real?).any_number_of_times.and_return(false)
lambda { Complex.send(@method, n) }.should raise_error(TypeError)
-> { Complex.send(@method, n) }.should raise_error(TypeError)
end
end
@ -68,7 +68,7 @@ describe :complex_rect_class, shared: true do
n2 = mock_numeric('n2')
n1.should_receive(:real?).any_number_of_times.and_return(r1)
n2.should_receive(:real?).any_number_of_times.and_return(r2)
lambda { Complex.send(@method, n1, n2) }.should raise_error(TypeError)
-> { Complex.send(@method, n1, n2) }.should raise_error(TypeError)
end
end
end
@ -87,8 +87,8 @@ describe :complex_rect_class, shared: true do
describe "passed a non-Numeric" do
it "raises TypeError" do
lambda { Complex.send(@method, :sym) }.should raise_error(TypeError)
lambda { Complex.send(@method, 0, :sym) }.should raise_error(TypeError)
-> { Complex.send(@method, :sym) }.should raise_error(TypeError)
-> { Complex.send(@method, 0, :sym) }.should raise_error(TypeError)
end
end
end

View file

@ -29,13 +29,13 @@ describe "Complex#to_f" do
describe "when the imaginary part is non-zero" do
it "raises RangeError" do
lambda { Complex(0, 1).to_f }.should raise_error(RangeError)
-> { Complex(0, 1).to_f }.should raise_error(RangeError)
end
end
describe "when the imaginary part is Float 0.0" do
it "raises RangeError" do
lambda { Complex(0, 0.0).to_f }.should raise_error(RangeError)
-> { Complex(0, 0.0).to_f }.should raise_error(RangeError)
end
end
end

View file

@ -29,13 +29,13 @@ describe "Complex#to_i" do
describe "when the imaginary part is non-zero" do
it "raises RangeError" do
lambda { Complex(0, 1).to_i }.should raise_error(RangeError)
-> { Complex(0, 1).to_i }.should raise_error(RangeError)
end
end
describe "when the imaginary part is Float 0.0" do
it "raises RangeError" do
lambda { Complex(0, 0.0).to_i }.should raise_error(RangeError)
-> { Complex(0, 0.0).to_i }.should raise_error(RangeError)
end
end
end

View file

@ -29,13 +29,13 @@ describe "Complex#to_r" do
describe "when the imaginary part is non-zero" do
it "raises RangeError" do
lambda { Complex(0, 1).to_r }.should raise_error(RangeError)
-> { Complex(0, 1).to_r }.should raise_error(RangeError)
end
end
describe "when the imaginary part is Float 0.0" do
it "raises RangeError" do
lambda { Complex(0, 0.0).to_r }.should raise_error(RangeError)
-> { Complex(0, 0.0).to_r }.should raise_error(RangeError)
end
end
end