summaryrefslogtreecommitdiff
path: root/test/ruby/test_rational.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-25 06:28:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-25 06:28:00 +0000
commit631dde2572eb78cbf09d73d23a43852ccb199bd1 (patch)
treed85aad8b66468b69730c9a85362879b56f5aa41a /test/ruby/test_rational.rb
parentb6d10b6c378edcb88d3238b5c862e585ad9c8b33 (diff)
round-down
* numeric.c (round_half_down, int_round_half_down): support round-down mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rational.rb')
-rw-r--r--test/ruby/test_rational.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 834188e4d8..cf870ad3a2 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -597,12 +597,12 @@ class Rational_Test < Test::Unit::TestCase
end
def test_trunc
- [[Rational(13, 5), [ 2, 3, 2, 3, 3, 3]], # 2.6
- [Rational(5, 2), [ 2, 3, 2, 2, 2, 3]], # 2.5
- [Rational(12, 5), [ 2, 3, 2, 2, 2, 2]], # 2.4
- [Rational(-12,5), [-3, -2, -2, -2, -2, -2]], # -2.4
- [Rational(-5, 2), [-3, -2, -2, -2, -2, -3]], # -2.5
- [Rational(-13, 5), [-3, -2, -2, -3, -3, -3]], # -2.6
+ [[Rational(13, 5), [ 2, 3, 2, 3, 3, 3, 3]], # 2.6
+ [Rational(5, 2), [ 2, 3, 2, 2, 2, 3, 2]], # 2.5
+ [Rational(12, 5), [ 2, 3, 2, 2, 2, 2, 2]], # 2.4
+ [Rational(-12,5), [-3, -2, -2, -2, -2, -2, -2]], # -2.4
+ [Rational(-5, 2), [-3, -2, -2, -2, -2, -3, -2]], # -2.5
+ [Rational(-13, 5), [-3, -2, -2, -3, -3, -3, -3]], # -2.6
].each do |i, a|
s = proc {i.inspect}
assert_equal(a[0], i.floor, s)
@@ -611,6 +611,7 @@ class Rational_Test < Test::Unit::TestCase
assert_equal(a[3], i.round, s)
assert_equal(a[4], i.round(half: :even), s)
assert_equal(a[5], i.round(half: :up), s)
+ assert_equal(a[6], i.round(half: :down), s)
end
end