Created
May 23, 2011 20:57
-
-
Save jacbar/987587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Rational" do | |
it "should create new object" do | |
RTest.new(3).should_not be_equal nil | |
end | |
it "should be equal to inf" do | |
RTest.new(0, 3, 0).to_f.should == 1.0/00 | |
end | |
10.times { | |
it "should be equal to float" do | |
a1,b1,a2,b2 = rand(100), rand(100), rand(100), rand(100) | |
a = RTest.new(0, a1, b1) | |
b = RTest.new(0, a2, b2) | |
(a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
end | |
} | |
10.times { | |
it "should be equal to float" do | |
a1,a2 = rand(2147483648) , rand(100000) | |
a = RTest.new(0, a1, 1) | |
b = RTest.new(0, a2, 1) | |
(a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
end | |
} | |
10.times { | |
it "should be equal to float" do | |
a1,b1,a2,b2 = rand(100), rand(100), rand(100), rand(100) | |
a = RTest.new(0, a1, b1) | |
b = RTest.new(0, a2, b2) | |
(a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
end | |
} | |
end | |
Failures: | |
1) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 18.307692307692307 | |
got: 18.30769157409668 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
2) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 1.5753968253968254 | |
got: 1.5753967761993408 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
3) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 4.309565217391304 | |
got: 4.30956506729126 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
4) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 2.0883190883190883 | |
got: 2.0883190631866455 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
5) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 54.62105263157895 | |
got: 54.62105178833008 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
6) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 3.3696581196581197 | |
got: 3.3696582317352295 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
7) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 2.3002263723825696 | |
got: 2.3002264499664307 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
8) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 2.48216276477146 | |
got: 2.4821627140045166 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
9) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2) | |
expected: 4.779487179487179 | |
got: 4.779487133026123 (using ==) | |
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>' | |
10) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 103100659.0 | |
got: 103100656.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
11) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 112719123.0 | |
got: 112719120.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
12) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 1803835740.0 | |
got: 1803835776.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
13) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 877655597.0 | |
got: 877655616.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
14) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 823554274.0 | |
got: 823554304.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
15) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 1324711073.0 | |
got: 1324711040.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
16) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 690146132.0 | |
got: 690146112.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
17) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 1060368127.0 | |
got: 1060368128.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
18) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 1806265653.0 | |
got: 1806265600.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
19) Rational should be equal to float | |
Failure/Error: (a+b).to_f.should == (1.0*a1 + 1.0*a2) | |
expected: 1404454660.0 | |
got: 1404454656.0 (using ==) | |
# ./spec/rational_spec.rb:29:in `block (3 levels) in <top (required)>' | |
20) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 0.3611111111111111 | |
got: 1.6944444179534912 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
21) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 2.46875 | |
got: 3.234375 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
22) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 0.2518518518518518 | |
got: 2.0222222805023193 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
23) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 49.1764705882353 | |
got: 21.58823585510254 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
24) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 0.5211267605633803 | |
got: 1.5422534942626953 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
25) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 2.6044657097288675 | |
got: 4.034290313720703 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
26) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 0.07945687704299723 | |
got: 1.045888900756836 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
27) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 1.605899419729207 | |
got: 2.713249444961548 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
28) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 0.037990867579908674 | |
got: 0.39251142740249634 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
29) Rational should be equal to float | |
Failure/Error: (a*b).to_f.should == ((1.0*a1/b1) * (1.0*a2/b2)) | |
expected: 0.5098039215686274 | |
got: 2.5163397789001465 (using ==) | |
# ./spec/rational_spec.rb:38:in `block (3 levels) in <top (required)>' | |
Finished in 0.01648 seconds | |
32 examples, 29 failures | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment