Updated RubySpec source to b897f30c.
[rbx.git] / spec / frozen / 1.8 / library / bigdecimal / shared / quo.rb
blobb904aab90a205541fe54766f95c796fadfa38ca9
1 require 'bigdecimal'
3 describe :bigdecimal_quo, :shared => true do
4   before(:each) do
5     @one = BigDecimal("1")
6     @zero = BigDecimal("0")
7     @zero_plus = BigDecimal("+0")
8     @zero_minus = BigDecimal("-0")
9     @two = BigDecimal("2")
10     @three = BigDecimal("3")
11     @eleven = BigDecimal("11")
12     @nan = BigDecimal("NaN")
13     @infinity = BigDecimal("Infinity")
14     @infinity_minus = BigDecimal("-Infinity")
15     @one_minus = BigDecimal("-1")
16     @frac_1 = BigDecimal("1E-99999")
17     @frac_2 = BigDecimal("0.9E-99999")
18   end
20   it "returns a / b" do
21     @two.send(@method, @one, *@object).should == @two
22     @one.send(@method, @two, *@object).should == BigDecimal("0.5")
23     @eleven.send(@method, @three, *@object).should be_close(@three + (@two / @three), TOLERANCE)
24     @one.send(@method, @one_minus, *@object).should == @one_minus
25     @one_minus.send(@method, @one_minus, *@object).should == @one
26     @frac_2.send(@method, @frac_1, *@object).should == BigDecimal("0.9")
27     @frac_1.send(@method, @frac_1, *@object).should == @one
28     @one.send(@method, BigDecimal('-2E5555'), *@object).should == BigDecimal('-0.5E-5555')
29     @one.send(@method, BigDecimal('2E-5555'), *@object).should == BigDecimal('0.5E5555')
30   end
32   it "returns NaN if NaN is involved" do
33     @one.send(@method, @nan, *@object).nan?.should == true
34     @nan.send(@method ,@one).nan?.should == true
35   end
37   it "returns 0 if divided by Infinity" do
38     @zero.send(@method, @infinity, *@object).should == 0
39     @frac_2.send(@method, @infinity, *@object).should == 0
40   end
42   it "returns (+|-) Infinity if (+|-) Infinity divided by one" do
43     @infinity_minus.send(@method, @one, *@object).should == @infinity_minus
44     @infinity.send(@method, @one, *@object).should == @infinity
45     @infinity_minus.send(@method, @one_minus, *@object).should == @infinity
46   end
48   it "returns NaN if Infinity / ((+|-) Infinity)" do
49     @infinity.send(@method, @infinity_minus, *@object).nan?.should == true
50     @infinity_minus.send(@method, @infinity, *@object).nan?.should == true
51   end
53   it "returns (+|-) Infinity if divided by zero" do
54     @one.send(@method, @zero, *@object).should == @infinity
55     @one.send(@method, @zero_plus, *@object).should == @infinity
56     @one.send(@method, @zero_minus, *@object).should == @infinity_minus
57   end
59   it "returns NaN if zero is divided by zero" do
60     @zero.send(@method, @zero, *@object).nan?.should == true
61     @zero_minus.send(@method, @zero_plus, *@object).nan?.should == true
62     @zero_plus.send(@method, @zero_minus, *@object).nan?.should == true
63   end
64 end