Skip to content

Instantly share code, notes, and snippets.

@jfirebaugh
Created December 9, 2011 22:24
Show Gist options
  • Select an option

  • Save jfirebaugh/1453587 to your computer and use it in GitHub Desktop.

Select an option

Save jfirebaugh/1453587 to your computer and use it in GitHub Desktop.
ruby_bug "#5713", "2.0" do
it "returns Rational(0) when self is Rational(0) and the exponent is positive" do
(Rational(0) ** bignum_value).should eql(Rational(0))
end
it "raises ZeroDivisionError when self is Rational(0) and the exponent is negative" do
lambda { Rational(0) ** -bignum_value }.should raise_error(ZeroDivisionError)
end
it "returns Rational(1) when self is Rational(1)" do
(Rational(1) ** bignum_value).should eql(Rational(1))
(Rational(1) ** -bignum_value).should eql(Rational(1))
end
it "returns Rational(1) when self is Rational(-1) and the exponent is even" do
(Rational(-1) ** bignum_value(0)).should eql(Rational(1))
(Rational(-1) ** bignum_value(2)).should eql(Rational(1))
end
it "returns Rational(-1) when self is Rational(-1) and the exponent is odd" do
(Rational(-1) ** bignum_value(1)).should eql(Rational(-1))
(Rational(-1) ** bignum_value(3)).should eql(Rational(-1))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment