summaryrefslogtreecommitdiff
path: root/test/ruby/test_integer.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-13 14:50:06 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-13 14:50:06 +0000
commit744701f40464355af08734482b7ec02f6447ca25 (patch)
tree1d2ec9f9be6dd6f02e3fd6854d678a8c8d91837c /test/ruby/test_integer.rb
parent3cf28c2caa1d0edbd78082bfe7b6c01172bb861f (diff)
more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_integer.rb')
-rw-r--r--test/ruby/test_integer.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index 1bce4102c7..a5c7aab7f3 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -59,6 +59,14 @@ class TestInteger < Test::Unit::TestCase
0x10000000000000000,
]
+ def test_aref
+ VS.each {|a|
+ 100.times {|i|
+ assert_equal((a >> i).odd? ? 1 : 0, a[i], "(#{a})[#{i}]")
+ }
+ }
+ end
+
def test_plus
VS.each {|a|
VS.each {|b|
@@ -231,6 +239,18 @@ class TestInteger < Test::Unit::TestCase
}
end
+ def test_cmp
+ VS.each_with_index {|a, i|
+ VS.each_with_index {|b, j|
+ assert_equal(i <=> j, a <=> b, "#{a} <=> #{b}")
+ assert_equal(i < j, a < b, "#{a} < #{b}")
+ assert_equal(i <= j, a <= b, "#{a} <= #{b}")
+ assert_equal(i > j, a > b, "#{a} > #{b}")
+ assert_equal(i >= j, a >= b, "#{a} >= #{b}")
+ }
+ }
+ end
+
def test_eq
VS.each_with_index {|a, i|
VS.each_with_index {|b, j|
@@ -314,4 +334,14 @@ class TestInteger < Test::Unit::TestCase
end
}
end
+
+ def test_even_odd
+ VS.each {|a|
+ e = a.even?
+ o = a.odd?
+ assert_equal((a % 2) == 0, e, "(#{a}).even?")
+ assert_equal((a % 2) == 1, o, "(#{a}).odd")
+ assert(e ^ o)
+ }
+ end
end