Sha256: da6268e2c6fa62c3e88c0bd97c272ca4a29a6215c51a1a9655a297e5a12bd2fd

Contents?: true

Size: 1.12 KB

Versions: 52

Compression:

Stored size: 1.12 KB

Contents

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

describe :numeric_rect, :shared => true do
  before(:each) do
    @numbers = [
      20,             # Integer
      398.72,         # Float
      Rational(3, 4), # Rational
      99999999**99, # Bignum
      Float::MAX * 2, # Infinity
      0/0.0           # NaN
    ]
  end

  it "returns an Array" do
    @numbers.each do |number|
      number.send(@method).should be_an_instance_of(Array)
    end
  end

  it "returns a two-element Array" do
    @numbers.each do |number|
      number.send(@method).size.should == 2
    end
  end

  it "returns self as the first element" do
   @numbers.each do |number|
     if number.to_f.nan?
       number.send(@method).first.nan?.should be_true
     else
       number.send(@method).first.should == number
     end
   end
  end

  it "returns 0 as the last element" do
   @numbers.each do |number|
     number.send(@method).last.should == 0
   end
  end

  it "raises an ArgumentError if given any arguments" do
   @numbers.each do |number|
     lambda { number.send(@method, number) }.should raise_error(ArgumentError)
   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/numeric/shared/rect.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/numeric/shared/rect.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/numeric/shared/rect.rb