From 631dde2572eb78cbf09d73d23a43852ccb199bd1 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 25 Nov 2016 06:28:00 +0000 Subject: 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 --- test/test_mathn.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/test_mathn.rb') diff --git a/test/test_mathn.rb b/test/test_mathn.rb index 2ea049502c..bafc4c8dbc 100644 --- a/test/test_mathn.rb +++ b/test/test_mathn.rb @@ -157,6 +157,27 @@ class TestMathn < Test::Unit::TestCase assert_equal((-12/5), (-12/5).round(2, half: :up)) assert_equal(( -5/2), ( -5/2).round(2, half: :up)) assert_equal((-13/5), (-13/5).round(2, half: :up)) + + assert_equal( 3, ( 13/5).round(half: :down)) + assert_equal( 2, ( 5/2).round(half: :down)) + assert_equal( 2, ( 12/5).round(half: :down)) + assert_equal(-2, (-12/5).round(half: :down)) + assert_equal(-2, ( -5/2).round(half: :down)) + assert_equal(-3, (-13/5).round(half: :down)) + + assert_equal( 3, ( 13/5).round(0, half: :down)) + assert_equal( 2, ( 5/2).round(0, half: :down)) + assert_equal( 2, ( 12/5).round(0, half: :down)) + assert_equal(-2, (-12/5).round(0, half: :down)) + assert_equal(-2, ( -5/2).round(0, half: :down)) + assert_equal(-3, (-13/5).round(0, half: :down)) + + assert_equal(( 13/5), ( 13/5).round(2, half: :down)) + assert_equal(( 5/2), ( 5/2).round(2, half: :down)) + assert_equal(( 12/5), ( 12/5).round(2, half: :down)) + assert_equal((-12/5), (-12/5).round(2, half: :down)) + assert_equal(( -5/2), ( -5/2).round(2, half: :down)) + assert_equal((-13/5), (-13/5).round(2, half: :down)) EOS end end -- cgit v1.2.3