summaryrefslogtreecommitdiff
path: root/sample/test.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-12-28 05:00:47 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-12-28 05:00:47 +0000
commit08ec02b92b45464df3dbf79022bb15b853ab0428 (patch)
tree571574af57859810d146f28177c240f1fe04e4f7 /sample/test.rb
parentceec42bf8c4e350d02d11b84adf9b8ebf7b4af47 (diff)
changes from personal modifies -- matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/test.rb')
-rw-r--r--sample/test.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/sample/test.rb b/sample/test.rb
index 2aa598f..3d8ce72 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -116,21 +116,21 @@ tmp.close
tmp = open("while_tmp", "r")
test_ok(tmp.kind_of?(File))
-while tmp.gets()
- break if /vt100/
+while line = tmp.gets()
+ break if /vt100/ =~ line
end
-test_ok(!tmp.eof? && /vt100/)
+test_ok(!tmp.eof? && /vt100/ =~ line)
tmp.close
# test next
$bad = false
tmp = open("while_tmp", "r")
-while tmp.gets()
- next if /vt100/;
- $bad = 1 if /vt100/;
+while line = tmp.gets()
+ next if /vt100/ =~ line
+ $bad = 1 if /vt100/ =~ line
end
-test_ok(!(!tmp.eof? || /vt100/ || $bad))
+test_ok(!(!tmp.eof? || /vt100/ =~ line || $bad))
tmp.close
# test redo
@@ -138,13 +138,13 @@ $bad = false
tmp = open("while_tmp", "r")
while tmp.gets()
line = $_
- $_ = gsub(/vt100/, 'VT100')
+ gsub(/vt100/, 'VT100')
if $_ != line
- gsub!('VT100', 'Vt100')
- redo;
+ $_.gsub!('VT100', 'Vt100')
+ redo
end
- $bad = 1 if /vt100/
- $bad = 1 if /VT100/
+ $bad = 1 if /vt100/ =~ $_
+ $bad = 1 if /VT100/ =~ $_
end
test_ok(tmp.eof? && !$bad)
tmp.close
@@ -162,11 +162,11 @@ test_ok(sum == 220)
# test interval
$bad = false
tmp = open("while_tmp", "r")
-while tmp.gets()
- break unless 1..2
- if /vt100/ || /Amiga/ || /paper/
+while line = tmp.gets()
+ break if 3
+ case line
+ when /vt100/, /Amiga/, /paper/
$bad = true
- break
end
end
test_ok(!$bad)