From 44785befeabd09d5d34f33b33783c0ec54f06a1f Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 5 Sep 2003 15:15:43 +0000 Subject: * lib/optparse.rb (OptionParser#order, #permute, #parse): allow an array as argument. * test/ruby/test_*.rb: moved invariants to left side in assert_equal, and use assert_nil, assert_raises and so on. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_whileuntil.rb | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'test/ruby/test_whileuntil.rb') diff --git a/test/ruby/test_whileuntil.rb b/test/ruby/test_whileuntil.rb index ecbfed2f7a..0dba4c9eea 100644 --- a/test/ruby/test_whileuntil.rb +++ b/test/ruby/test_whileuntil.rb @@ -13,25 +13,25 @@ class TestWhileuntil < Test::Unit::TestCase tmp.close tmp = open("while_tmp", "r") - assert(tmp.kind_of?(File)) - + assert_kind_of(File, tmp) + while line = tmp.gets() break if /vt100/ =~ line end - - assert(!tmp.eof? && /vt100/ =~ line) + + assert(!tmp.eof?) + assert_match(/vt100/, line) tmp.close - $bad = false tmp = open("while_tmp", "r") while line = tmp.gets() next if /vt100/ =~ line - $bad = 1 if /vt100/ =~ line + assert_no_match(/vt100/, line) end - assert(!(!tmp.eof? || /vt100/ =~ line || $bad)) + assert(tmp.eof?) + assert_no_match(/vt100/, line) tmp.close - - $bad = false + tmp = open("while_tmp", "r") while tmp.gets() line = $_ @@ -40,12 +40,12 @@ class TestWhileuntil < Test::Unit::TestCase $_.gsub!('VT100', 'Vt100') redo end - $bad = 1 if /vt100/ =~ $_ - $bad = 1 if /VT100/ =~ $_ + assert_no_match(/vt100/, $_) + assert_no_match(/VT100/, $_) end - assert(tmp.eof? && !$bad) + assert(tmp.eof?) tmp.close - + sum=0 for i in 1..10 sum += i @@ -54,20 +54,17 @@ class TestWhileuntil < Test::Unit::TestCase redo end end - assert_equal(sum, 220) - - $bad = false + assert_equal(220, sum) + tmp = open("while_tmp", "r") while line = tmp.gets() break if 3 - case line - when /vt100/, /Amiga/, /paper/ - $bad = true - end + assert_no_match(/vt100/, line) + assert_no_match(/Amiga/, line) + assert_no_match(/paper/, line) end - assert(!$bad) tmp.close - + File.unlink "while_tmp" or `/bin/rm -f "while_tmp"` assert(!File.exist?("while_tmp")) end -- cgit v1.2.3