perl 4.0 patch 6: patch #4, continued
[p5sagit/p5-mst-13.2.git] / t / op / regexp.t
1 #!./perl
2
3 # $Header: regexp.t,v 4.0 91/03/20 01:54:22 lwall Locked $
4
5 open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
6     || die "Can't open re_tests";
7 while (<TESTS>) { }
8 $numtests = $.;
9 close(TESTS);
10
11 print "1..$numtests\n";
12 open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
13     || die "Can't open re_tests";
14 while (<TESTS>) {
15     ($pat, $subject, $result, $repl, $expect) = split(/[\t\n]/,$_);
16     $input = join(':',$pat,$subject,$result,$repl,$expect);
17     eval "\$match = (\$subject =~ \$pat); \$got = \"$repl\";";
18     if ($result eq 'c') {
19         if ($@ ne '') {print "ok $.\n";} else {print "not ok $.\n";}
20     }
21     elsif ($result eq 'n') {
22         if (!$match) {print "ok $.\n";} else {print "not ok $. $input => $got\n";}
23     }
24     else {
25         if ($match && $got eq $expect) {
26             print "ok $.\n";
27         }
28         else {
29             print "not ok $. $input => $got\n";
30         }
31     }
32 }
33 close(TESTS);