aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-10 02:36:16 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-10 02:36:16 +0000
commit848d3a3538469c8fc2849f0079d2db3e4bc40c9f (patch)
treee5a8d6aba89ef69df04055fca981228a09399269 /test
parent81bdceb718c7beb8e3e0b1e3d28fbd7d92bbca01 (diff)
downloadruby-848d3a3538469c8fc2849f0079d2db3e4bc40c9f.tar.gz
internal.h: change the default rounding mode to half-up
* internal.h (ROUND_DEFAULT): changed to RUBY_NUM_ROUND_HALF_UP. [Bug #12958] [ruby-core:78204] * test/ruby/test_integer.rb: fix assertions for the above change. * test/ruby/test_rational.rb: ditto. * test/test_mathn.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_integer.rb8
-rw-r--r--test/ruby/test_rational.rb4
-rw-r--r--test/test_mathn.rb8
3 files changed, 10 insertions, 10 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index 18346e95f9..0a6b2f4539 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -187,7 +187,7 @@ class TestInteger < Test::Unit::TestCase
assert_int_equal(11110, 11111.round(-1))
assert_int_equal(11100, 11111.round(-2))
assert_int_equal(+200, +249.round(-2))
- assert_int_equal(+200, +250.round(-2))
+ assert_int_equal(+300, +250.round(-2))
assert_int_equal(-200, -249.round(-2))
assert_int_equal(+200, +249.round(-2, half: :even))
assert_int_equal(+200, +250.round(-2, half: :even))
@@ -201,7 +201,7 @@ class TestInteger < Test::Unit::TestCase
assert_int_equal(+200, +250.round(-2, half: :down))
assert_int_equal(+300, +349.round(-2, half: :down))
assert_int_equal(+300, +350.round(-2, half: :down))
- assert_int_equal(-200, -250.round(-2))
+ assert_int_equal(-300, -250.round(-2))
assert_int_equal(-200, -249.round(-2, half: :even))
assert_int_equal(-200, -250.round(-2, half: :even))
assert_int_equal(-300, -349.round(-2, half: :even))
@@ -214,8 +214,8 @@ class TestInteger < Test::Unit::TestCase
assert_int_equal(-200, -250.round(-2, half: :down))
assert_int_equal(-300, -349.round(-2, half: :down))
assert_int_equal(-300, -350.round(-2, half: :down))
- assert_int_equal(+20 * 10**70, (+25 * 10**70).round(-71))
- assert_int_equal(-20 * 10**70, (-25 * 10**70).round(-71))
+ assert_int_equal(+30 * 10**70, (+25 * 10**70).round(-71))
+ assert_int_equal(-30 * 10**70, (-25 * 10**70).round(-71))
assert_int_equal(+20 * 10**70, (+25 * 10**70 - 1).round(-71))
assert_int_equal(-20 * 10**70, (-25 * 10**70 + 1).round(-71))
assert_int_equal(+40 * 10**70, (+35 * 10**70).round(-71))
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 168383a106..99f80bc561 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -598,10 +598,10 @@ class Rational_Test < Test::Unit::TestCase
def test_trunc
[[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(5, 2), [ 2, 3, 2, 3, 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(-5, 2), [-3, -2, -2, -3, -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}
diff --git a/test/test_mathn.rb b/test/test_mathn.rb
index bafc4c8dbc..00130eadf1 100644
--- a/test/test_mathn.rb
+++ b/test/test_mathn.rb
@@ -96,17 +96,17 @@ class TestMathn < Test::Unit::TestCase
def test_round
assert_separately(%w[-rmathn], <<-EOS, ignore_stderr: true)
assert_equal( 3, ( 13/5).round)
- assert_equal( 2, ( 5/2).round)
+ assert_equal( 3, ( 5/2).round)
assert_equal( 2, ( 12/5).round)
assert_equal(-2, (-12/5).round)
- assert_equal(-2, ( -5/2).round)
+ assert_equal(-3, ( -5/2).round)
assert_equal(-3, (-13/5).round)
assert_equal( 3, ( 13/5).round(0))
- assert_equal( 2, ( 5/2).round(0))
+ assert_equal( 3, ( 5/2).round(0))
assert_equal( 2, ( 12/5).round(0))
assert_equal(-2, (-12/5).round(0))
- assert_equal(-2, ( -5/2).round(0))
+ assert_equal(-3, ( -5/2).round(0))
assert_equal(-3, (-13/5).round(0))
assert_equal(( 13/5), ( 13/5).round(2))