diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-01 12:35:32 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-01 12:35:32 +0000 |
commit | cbfe54c5609584c9c895262df6a7a58d675473ba (patch) | |
tree | e499c95c66a956a781e00a7c3ac009a881d3730c | |
parent | 22e41718a49b07b093e25e2d211a988c4a9fd6cc (diff) | |
download | ruby-cbfe54c5609584c9c895262df6a7a58d675473ba.tar.gz |
numeric.c: fix return value on big 0
* numeric.c (num_zero_p): should return true if zero.
rb_bigzero_p returns 1 or 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | numeric.c | 5 | ||||
-rw-r--r-- | test/-ext-/bignum/test_bigzero.rb | 6 |
2 files changed, 10 insertions, 1 deletions
@@ -721,7 +721,10 @@ num_zero_p(VALUE num) } } else if (RB_TYPE_P(num, T_BIGNUM)) { - return rb_bigzero_p(num); + if (rb_bigzero_p(num)) { + /* this should not happen usually */ + return Qtrue; + } } else if (rb_equal(num, INT2FIX(0))) { return Qtrue; diff --git a/test/-ext-/bignum/test_bigzero.rb b/test/-ext-/bignum/test_bigzero.rb index 8529e54456..43a99b01a3 100644 --- a/test/-ext-/bignum/test_bigzero.rb +++ b/test/-ext-/bignum/test_bigzero.rb @@ -10,5 +10,11 @@ class TestBignum < Test::Unit::TestCase assert_equal(0, Bug::Bignum.zero(i), "#{bug8204} Bignum.zero(#{i})") end end + + def test_zero? + (0..10).each do |i| + assert_equal(true, Bug::Bignum.zero(i).zero?) + end + end end end |