Sha256: 0b5c0c0eabd45aca2045b87b98051a4b76a2e01495aec2bd898d2619cff1cae6

Contents?: true

Size: 1.47 KB

Versions: 52

Compression:

Stored size: 1.47 KB

Contents

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

# arctangent : (-Inf, Inf) --> (-PI/2, PI/2)
describe "Math.atan" do
  it "returns a float" do
    Math.atan(1).should be_kind_of(Float)
  end

  it "return the arctangent of the argument" do
    Math.atan(1).should be_close(Math::PI/4, TOLERANCE)
    Math.atan(0).should be_close(0.0, TOLERANCE)
    Math.atan(-1).should be_close(-Math::PI/4, TOLERANCE)
    Math.atan(0.25).should be_close(0.244978663126864, TOLERANCE)
    Math.atan(0.50).should be_close(0.463647609000806, TOLERANCE)
    Math.atan(0.75).should be_close(0.643501108793284, TOLERANCE)
  end

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

  ruby_version_is "1.9" do
    it "raises a TypeError if the argument cannot be coerced with Float()" do
      lambda { Math.atan("test") }.should raise_error(TypeError)
    end
  end

  it "raises a TypeError if the argument is nil" do
    lambda { Math.atan(nil) }.should raise_error(TypeError)
  end

  it "accepts any argument that can be coerced with Float()" do
    Math.atan(MathSpecs::Float.new).should be_close(0.785398163397448, TOLERANCE)
  end
end

describe "Math#atan" do
  it "is accessible as a private instance method" do
    IncludesMath.new.send(:atan, 3.1415).should be_close(1.2626187313511, TOLERANCE)
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

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