Sha256: 41ce6151cfd9a5efb3d9b7f4b054e0d8707df775c202007eb13cb89aeb7db8bb

Contents?: true

Size: 1.04 KB

Versions: 19

Compression:

Stored size: 1.04 KB

Contents

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

describe "Math.sqrt" do
  it "returns a float" do
    Math.sqrt(1).class.should == Float
  end
  
  it "returns the square root of the argument" do
    Math.sqrt(1).should == 1.0
    Math.sqrt(4.0).should == 2.0
    Math.sqrt(15241578780673814.441547445).to_s.should == '123456789.123457'
  end

  it "raises an ArgumentError if the argument cannot be coerced with Float()" do
    lambda { Math.sqrt("test") }.should raise_error(ArgumentError)
  end

  it "raises a TypeError if the argument is nil" do
    lambda { Math.sqrt(nil) }.should raise_error(TypeError)
  end    
  
  it "accepts any argument that can be coerced with Float()" do
    Math.sqrt(MathSpecs::Float.new).should be_close(1.0, TOLERANCE)
  end
end

describe "Math#sqrt" do
  it "is accessible as a private instance method" do
    IncludesMath.new.send(:sqrt, 2.23).should be_close(1.49331845230681, TOLERANCE)
  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/sqrt_spec.rb
rhodes-2.0.0.beta10 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-2.0.0.beta9 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-2.0.0.beta8 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-2.0.0.beta7 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-2.0.0.beta6 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-2.0.0.beta4 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-2.0.0.beta3 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.5.5 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-2.0.0.beta2 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-2.0.0.beta1 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.5.4 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.5.3 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.5.2 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.5.1 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.5.0 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.4.2 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.4.1 spec/framework_spec/app/spec/core/math/sqrt_spec.rb
rhodes-1.4.0 spec/framework_spec/app/spec/core/math/sqrt_spec.rb