Sha256: 2099320763cde101b6c8036478fc27e54908d9956a066434ecd4327d3a24b8be
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' describe Numeric do it 'should respond to the new methods' do [10,10.5].each do |num| num.should respond_to(*%w(square cube sqrt root ln log)) end end it 'should return Numeric from most new methods' do %w(square cube sqrt root ln log).each do |method| [10,10.5].each do |num| num.send(method.intern).should be_a_kind_of(Numeric) end end end it 'should do squares' do 4.square.should == 16 -4.square.should == 16 end it 'should do cubes' do 3.cube.should == 27 -3.cube.should == -27 end it 'should do square roots' do 9.sqrt.should == 3 81.sqrt.should == 9 end it 'should do roots' do 9.sqrt.should == 9.root 27.root(3).should == 3 81.root(4).should == 3 5.root(1).should == 5 10.root(-1).should == 0.1 100.root(-2).should == 0.1 end it 'should do ln' do Math::E.ln.should == 1 Math::PI.ln.should be_close(1.14473, 0.001) end it 'should do log' do 10.log.should == 1 100.log.should == 2 Math::PI.log.should be_close(0.4971, 0.0001) end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
darkhelmet-darkext-0.12.0 | spec/numeric_spec.rb |
darkext-0.12.0 | spec/numeric_spec.rb |