summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorHans Mulder <hansm@euronet.nl>1997-06-11 12:00:00 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-06-11 12:00:00 +1200
commitad4f75a617e142cf0d567ad25c1dbd4439093580 (patch)
tree1ac1f8453f8cc0e308cd6737069e8da04ab3b825 /t
parenta3f082f97840ecb41646a9958f79771640cb9d41 (diff)
downloadperl-ad4f75a617e142cf0d567ad25c1dbd4439093580.tar.gz
More simple regexp tests and test docs
Diffstat (limited to 't')
-rw-r--r--t/op/re_tests3
-rwxr-xr-xt/op/regexp.t23
2 files changed, 25 insertions, 1 deletions
diff --git a/t/op/re_tests b/t/op/re_tests
index c20fb89e80..77d97e2aeb 100644
--- a/t/op/re_tests
+++ b/t/op/re_tests
@@ -301,3 +301,6 @@ a(?:b|c|d)*(.) ace y $1 e
a(?:b|c|d)+?(.) ace y $1 e
a(?:b|(c|e){1,2}?|d)+?(.) ace y $1$2 ce
^(.+)?B AB y $1 A
+'([a-z]+)\s\1'i Aa aa y $&-$1 Aa aa-Aa
+'([a-z]+)\s\1'i Ab ab y $&-$1 Ab ab-Ab
+foo\w*\d{4}baz foobar1234baz y $& foobar1234baz
diff --git a/t/op/regexp.t b/t/op/regexp.t
index c6969240fc..ea470f879b 100755
--- a/t/op/regexp.t
+++ b/t/op/regexp.t
@@ -1,5 +1,26 @@
#!./perl
+# The tests are in a separate file 't/op/re_tests'.
+# Each line in that file is a separate test.
+# There are five columns, separated by tabs.
+#
+# Column 1 contains the pattern, optionally enclosed in C<''>.
+# Modifiers can be put after the closing C<'>.
+#
+# Column 2 contains the string to be matched.
+#
+# Column 3 contains the expected result:
+# y expect a match
+# n expect no match
+# c expect an error
+#
+# Columns 4 and 5 are used only of column 3 contains C<y>.
+#
+# Column 4 contains a string, usually C<$&>.
+#
+# Column 5 contains the expected result of double-quote
+# interpolating that string after the match.
+
open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests')
|| die "Can't open re_tests";
@@ -15,7 +36,7 @@ while (<TESTS>) {
($pat, $subject, $result, $repl, $expect) = split(/[\t\n]/,$_);
$input = join(':',$pat,$subject,$result,$repl,$expect);
$pat = "'$pat'" unless $pat =~ /^'/;
- for $study ("", "study \$match") {
+ for $study ("", "study \$subject") {
eval "$study; \$match = (\$subject =~ m$pat); \$got = \"$repl\";";
if ($result eq 'c') {
if ($@ eq '') { print "not ok $.\n"; next TEST }