diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-13 14:50:06 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-13 14:50:06 +0000 |
commit | e6c31a06a9cfef8738140932128943410b0d95fc (patch) | |
tree | 1d2ec9f9be6dd6f02e3fd6854d678a8c8d91837c /test/ruby | |
parent | 5285afc529bd99c2da1a2f64b0a805d894ceb6b7 (diff) | |
download | ruby-e6c31a06a9cfef8738140932128943410b0d95fc.tar.gz ruby-e6c31a06a9cfef8738140932128943410b0d95fc.tar.xz ruby-e6c31a06a9cfef8738140932128943410b0d95fc.zip |
more tests.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_integer.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 1bce4102c..a5c7aab7f 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 |