mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
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
This commit is contained in:
parent
92e2a7048e
commit
62fb6147cd
2 changed files with 104 additions and 157 deletions
|
@ -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']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue