Sha256: 1eb58b9e1ca97806cf40da09fede2696faf2343f813c8a3f5cfdf2d64d1730ba

Contents?: true

Size: 1.5 KB

Versions: 52

Compression:

Stored size: 1.5 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)

describe "Bignum#quo" do
  before(:each) do
    @bignum = bignum_value(3)
  end

  it "returns the result of self divided by the given Integer as a Float" do
    @bignum.quo(0xffff_afed.to_f).should be_close(2147493897.54892, TOLERANCE)
    @bignum.quo(0xabcd_effe).should be_close(3199892875.41007, TOLERANCE)
    @bignum.quo(bignum_value).should be_close(1.00000000279397, TOLERANCE)
  end

  conflicts_with :Rational do
    ruby_version_is ""..."1.9" do
      it "does not raise a ZeroDivisionError when the given Integer is 0" do
        @bignum.quo(0).to_s.should == "Infinity"
        (-@bignum).quo(0).to_s.should == "-Infinity"
      end
    end
  end

  ruby_version_is "1.9" do
    it "raises a ZeroDivisionError when the given Integer is 0" do
      lambda { @bignum.quo(0) }.should raise_error(ZeroDivisionError)
      lambda { -@bignum.quo(0) }.should raise_error(ZeroDivisionError)
    end
  end

  it "does not raise a FloatDomainError when the given argument is 0 and a Float" do
    @bignum.quo(0.0).to_s.should == "Infinity"
    (-@bignum).quo(0.0).to_s.should == "-Infinity"
  end

  conflicts_with :Rational do
    it "raises a TypeError when given a non-Integer" do
      lambda {
        (obj = mock('to_int')).should_not_receive(:to_int)
        @bignum.quo(obj)
      }.should raise_error(TypeError)
      lambda { @bignum.quo("10") }.should raise_error(TypeError)
      lambda { @bignum.quo(:symbol) }.should raise_error(TypeError)
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/bignum/quo_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/bignum/quo_spec.rb