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