Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3a7c8675ba81
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 888604cb38a1
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Apr 14, 2015

  1. Kernel#Integer('xyz', 36) should == 44027, but Kernel#Integer('xyz', …

    …10) should raise ArgumentError
    vais committed Apr 14, 2015
    Copy the full SHA
    f1fe80b View commit details

Commits on Apr 15, 2015

  1. Merge pull request #797 from vais/integer

    Kernel#Integer('xyz', 36) should == 44027, but Kernel#Integer('xyz', 10) should raise ArgumentError
    meh committed Apr 15, 2015
    Copy the full SHA
    888604c View commit details
Showing with 9 additions and 5 deletions.
  1. +9 −5 opal/corelib/kernel.rb
14 changes: 9 additions & 5 deletions opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -443,7 +443,7 @@ def instance_variables

def Integer(value, base = undefined)
%x{
var i, str;
var i, str, base_digits;
if (!value.$$is_string) {
if (base !== undefined) {
@@ -480,10 +480,6 @@ def Integer(value, base = undefined)
str = str.replace(/(\d)_(\d)/g, '$1$2');
if (!/^\s*[+-]?[0-9a-z]+\s*$/.test(str)) {
#{raise ArgumentError, "invalid value for Integer(): \"#{value}\""}
}
str = str.replace(/^(\s*[+-]?)(0[bodx]?)/, function (_, head, flag) {
switch (flag) {
case '0b':
@@ -511,6 +507,14 @@ def Integer(value, base = undefined)
#{raise ArgumentError, "invalid value for Integer(): \"#{value}\""}
});
base = (base === 0 ? 10 : base);
base_digits = '0-' + (base <= 10 ? base - 1 : '9a-' + String.fromCharCode(97 + (base - 11)));
if (!(new RegExp('^\\s*[+-]?[' + base_digits + ']+\\s*$')).test(str)) {
#{raise ArgumentError, "invalid value for Integer(): \"#{value}\""}
}
i = parseInt(str, base);
if (isNaN(i)) {