numeric.c: Bignum 0 is not positive
* numeric.c (num_positive_p): should false on Bignum 0. http://twitter.com/rafaelfranca/status/600509783427391488 [ruby-core:69173] [Feature #11151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8c7310e713
commit
b4e5bff89d
@ -1,3 +1,9 @@
|
||||
Tue May 19 13:10:08 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* numeric.c (num_positive_p): should false on Bignum 0.
|
||||
http://twitter.com/rafaelfranca/status/600509783427391488
|
||||
[ruby-core:69173] [Feature #11151]
|
||||
|
||||
Tue May 19 11:22:28 2015 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* lib/uri/rfc2396_parser.rb (initialize_pattern):
|
||||
|
@ -666,7 +666,7 @@ num_positive_p(VALUE num)
|
||||
}
|
||||
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
||||
if (method_basic_p(rb_cBignum))
|
||||
return BIGNUM_POSITIVE_P(num);
|
||||
return BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num);
|
||||
}
|
||||
return RTEST(compare_with_zero(num, mid));
|
||||
}
|
||||
|
@ -268,6 +268,18 @@ class TestBignum < Test::Unit::TestCase
|
||||
assert_equal(2**180, (2**80) * o)
|
||||
end
|
||||
|
||||
def test_positive_p
|
||||
assert_predicate(T_ONE, :positive?)
|
||||
assert_not_predicate(T_MONE, :positive?)
|
||||
assert_not_predicate(T_ZERO, :positive?)
|
||||
end
|
||||
|
||||
def test_negative_p
|
||||
assert_not_predicate(T_ONE, :negative?)
|
||||
assert_predicate(T_MONE, :negative?)
|
||||
assert_not_predicate(T_ZERO, :negative?)
|
||||
end
|
||||
|
||||
def test_mul_balance
|
||||
assert_equal(3**7000, (3**5000) * (3**2000))
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user