Skip to content

Instantly share code, notes, and snippets.

@jacbar
Created May 23, 2011 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacbar/987571 to your computer and use it in GitHub Desktop.
Save jacbar/987571 to your computer and use it in GitHub Desktop.
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
}
Failures:
1) Rational should be equal to float
Failure/Error: (a+b).to_f.should == (1.0*a1/b1 + 1.0*a2/b2)
expected: 2.337885154061625
got: 2.3378851413726807 (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: 7.332775919732441
got: 7.332776069641113 (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: 2.9200879765395893
got: 2.920088052749634 (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: 0.42756756756756753
got: 0.42756757140159607 (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: 0.9358075820324944
got: 0.9358075857162476 (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.4615384615384617
got: 3.461538553237915 (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: 60.88
got: 60.880001068115234 (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: 1.85178727114211
got: 1.8517873287200928 (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: 38.58163265306123
got: 38.581634521484375 (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/b1 + 1.0*a2/b2)
expected: 6.123076923076923
got: 6.123076915740967 (using ==)
# ./spec/rational_spec.rb:19:in `block (3 levels) in <top (required)>'
Finished in 0.00339 seconds
12 examples, 10 failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment