diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-08 19:07:16 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-09 22:38:06 +0900 |
commit | 590dc06e3840cc7b00d80ccaac9fbf42573428f8 (patch) | |
tree | e5f6aa316246401b8d89e7419ddf0976238c04b5 /test/-ext-/bignum/test_mul.rb | |
parent | 161a20df28dd09ff35a32a7e2b7ce6cab7079707 (diff) | |
download | ruby-590dc06e3840cc7b00d80ccaac9fbf42573428f8.tar.gz |
Get rid of defining methods for tests in core classes
Not to interfere in other tests.
Diffstat (limited to 'test/-ext-/bignum/test_mul.rb')
-rw-r--r-- | test/-ext-/bignum/test_mul.rb | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/test/-ext-/bignum/test_mul.rb b/test/-ext-/bignum/test_mul.rb index 5de046a804..7653a8e37a 100644 --- a/test/-ext-/bignum/test_mul.rb +++ b/test/-ext-/bignum/test_mul.rb @@ -5,132 +5,132 @@ require "-test-/bignum" class Test_Bignum < Test::Unit::TestCase class TestMul < Test::Unit::TestCase - SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT - BITSPERDIG = Integer::BITSPERDIG + SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT + BITSPERDIG = Bug::Bignum::BITSPERDIG BDIGMAX = (1 << BITSPERDIG) - 1 def test_mul_normal x = (1 << BITSPERDIG) | 1 y = (1 << BITSPERDIG) | 1 z = (1 << (BITSPERDIG*2)) | (2 << BITSPERDIG) | 1 - assert_equal(z, x.big_mul_normal(y)) + assert_equal(z, Bug::Bignum.big_mul_normal(x, y)) end def test_mul_normal_zero_in_x x = (1 << (2*BITSPERDIG)) | 1 y = (1 << BITSPERDIG) | 1 z = (1 << (BITSPERDIG*3)) | (1 << (BITSPERDIG*2)) | (1 << BITSPERDIG) | 1 - assert_equal(z, x.big_mul_normal(y)) + assert_equal(z, Bug::Bignum.big_mul_normal(x, y)) end def test_mul_normal_zero_in_y x = (1 << BITSPERDIG) | 1 y = (1 << (2*BITSPERDIG)) | 1 z = (1 << (BITSPERDIG*3)) | (1 << (BITSPERDIG*2)) | (1 << BITSPERDIG) | 1 - assert_equal(z, x.big_mul_normal(y)) + assert_equal(z, Bug::Bignum.big_mul_normal(x, y)) end def test_mul_normal_max_max x = (1 << (2*BITSPERDIG)) - 1 y = (1 << (2*BITSPERDIG)) - 1 z = (1 << (4*BITSPERDIG)) - (1 << (2*BITSPERDIG+1)) + 1 - assert_equal(z, x.big_mul_normal(y)) + assert_equal(z, Bug::Bignum.big_mul_normal(x, y)) end def test_sq_fast x = (1 << BITSPERDIG) | 1 z = (1 << 2*BITSPERDIG) | (2 << BITSPERDIG) | 1 - assert_equal(z, x.big_sq_fast) + assert_equal(z, Bug::Bignum.big_sq_fast(x)) end def test_sq_fast_max2 x = (BDIGMAX << BITSPERDIG) | BDIGMAX - assert_equal(x.big_mul_normal(x), x.big_sq_fast) + assert_equal(Bug::Bignum.big_mul_normal(x, x), Bug::Bignum.big_sq_fast(x)) end def test_sq_fast_zero_in_middle x = (BDIGMAX << 2*BITSPERDIG) | BDIGMAX - assert_equal(x.big_mul_normal(x), x.big_sq_fast) + assert_equal(Bug::Bignum.big_mul_normal(x, x), Bug::Bignum.big_sq_fast(x)) end def test_mul_balance x = (1 << BITSPERDIG) | 1 y = (1 << BITSPERDIG) | 1 z = (1 << (BITSPERDIG*2)) | (2 << BITSPERDIG) | 1 - assert_equal(z, x.big_mul_balance(y)) + assert_equal(z, Bug::Bignum.big_mul_balance(x, y)) end def test_mul_balance_2x16 - x = (1 << Integer::BITSPERDIG) | 1 - y = (1 << Integer::BITSPERDIG*16) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_balance(y)) + x = (1 << BITSPERDIG) | 1 + y = (1 << BITSPERDIG*16) | 1 + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_balance(x, y)) end def test_mul_balance_2x17 - x = (1 << Integer::BITSPERDIG) | 1 - y = (1 << Integer::BITSPERDIG*17) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_balance(y)) + x = (1 << BITSPERDIG) | 1 + y = (1 << BITSPERDIG*17) | 1 + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_balance(x, y)) end def test_mul_karatsuba x = (1 << BITSPERDIG) | 1 y = (1 << BITSPERDIG) | 1 z = (1 << (BITSPERDIG*2)) | (2 << BITSPERDIG) | 1 - assert_equal(z, x.big_mul_karatsuba(y)) + assert_equal(z, Bug::Bignum.big_mul_karatsuba(x, y)) end def test_mul_karatsuba_odd_y x = (1 << BITSPERDIG) | 1 y = (1 << (2*BITSPERDIG)) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_karatsuba(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_karatsuba(x, y)) end def test_mul_karatsuba_odd_xy x = (1 << (2*BITSPERDIG)) | 1 y = (1 << (2*BITSPERDIG)) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_karatsuba(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_karatsuba(x, y)) end def test_mul_karatsuba_x1_gt_x0 x = (2 << BITSPERDIG) | 1 y = (1 << BITSPERDIG) | 2 - assert_equal(x.big_mul_normal(y), x.big_mul_karatsuba(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_karatsuba(x, y)) end def test_mul_karatsuba_y1_gt_y0 x = (1 << BITSPERDIG) | 2 y = (2 << BITSPERDIG) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_karatsuba(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_karatsuba(x, y)) end def test_mul_karatsuba_x1_gt_x0_and_y1_gt_y0 x = (2 << BITSPERDIG) | 1 y = (2 << BITSPERDIG) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_karatsuba(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_karatsuba(x, y)) end def test_mul_karatsuba_carry2 x = (1 << BITSPERDIG) | BDIGMAX y = (1 << BITSPERDIG) | BDIGMAX - assert_equal(x.big_mul_normal(y), x.big_mul_karatsuba(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_karatsuba(x, y)) end def test_mul_karatsuba_borrow x = (BDIGMAX << BITSPERDIG) | 1 y = (BDIGMAX << BITSPERDIG) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_karatsuba(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_karatsuba(x, y)) end def test_mul_toom3 x = (1 << 2*BITSPERDIG) | (1 << BITSPERDIG) | 1 y = (1 << 2*BITSPERDIG) | (1 << BITSPERDIG) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_toom3(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_toom3(x, y)) end def test_mul_gmp x = (1 << 2*BITSPERDIG) | (1 << BITSPERDIG) | 1 y = (1 << 2*BITSPERDIG) | (1 << BITSPERDIG) | 1 - assert_equal(x.big_mul_normal(y), x.big_mul_gmp(y)) + assert_equal(Bug::Bignum.big_mul_normal(x, y), Bug::Bignum.big_mul_gmp(x, y)) rescue NotImplementedError end |