diff options
Diffstat (limited to 'spec/ruby/core/float/fdiv_spec.rb')
| -rw-r--r-- | spec/ruby/core/float/fdiv_spec.rb | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/spec/ruby/core/float/fdiv_spec.rb b/spec/ruby/core/float/fdiv_spec.rb index 632dd0f293..8a3ead4880 100644 --- a/spec/ruby/core/float/fdiv_spec.rb +++ b/spec/ruby/core/float/fdiv_spec.rb @@ -1,6 +1,61 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/quo', __FILE__) +require_relative '../../spec_helper' describe "Float#fdiv" do - it_behaves_like :float_quo, :fdiv + it "performs floating-point division between self and an Integer" do + 8.9.fdiv(7).should == 1.2714285714285716 + end + + it "performs floating-point division between self and an Integer" do + 8.9.fdiv(9999999999999**9).should == 8.900000000008011e-117 + end + + it "performs floating-point division between self and a Float" do + 2827.22.fdiv(872.111111).should == 3.2418116961704433 + end + + it "returns NaN when the argument is NaN" do + -1819.999999.fdiv(nan_value).nan?.should == true + 11109.1981271.fdiv(nan_value).nan?.should == true + end + + it "returns Infinity when the argument is 0.0" do + 2827.22.fdiv(0.0).infinite?.should == 1 + end + + it "returns -Infinity when the argument is 0.0 and self is negative" do + -48229.282.fdiv(0.0).infinite?.should == -1 + end + + it "returns Infinity when the argument is 0" do + 2827.22.fdiv(0).infinite?.should == 1 + end + + it "returns -Infinity when the argument is 0 and self is negative" do + -48229.282.fdiv(0).infinite?.should == -1 + end + + it "returns 0.0 when the argument is Infinity" do + 47292.2821.fdiv(infinity_value).should == 0.0 + end + + it "returns -0.0 when the argument is -Infinity" do + 1.9999918.fdiv(-infinity_value).should == -0.0 + end + + it "performs floating-point division between self and a Rational" do + 74620.09.fdiv(Rational(2,3)).should == 111930.135 + end + + it "performs floating-point division between self and a Complex" do + 74620.09.fdiv(Complex(8,2)).should == Complex( + 8778.834117647059, -2194.7085294117646) + end + + it "raises a TypeError when argument isn't numeric" do + -> { 27292.2.fdiv(mock('non-numeric')) }.should.raise(TypeError) + end + + it "raises an ArgumentError when passed multiple arguments" do + -> { 272.221.fdiv(6,0.2) }.should.raise(ArgumentError) + end end |
