This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 2
[perl5.git] / t / op / regexp.t
1 #!./perl
2
3 # $RCSfile: regexp.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:20 $
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 $| = 1;
15 while (<TESTS>) {
16     ($pat, $subject, $result, $repl, $expect) = split(/[\t\n]/,$_);
17     $input = join(':',$pat,$subject,$result,$repl,$expect);
18     $pat = "'$pat'" unless $pat =~ /^'/;
19     eval "\$match = (\$subject =~ m$pat); \$got = \"$repl\";";
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);