Skip to content

Commit

Permalink
more assertions.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
akr committed Jul 14, 2007
1 parent f3750db commit 75d484a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/ruby/test_integer.rb
Expand Up @@ -14,7 +14,7 @@ class TestInteger < Test::Unit::TestCase
-0x100000001,
-0x100000000,
-0xffffffff,
-0xc717a08d,
-0xc717a08d, # 0xc717a08d * 0x524b2245 = 0x4000000000000001
-0x524b2245,
-0x40000002,
-0x40000001,
Expand All @@ -24,7 +24,7 @@ class TestInteger < Test::Unit::TestCase
-0x10001,
-0x10000,
-0xffff,
-0x8101,
-0x8101, # 0x8101 * 0x7f01 = 0x40000001
-0x8002,
-0x8001,
-0x8000,
Expand Down Expand Up @@ -95,6 +95,7 @@ def test_plus
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
Expand Down Expand Up @@ -123,9 +124,12 @@ def test_mult
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
Expand Down Expand Up @@ -172,6 +176,7 @@ def test_or
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})")
Expand All @@ -184,6 +189,7 @@ def test_and
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}")
Expand All @@ -196,6 +202,7 @@ def test_xor
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}")
Expand Down

0 comments on commit 75d484a

Please sign in to comment.