diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-12-11 16:40:39 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2019-12-11 16:40:39 +0900 |
| commit | 7192429e83b3931928d163fc32bf704d513a9f72 (patch) | |
| tree | ebb43bdd2763ef2c744fab6d1db251e64f01e84e /test | |
| parent | 994da0fd7375b2ef0fb618db66ffeeac8fd9b383 (diff) | |
| download | mruby-7192429e83b3931928d163fc32bf704d513a9f72.tar.gz mruby-7192429e83b3931928d163fc32bf704d513a9f72.zip | |
Fix behavior of `Kernel#Integer` to numbers ending with `_` and spaces
#### Before this patch:
```ruby
Integer("1_ ") #=> 1
```
#### After this patch (same as Ruby):
```ruby
Integer("1_ ") #=> ArgumentError
```
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/string.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/test/t/string.rb b/test/t/string.rb index ed7e4b8f4..2bb988810 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -699,6 +699,7 @@ assert('String#to_f', '15.2.10.5.38') do assert_operator(68.0, :eql?, '68_'.to_f) assert_operator(68.0, :eql?, '68._7'.to_f) assert_operator(68.7, :eql?, '68.7_'.to_f) + assert_operator(68.7, :eql?, '68.7_ '.to_f) assert_operator(6.0, :eql?, '6 8.7'.to_f) assert_operator(68.0, :eql?, '68. 7'.to_f) assert_operator(0.0, :eql?, '_68'.to_f) @@ -720,6 +721,7 @@ assert('String#to_i', '15.2.10.5.39') do assert_operator 12, :eql?, '1_2__3'.to_i assert_operator 123, :eql?, '1_2_3'.to_i assert_operator 68, :eql?, '68_'.to_i + assert_operator 68, :eql?, '68_ '.to_i assert_operator 0, :eql?, '_68'.to_i assert_operator 0, :eql?, ' _68'.to_i assert_operator 68, :eql?, "\t\r\n\f\v 68 \t\r\n\f\v".to_i |
