From 6ea1aee76e2642aa0d532a00e0b971dede02d818 Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 20 Jun 2013 13:05:27 +0000 Subject: * bignum.c (bary_unpack_internal): Return -2 when negative overflow. (bary_unpack): Set the overflowed bit if an extra BDIGIT exists. (rb_integer_unpack): Set the overflowed bit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/-ext-/bignum/test_pack.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/-ext-') diff --git a/test/-ext-/bignum/test_pack.rb b/test/-ext-/bignum/test_pack.rb index 093c9bd212..c2c19a32a2 100644 --- a/test/-ext-/bignum/test_pack.rb +++ b/test/-ext-/bignum/test_pack.rb @@ -194,5 +194,10 @@ class TestBignum < Test::Unit::TestCase assert_equal( -1, Integer.test_unpack("\xFF", 1, 1, 0, TWOCOMP|BIG_ENDIAN|NEGATIVE)) end + def test_unpack2comp_negative_zero + 0.upto(100) {|n| + assert_equal(-(256**n), Integer.test_unpack("\x00"*n, n, 1, 0, TWOCOMP|BIG_ENDIAN|NEGATIVE)) + } + end end end -- cgit v1.2.3