summaryrefslogtreecommitdiff
path: root/test/ruby/test_rational.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-16 03:32:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-16 03:32:16 +0000
commit62fb6147cde44c2c697ea8c160b724d029e1cd87 (patch)
treef7a9d19f61c354c953e6a3a1694fa2aa0fd80ce3 /test/ruby/test_rational.rb
parent92e2a7048ef575bab6b166533340e91a8281d62a (diff)
rational.c: read_num
* rational.c (read_num): use rb_int_parse_cstr to parse integer parts, and make String#to_r consistent with #to_i and #to_f. [ruby-core:80098] [Bug #13105] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rational.rb')
-rw-r--r--test/ruby/test_rational.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index ff2d189eff..43bd750615 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -695,27 +695,43 @@ class Rational_Test < Test::Unit::TestCase
ok[-5, 1, '-5']
ok[ 5, 3, '5/3']
ok[-5, 3, '-5/3']
+ ok[ 5, 3, '5_5/33']
+ ok[ 5,33, '5/3_3']
+ ng[ 5, 1, '5__5/33']
+ ng[ 5, 3, '5/3__3']
ok[ 5, 1, '5.0']
ok[-5, 1, '-5.0']
ok[ 5, 3, '5.0/3']
ok[-5, 3, '-5.0/3']
+ ok[ 501,100, '5.0_1']
+ ok[ 501,300, '5.0_1/3']
+ ok[ 5,33, '5.0/3_3']
+ ng[ 5, 1, '5.0__1/3']
+ ng[ 5, 3, '5.0/3__3']
ok[ 5, 1, '5e0']
ok[-5, 1, '-5e0']
ok[ 5, 3, '5e0/3']
ok[-5, 3, '-5e0/3']
+ ok[550, 1, '5_5e1']
+ ng[ 5, 1, '5_e1']
ok[ 5e1, 1, '5e1']
ok[-5e2, 1, '-5e2']
ok[ 5e3, 3, '5e003/3']
ok[-5e4, 3, '-5e004/3']
+ ok[ 5e3, 1, '5e0_3']
+ ok[ 5e1,33, '5e1/3_3']
+ ng[ 5e0, 1, '5e0__3/3']
+ ng[ 5e1, 3, '5e1/3__3']
ok[ 33, 100, '.33']
ok[ 33, 100, '0.33']
ok[-33, 100, '-.33']
ok[-33, 100, '-0.33']
ok[-33, 100, '-0.3_3']
+ ng[ -3, 10, '-0.3__3']
ok[ 1, 2, '5e-1']
ok[50, 1, '5e+1']