From a7357c196559f3181e359662d92cb06d7b18e3cb Mon Sep 17 00:00:00 2001 From: nahi Date: Sat, 6 Sep 2003 17:27:58 +0000 Subject: * test/ruby/test_*.rb: assert_same, assert_match, and so on. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_bignum.rb | 18 +++++++++--------- test/ruby/test_hash.rb | 4 ++-- test/ruby/test_iterator.rb | 4 ++-- test/ruby/test_pack.rb | 2 +- test/ruby/test_stringchar.rb | 2 +- test/ruby/test_system.rb | 1 - test/ruby/test_trace.rb | 8 ++++---- test/ruby/test_variable.rb | 9 +++------ test/ruby/test_whileuntil.rb | 4 ++-- 9 files changed, 24 insertions(+), 28 deletions(-) (limited to 'test') diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index 0ba2397c54..d05bc5406b 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -72,17 +72,17 @@ class TestBignum < Test::Unit::TestCase assert_equal(0, -a % b) end - def test_shift - def shift_test(a) - b = a / (2 ** 32) - c = a >> 32 - assert_equal(b, c) + def shift_test(a) + b = a / (2 ** 32) + c = a >> 32 + assert_equal(b, c) - b = a * (2 ** 32) - c = a << 32 - assert_equal(b, c) - end + b = a * (2 ** 32) + c = a << 32 + assert_equal(b, c) + end + def test_shift shift_test(-4518325415524767873) shift_test(-0xfffffffffffffffff) end diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 22c694ef1f..e21c464de3 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -45,11 +45,11 @@ class TestHash < Test::Unit::TestCase $x = Hash.new([]) assert_equal([], $x[22]) - assert($x[22].equal?($x[22])) + assert_same($x[22], $x[22]) $x = Hash.new{[]} assert_equal([], $x[22]) - assert(!$x[22].equal?($x[22])) + assert_not_same($x[22], $x[22]) $x = Hash.new{|h,k| $z = k; h[k] = k*2} $z = 0 diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb index 296efaf269..4947ed26ce 100644 --- a/test/ruby/test_iterator.rb +++ b/test/ruby/test_iterator.rb @@ -252,7 +252,7 @@ class TestIterator < Test::Unit::TestCase assert_nothing_raised {Proc.new{|a,|}.call(1,2)} end - def return1_test # !! test_return1 -> return1_test + def return1_test Proc.new { return 55 }.call + 5 @@ -262,7 +262,7 @@ class TestIterator < Test::Unit::TestCase assert_equal(55, return1_test()) end - def return2_test # !! test_return2 -> return2_test + def return2_test lambda { return 55 }.call + 5 diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 4132c89a61..c7097af423 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -13,7 +13,7 @@ class TestPack < Test::Unit::TestCase assert_equal(ary.length, ary2.length) assert_equal(ary.join(':'), ary2.join(':')) - assert($x =~ /def/) + assert_match(/def/, $x) $x = [-1073741825] assert_equal($x, $x.pack("q").unpack("q")) diff --git a/test/ruby/test_stringchar.rb b/test/ruby/test_stringchar.rb index 9e22bb35a0..e9b643ad3f 100644 --- a/test/ruby/test_stringchar.rb +++ b/test/ruby/test_stringchar.rb @@ -5,7 +5,7 @@ $KCODE = 'none' class TestStringchar < Test::Unit::TestCase def test_string assert_equal("abcd", "abcd") - assert("abcd" =~ /abcd/) + assert_match(/abcd/, "abcd") assert("abcd" === "abcd") # compile time string concatenation assert_equal("abcd", "ab" "cd") diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index 6865515d44..a3da43459f 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -57,7 +57,6 @@ class TestSystem < Test::Unit::TestCase File.unlink "script_tmp" or `/bin/rm -f "script_tmp"` File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"` - $bad = false if (dir = File.dirname(File.dirname($0))) == '.' dir = "" else diff --git a/test/ruby/test_trace.rb b/test/ruby/test_trace.rb index 4a2e7c4f82..69c0c24fe7 100644 --- a/test/ruby/test_trace.rb +++ b/test/ruby/test_trace.rb @@ -9,15 +9,15 @@ class TestTrace < Test::Unit::TestCase trace_var :$x, proc{$y = $x} $x = 40414 assert_equal($x, $y) - + untrace_var :$x $x = 19660208 - assert($y != $x) - + assert_not_equal($x, $y) + trace_var :$x, proc{$x *= 2} $x = 5 assert_equal(10, $x) - + untrace_var :$x end end diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb index 305a6f22c5..ab0e405115 100644 --- a/test/ruby/test_variable.rb +++ b/test/ruby/test_variable.rb @@ -32,14 +32,11 @@ class TestVariable < Test::Unit::TestCase end def test_variable - assert($$.instance_of?(Fixnum)) - + assert_instance_of(Fixnum, $$) + # read-only variable - begin + assert_raises(NameError) do $$ = 5 - assert false - rescue NameError - assert true end foobar = "foobar" diff --git a/test/ruby/test_whileuntil.rb b/test/ruby/test_whileuntil.rb index 0dba4c9eea..841a15135d 100644 --- a/test/ruby/test_whileuntil.rb +++ b/test/ruby/test_whileuntil.rb @@ -13,8 +13,8 @@ class TestWhileuntil < Test::Unit::TestCase tmp.close tmp = open("while_tmp", "r") - assert_kind_of(File, tmp) - + assert_instance_of(File, tmp) + while line = tmp.gets() break if /vt100/ =~ line end -- cgit v1.2.3