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: 888604cb38a1
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ae3ae6c32550
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Apr 15, 2015

  1. Fix underscore stripping regex in Kernel#Integer and Kernel#Float

    The regex /(\d)_(\d)/g did not handle some cases correctly, e.g.
    ”10_1_0.5_5_5" became “101_0.55_5” instead of the expected “1010.555”.
    This issue was not caught by any of the rubyspec code for
    Kernel#Integer and Kernel#Float, but surfaced when testing
    Kernel#format. Changing the regex to /(\d)_(?=\d)/g fixed the issue.
    vais committed Apr 15, 2015
    Copy the full SHA
    0c08ea8 View commit details
  2. Merge pull request #799 from vais/fix-underscore-stripping-regex

    Fix underscore stripping regex in Kernel#Integer and Kernel#Float
    meh committed Apr 15, 2015
    Copy the full SHA
    ae3ae6c View commit details
Showing with 2 additions and 2 deletions.
  1. +2 −2 opal/corelib/kernel.rb
4 changes: 2 additions & 2 deletions opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -478,7 +478,7 @@ def Integer(value, base = undefined)
str = value.toLowerCase();
str = str.replace(/(\d)_(\d)/g, '$1$2');
str = str.replace(/(\d)_(?=\d)/g, '$1');
str = str.replace(/^(\s*[+-]?)(0[bodx]?)/, function (_, head, flag) {
switch (flag) {
@@ -536,7 +536,7 @@ def Float(value)
if (value.$$is_string) {
str = value.toString();
str = str.replace(/(\d)_(\d)/g, '$1$2');
str = str.replace(/(\d)_(?=\d)/g, '$1');
if (!/^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$/.test(str)) {
#{raise ArgumentError, "invalid value for Float(): \"#{value}\""}