Sha256: f4b208d24ac1d587004f7dd57ece44d8c08d585d59e3344b18f28bf148e9f4c0

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes'

describe "Math.frexp" do
  it "returns the normalized fraction and exponent" do
    frac, exp = Math.frexp(102.83)
    frac.should be_close(0.803359375, TOLERANCE)
    exp.should == 7
  end

  it "raises an ArgumentError if the argument cannot be coerced with Float()" do    
    lambda { Math.frexp("test") }.should raise_error(ArgumentError)
  end
  
  it "raises a TypeError if the argument is nil" do
    lambda { Math.frexp(nil) }.should raise_error(TypeError)
  end
  
  it "accepts any argument that can be coerced with Float()" do
    frac, exp = Math.frexp(MathSpecs::Float.new)
    frac.should be_close(0.5, TOLERANCE)
    exp.should == 1
  end
end

describe "Math#frexp" do
  it "is accessible as a private instance method" do
    frac, exp = IncludesMath.new.send(:frexp, 2.1415)
    frac.should be_close(0.535375, TOLERANCE)
    exp.should == 2
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rhodes-2.0.0.beta11 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta10 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta9 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta8 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta7 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta6 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta4 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta3 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.5.5 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta2 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-2.0.0.beta1 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.5.4 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.5.3 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.5.2 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.5.1 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.5.0 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.4.2 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.4.1 spec/framework_spec/app/spec/core/math/frexp_spec.rb
rhodes-1.4.0 spec/framework_spec/app/spec/core/math/frexp_spec.rb