From 744701f40464355af08734482b7ec02f6447ca25 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 13 Jul 2007 14:50:06 +0000 Subject: more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_integer.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/ruby/test_integer.rb') 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 -- cgit v1.2.3