Commit | Line | Data |
378cc40b |
1 | #!./perl |
2 | |
fe14fcc3 |
3 | # $Header: regexp.t,v 4.0 91/03/20 01:54:22 lwall Locked $ |
378cc40b |
4 | |
fe14fcc3 |
5 | open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') |
6 | || die "Can't open re_tests"; |
378cc40b |
7 | while (<TESTS>) { } |
8 | $numtests = $.; |
9 | close(TESTS); |
10 | |
11 | print "1..$numtests\n"; |
fe14fcc3 |
12 | open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') |
13 | || die "Can't open re_tests"; |
378cc40b |
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); |