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

more assertions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-07-14 04:13:12 +00:00
parent f3750dbf99
commit 75d484a453

View file

@ -14,7 +14,7 @@ class TestInteger < Test::Unit::TestCase
-0x100000001,
-0x100000000,
-0xffffffff,
-0xc717a08d,
-0xc717a08d, # 0xc717a08d * 0x524b2245 = 0x4000000000000001
-0x524b2245,
-0x40000002,
-0x40000001,
@ -24,7 +24,7 @@ class TestInteger < Test::Unit::TestCase
-0x10001,
-0x10000,
-0xffff,
-0x8101,
-0x8101, # 0x8101 * 0x7f01 = 0x40000001
-0x8002,
-0x8001,
-0x8000,
@ -95,6 +95,7 @@ class TestInteger < Test::Unit::TestCase
VS.each {|a|
VS.each {|b|
c = a + b
assert_equal(b + a, c, "#{a} + #{b}")
assert_equal(a, c - b, "(#{a} + #{b}) - #{b}")
assert_equal(b, c - a, "(#{a} + #{b}) - #{a}")
assert_equal(a-~b-1, c, "#{a} + #{b}") # Hacker's Delight
@ -123,9 +124,12 @@ class TestInteger < Test::Unit::TestCase
VS.each {|a|
VS.each {|b|
c = a * b
assert_equal(b * a, c, "#{a} * #{b}")
assert_equal(a, c / b, "(#{a} * #{b}) / #{b}") if b != 0
assert_equal(b, c / a, "(#{a} * #{b}) / #{a}") if a != 0
assert_equal(a.abs * b.abs, (a * b).abs, "(#{a} * #{b}).abs")
assert_equal((a-100)*(b-100)+(a-100)*100+(b-100)*100+10000, c, "#{a} * #{b}")
assert_equal((a+100)*(b+100)-(a+100)*100-(b+100)*100+10000, c, "#{a} * #{b}")
}
}
end
@ -172,6 +176,7 @@ class TestInteger < Test::Unit::TestCase
VS.each {|a|
VS.each {|b|
c = a | b
assert_equal(b | a, c, "#{a} | #{b}")
assert_equal(a + b - (a&b), c, "#{a} | #{b}")
assert_equal((a & ~b) + b, c, "#{a} | #{b}") # Hacker's Delight
assert_equal(-1, c | ~a, "(#{a} | #{b}) | ~#{a})")
@ -184,6 +189,7 @@ class TestInteger < Test::Unit::TestCase
VS.each {|a|
VS.each {|b|
c = a & b
assert_equal(b & a, c, "#{a} & #{b}")
assert_equal(a + b - (a|b), c, "#{a} & #{b}")
assert_equal((~a | b) - ~a, c, "#{a} & #{b}") # Hacker's Delight
assert_equal(0, c & ~a, "(#{a} & #{b}) & ~#{a}")
@ -196,6 +202,7 @@ class TestInteger < Test::Unit::TestCase
VS.each {|a|
VS.each {|b|
c = a ^ b
assert_equal(b ^ a, c, "#{a} ^ #{b}")
assert_equal((a|b)-(a&b), c, "#{a} ^ #{b}") # Hacker's Delight
assert_equal(b, c ^ a, "(#{a} ^ #{b}) ^ #{a}")
assert_equal(a, c ^ b, "(#{a} ^ #{b}) ^ #{b}")