Sha256: 95963287b166d40fa26973dccc27ceaddf37e9daba1925cceed7794ce02efd63

Contents?: true

Size: 983 Bytes

Versions: 70

Compression:

Stored size: 983 Bytes

Contents

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

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

  it "overflows the answer to a bignum transparantly" do
    (2 ** 29).should == 536870912
    (2 ** 30).should == 1073741824
    (2 ** 31).should == 2147483648
    (2 ** 32).should == 4294967296

    (2 ** 61).should == 2305843009213693952
    (2 ** 62).should == 4611686018427387904
    (2 ** 63).should == 9223372036854775808
    (2 ** 64).should == 18446744073709551616
  end

  it "raises negative numbers to the given power" do
    ((-2) ** 29).should == -536870912
    ((-2) ** 30).should == 1073741824
    ((-2) ** 31).should == -2147483648
    ((-2) ** 32).should == 4294967296

    ((-2) ** 61).should == -2305843009213693952
    ((-2) ** 62).should == 4611686018427387904
    ((-2) ** 63).should == -9223372036854775808
    ((-2) ** 64).should == 18446744073709551616
  end
end

Version data entries

70 entries across 70 versions & 3 rubygems

Version Path
opal-0.10.6 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.6.beta spec/opal/core/numeric/exponent_spec.rb
opal-0.10.5 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.4 spec/opal/core/numeric/exponent_spec.rb
opal-0.11.0.rc1 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.3 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.2 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.1 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.0 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.0.rc2 spec/opal/core/numeric/exponent_spec.rb
opal-0.9.4 spec/opal/core/numeric/exponent_spec.rb
opal-0.9.3 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.0.rc1 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.0.beta5 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.0.beta4 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.0.beta3 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.0.beta2 spec/opal/core/numeric/exponent_spec.rb
opal-0.10.0.beta1 spec/opal/core/numeric/exponent_spec.rb
opal-0.9.2 spec/opal/core/numeric/exponent_spec.rb
opal-0.9.0 spec/opal/core/numeric/exponent_spec.rb