Commit | Line | Data |
378cc40b |
1 | #!./perl |
2 | |
79072805 |
3 | # $RCSfile: regexp.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:20 $ |
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"; |
1462b684 |
14 | $| = 1; |
378cc40b |
15 | while (<TESTS>) { |
16 | ($pat, $subject, $result, $repl, $expect) = split(/[\t\n]/,$_); |
17 | $input = join(':',$pat,$subject,$result,$repl,$expect); |
1462b684 |
18 | $pat = "'$pat'" unless $pat =~ /^'/; |
19 | eval "\$match = (\$subject =~ m$pat); \$got = \"$repl\";"; |
378cc40b |
20 | if ($result eq 'c') { |
21 | if ($@ ne '') {print "ok $.\n";} else {print "not ok $.\n";} |
22 | } |
23 | elsif ($result eq 'n') { |
24 | if (!$match) {print "ok $.\n";} else {print "not ok $. $input => $got\n";} |
25 | } |
26 | else { |
27 | if ($match && $got eq $expect) { |
28 | print "ok $.\n"; |
29 | } |
30 | else { |
31 | print "not ok $. $input => $got\n"; |
32 | } |
33 | } |
34 | } |
35 | close(TESTS); |