Sha256: fac2244310be88bdd7225da876456b5ba0348971b956961aed082dfb5ed37599

Contents?: true

Size: 801 Bytes

Versions: 33

Compression:

Stored size: 801 Bytes

Contents

describe "String#to_i" do
  it "returns 0 for strings with leading underscores" do
    "_123".to_i.should == 0
  end

  it "ignores subsequent invalid characters" do
    "123asdf".to_i.should == 123
    "123#123".to_i.should == 123
    "123 456".to_i.should == 123
  end

  it "interprets leading characters as a number in the given base" do
    "10110010010".to_i(2).should == 1426
    "100110201001".to_i(3).should == 186409
    "103110201001".to_i(4).should == 5064769
    "103110241001".to_i(5).should == 55165126
    "153110241001".to_i(6).should == 697341529
    "153160241001".to_i(7).should == 3521513430
    "153160241701".to_i(8).should == 14390739905
    "853160241701".to_i(9).should == 269716550518
    "853160241791".to_i(10).should == 853160241791

    "5e10".to_i.should == 5
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
opal-0.5.5 spec/opal/core/string/to_i_spec.rb
opal-0.5.4 spec/corelib/string/to_i_spec.rb
opal-0.5.2 spec/corelib/string/to_i_spec.rb
opal-0.5.0 spec/corelib/string/to_i_spec.rb
opal-0.4.4 spec/rubyspec/core/string/to_i_spec.rb
opal-0.4.3 spec/rubyspec/core/string/to_i_spec.rb
opal-0.4.2 spec/rubyspec/core/string/to_i_spec.rb
opal-0.4.1 spec/rubyspec/core/string/to_i_spec.rb
opal-0.4.0 spec/rubyspec/core/string/to_i_spec.rb
opal-0.3.44 spec/rubyspec/core/string/to_i_spec.rb
opal-0.3.43 spec/rubyspec/core/string/to_i_spec.rb
opal-0.3.42 spec/core/string/to_i_spec.rb
opal-0.3.41 spec/core/string/to_i_spec.rb
opal-0.3.40 spec/core/string/to_i_spec.rb
opal-0.3.39 spec/core/string/to_i_spec.rb
opal-0.3.38 spec/core/string/to_i_spec.rb
opal-0.3.37 spec/core/string/to_i_spec.rb
opal-0.3.36 spec/core/string/to_i_spec.rb
opal-0.3.35 spec/core/string/to_i_spec.rb
opal-0.3.34 spec/core/string/to_i_spec.rb