Skip to content

Commit

Permalink
Rational#div: Simplify syntax to placate 1.8; guard #1648
Browse files Browse the repository at this point in the history
  • Loading branch information
runpaint committed Jun 17, 2009
1 parent 5727b2d commit c292ebd
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions shared/rational/div.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
end

it "raises a ZeroDivisionError when the argument has a numerator of 0" do
lambda { Rational(3, 4).div(Rational(0, 3)) }
.should raise_error(ZeroDivisionError)
lambda { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
end

it "raises a ZeroDivisionError when the argument has a numerator of 0.0" do
lambda { Rational(3, 4).div(Rational(0.0, 3)) }
.should raise_error(ZeroDivisionError)
lambda { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError)
end
end

Expand All @@ -25,8 +23,7 @@
end

it "raises a FloatDomainError when the argument is 0.0" do
lambda { Rational(3, 4).div(0.0) }
.should raise_error(FloatDomainError)
lambda { Rational(3, 4).div(0.0) }.should raise_error(FloatDomainError)
end
end

Expand All @@ -37,8 +34,7 @@
end

it "raises a ZeroDivisionError when the argument is 0" do
lambda { Rational(3, 4).div(0) }
.should raise_error(ZeroDivisionError)
lambda { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError)
end
end

Expand All @@ -48,12 +44,12 @@
end

it "raises an ArgumentError if passed more than one argument" do
lambda { Rational(3, 4).div(2,3) }
.should raise_error(ArgumentError)
lambda { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError)
end

it "raises a TypeError if passed a non-numeric argument" do
lambda { Rational(3, 4).div([]) }
.should raise_error(TypeError)
end
ruby_bug "#1648", "1.8.7" do
it "raises a TypeError if passed a non-numeric argument" do
lambda { Rational(3, 4).div([]) }.should raise_error(TypeError)
end
end
end

0 comments on commit c292ebd

Please sign in to comment.