mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_*.rb: replace 'assert(a == b)' with assert_equal(a, b)'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d9f38cbee8
commit
65264eadbd
25 changed files with 545 additions and 539 deletions
|
@ -15,18 +15,18 @@ class TestBignum < Test::Unit::TestCase
|
|||
|
||||
def test_bignum
|
||||
$x = fact(40)
|
||||
assert($x == $x)
|
||||
assert($x == fact(40))
|
||||
assert_equal($x, $x)
|
||||
assert_equal($x, fact(40))
|
||||
assert($x < $x+2)
|
||||
assert($x > $x-2)
|
||||
assert($x == 815915283247897734345611269596115894272000000000)
|
||||
assert($x != 815915283247897734345611269596115894272000000001)
|
||||
assert($x+1 == 815915283247897734345611269596115894272000000001)
|
||||
assert($x/fact(20) == 335367096786357081410764800000)
|
||||
assert_equal($x, 815915283247897734345611269596115894272000000000)
|
||||
assert_not_equal($x, 815915283247897734345611269596115894272000000001)
|
||||
assert_equal($x+1, 815915283247897734345611269596115894272000000001)
|
||||
assert_equal($x/fact(20), 335367096786357081410764800000)
|
||||
$x = -$x
|
||||
assert($x == -815915283247897734345611269596115894272000000000)
|
||||
assert(2-(2**32) == -(2**32-2))
|
||||
assert(2**32 - 5 == (2**32-3)-2)
|
||||
assert_equal($x, -815915283247897734345611269596115894272000000000)
|
||||
assert_equal(2-(2**32), -(2**32-2))
|
||||
assert_equal(2**32 - 5, (2**32-3)-2)
|
||||
|
||||
$good = true;
|
||||
for i in 1000..1014
|
||||
|
@ -65,33 +65,33 @@ class TestBignum < Test::Unit::TestCase
|
|||
def test_calc
|
||||
b = 10**80
|
||||
a = b * 9 + 7
|
||||
assert(7 == a.modulo(b))
|
||||
assert(-b + 7 == a.modulo(-b))
|
||||
assert(b + -7 == (-a).modulo(b))
|
||||
assert(-7 == (-a).modulo(-b))
|
||||
assert(7 == a.remainder(b))
|
||||
assert(7 == a.remainder(-b))
|
||||
assert(-7 == (-a).remainder(b))
|
||||
assert(-7 == (-a).remainder(-b))
|
||||
assert_equal(7, a.modulo(b))
|
||||
assert_equal(-b + 7, a.modulo(-b))
|
||||
assert_equal(b + -7, (-a).modulo(b))
|
||||
assert_equal(-7, (-a).modulo(-b))
|
||||
assert_equal(7, a.remainder(b))
|
||||
assert_equal(7, a.remainder(-b))
|
||||
assert_equal(-7, (-a).remainder(b))
|
||||
assert_equal(-7, (-a).remainder(-b))
|
||||
|
||||
assert(10**40+10**20 == 10000000000000000000100000000000000000000)
|
||||
assert(10**40/10**20 == 100000000000000000000)
|
||||
assert_equal(10**40+10**20, 10000000000000000000100000000000000000000)
|
||||
assert_equal(10**40/10**20, 100000000000000000000)
|
||||
|
||||
a = 677330545177305025495135714080
|
||||
b = 14269972710765292560
|
||||
assert(a % b == 0)
|
||||
assert(-a % b == 0)
|
||||
assert_equal(a % b, 0)
|
||||
assert_equal(-a % b, 0)
|
||||
end
|
||||
|
||||
def test_shift
|
||||
def shift_test(a)
|
||||
b = a / (2 ** 32)
|
||||
c = a >> 32
|
||||
assert(b == c)
|
||||
assert_equal(b, c)
|
||||
|
||||
b = a * (2 ** 32)
|
||||
c = a << 32
|
||||
assert(b == c)
|
||||
assert_equal(b, c)
|
||||
end
|
||||
|
||||
shift_test(-4518325415524767873)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue