Sha256: 163a9a09d6788041b916988ec3f1cba40fb45d8a0c1ea33953834db54afc83df

Contents?: true

Size: 933 Bytes

Versions: 83

Compression:

Stored size: 933 Bytes

Contents

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

describe "Fixnum#**" do
  it "returns self raised to the given power" do
    (2 ** 0).should == 1
    (2 ** 1).should == 2
    (2 ** 2).should == 4

    (9 ** 0.5).to_s.should == '3.0'
    (5 ** -1).to_f.to_s.should == '0.2'

    (2 ** 40).should == 1099511627776
  end

  conflicts_with :Rational do
#    ruby_bug "ruby-dev:32084", "1.8.6.138" do
#      it "returns Infinity for 0**-1" do
#        (0**-1).should be_kind_of(Float)
#        (0**-1).infinite?.should == 1
#      end
#    end

    it "raises a TypeError when given a non-Integer" do
      lambda {
        (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10)
        13 ** obj
      }.should raise_error(TypeError)
      lambda { 13 ** "10"    }.should raise_error(TypeError)
      lambda { 13 ** :symbol }.should raise_error(TypeError)
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/fixnum/exponent_spec.rb