perl 4.0.00: (no release announcement available)
[p5sagit/p5-mst-13.2.git] / t / op / regexp.t
CommitLineData
378cc40b 1#!./perl
2
fe14fcc3 3# $Header: regexp.t,v 4.0 91/03/20 01:54:22 lwall Locked $
378cc40b 4
fe14fcc3 5open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
6 || die "Can't open re_tests";
378cc40b 7while (<TESTS>) { }
8$numtests = $.;
9close(TESTS);
10
11print "1..$numtests\n";
fe14fcc3 12open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
13 || die "Can't open re_tests";
378cc40b 14while (<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}
33close(TESTS);