summaryrefslogtreecommitdiff
path: root/test/ruby/test_whileuntil.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-05 15:15:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-05 15:15:43 +0000
commit44785befeabd09d5d34f33b33783c0ec54f06a1f (patch)
tree56830470411bdaf525d1f4c489b120125efb9097 /test/ruby/test_whileuntil.rb
parent01e3a55648559ba3d54cdf72d5c55f71a41e69e9 (diff)
* 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
Diffstat (limited to 'test/ruby/test_whileuntil.rb')
-rw-r--r--test/ruby/test_whileuntil.rb41
1 files changed, 19 insertions, 22 deletions
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