diff options
Diffstat (limited to 'gnu/usr.bin/perl/t/op/regexp.t')
-rw-r--r-- | gnu/usr.bin/perl/t/op/regexp.t | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/t/op/regexp.t b/gnu/usr.bin/perl/t/op/regexp.t new file mode 100644 index 00000000000..c37293517c6 --- /dev/null +++ b/gnu/usr.bin/perl/t/op/regexp.t @@ -0,0 +1,35 @@ +#!./perl + +# $RCSfile: regexp.t,v $$Revision: 1.1 $$Date: 1996/08/19 10:13:22 $ + +open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') + || die "Can't open re_tests"; +while (<TESTS>) { } +$numtests = $.; +close(TESTS); + +print "1..$numtests\n"; +open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') + || die "Can't open re_tests"; +$| = 1; +while (<TESTS>) { + ($pat, $subject, $result, $repl, $expect) = split(/[\t\n]/,$_); + $input = join(':',$pat,$subject,$result,$repl,$expect); + $pat = "'$pat'" unless $pat =~ /^'/; + eval "\$match = (\$subject =~ m$pat); \$got = \"$repl\";"; + if ($result eq 'c') { + if ($@ ne '') {print "ok $.\n";} else {print "not ok $.\n";} + } + elsif ($result eq 'n') { + if (!$match) {print "ok $.\n";} else {print "not ok $. $input => $got\n";} + } + else { + if ($match && $got eq $expect) { + print "ok $.\n"; + } + else { + print "not ok $. $input => $got\n"; + } + } +} +close(TESTS); |