From 07bb9f21f56b0d066c44c62b0e6be35eb0e0fd51 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 13 Aug 1999 05:45:20 +0000 Subject: 1.4.0 git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sample/test.rb | 97 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 37 deletions(-) (limited to 'sample/test.rb') diff --git a/sample/test.rb b/sample/test.rb index f28327659..a849a42fc 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -183,7 +183,7 @@ ok(i>4) check "exception"; begin - fail "this must be handled" + raise "this must be handled" ok(false) rescue ok(true) @@ -191,7 +191,7 @@ end $bad = true begin - fail "this must be handled no.2" + raise "this must be handled no.2" rescue if $bad $bad = false @@ -205,9 +205,9 @@ ok(true) $string = "this must be handled no.3" begin begin - fail "exception in rescue clause" + raise "exception in rescue clause" rescue - fail $string + raise $string end ok(false) rescue @@ -217,9 +217,9 @@ end # exception in ensure clause begin begin - fail "this must be handled no.4" + raise "this must be handled no.4" ensure - fail "exception in ensure clause" + raise "exception in ensure clause" end ok(false) rescue @@ -229,7 +229,7 @@ end $bad = true begin begin - fail "this must be handled no.5" + raise "this must be handled no.5" ensure $bad = false end @@ -240,7 +240,7 @@ ok(!$bad) $bad = true begin begin - fail "this must be handled no.6" + raise "this must be handled no.6" ensure $bad = false end @@ -355,7 +355,7 @@ ok($x[1] == 2) ok(begin for k,v in $y - fail if k*2 != v + raise if k*2 != v end true rescue @@ -417,7 +417,7 @@ ok(i == 5) done = true loop{ break - done = false + done = false # should not reach here } ok(done) @@ -427,7 +427,7 @@ loop { break if done done = true next - $bad = true + $bad = true # should not reach here } ok(!$bad) @@ -437,7 +437,7 @@ loop { break if done done = true redo - $bad = true + $bad = true # should not reach here } ok(!$bad) @@ -599,14 +599,29 @@ ok(("abc" =~ /d*$/) == 3) ok("" =~ /^$/) ok("\n" =~ /^$/) ok("a\n\n" =~ /^$/) -"abcabc" =~ /.*a/ -ok($& == "abca") -"abcabc" =~ /.*c/ -ok($& == "abcabc") -"abcabc" =~ /.*?a/ -ok($& == "a") -"abcabc" =~ /.*?c/ -ok($& == "abc") +ok("abcabc" =~ /.*a/ && $& == "abca") +ok("abcabc" =~ /.*c/ && $& == "abcabc") +ok("abcabc" =~ /.*?a/ && $& == "a") +ok("abcabc" =~ /.*?c/ && $& == "abc") +ok(/(.|\n)*?\n(b|\n)/ =~ "a\nb\n\n" && $& == "a\nb") +$x = <