1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2016-11-01 12:35:32 +00:00
parent 22e41718a4
commit cbfe54c560
2 changed files with 10 additions and 1 deletions

View file

@ -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;

View file

@ -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