summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1991-06-06 23:28:07 +0000
committerLarry Wall <lwall@netlabs.com>1991-06-06 23:28:07 +0000
commit352d5a3ab0aab9889c59e847643d265e062cec0b (patch)
treee0189b7c762b8e87cf461b329640d6efdfab3520 /t
parent6e21c824d91ef0b4ae60b95b347e344e5bb4d38a (diff)
downloadperl-352d5a3ab0aab9889c59e847643d265e062cec0b.tar.gz
perl 4.0 patch 7: patch #4, continued
See patch #4.
Diffstat (limited to 't')
-rw-r--r--t/op/pat.t60
1 files changed, 58 insertions, 2 deletions
diff --git a/t/op/pat.t b/t/op/pat.t
index c770391dce..5223ef0be0 100644
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -1,8 +1,8 @@
#!./perl
-# $Header: pat.t,v 4.0 91/03/20 01:54:01 lwall Locked $
+# $RCSfile: pat.t,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:01:26 $
-print "1..43\n";
+print "1..48\n";
$x = "abc\ndef\n";
@@ -118,3 +118,59 @@ print /(y{2,3}.)/ ? "ok 40\n" : "not ok 40\n";
print $1 eq 'yyy ' ? "ok 41\n" : "not ok 41\n";
print /x {3,4}/ ? "not ok 42\n" : "ok 42\n";
print /^xxx {3,4}/ ? "not ok 43\n" : "ok 43\n";
+
+$_ = "now is the time for all good men to come to.";
+@words = /(\w+)/g;
+print join(':',@words) eq "now:is:the:time:for:all:good:men:to:come:to"
+ ? "ok 44\n"
+ : "not ok 44\n";
+
+@words = ();
+while (/\w+/g) {
+ push(@words, $&);
+}
+print join(':',@words) eq "now:is:the:time:for:all:good:men:to:come:to"
+ ? "ok 45\n"
+ : "not ok 45\n";
+
+@words = ();
+while (/to/g) {
+ push(@words, $&);
+}
+print join(':',@words) eq "to:to"
+ ? "ok 46\n"
+ : "not ok 46 @words\n";
+
+@words = /to/g;
+print join(':',@words) eq "to:to"
+ ? "ok 47\n"
+ : "not ok 47 @words\n";
+
+$_ = "abcdefghi";
+
+$pat1 = 'def';
+$pat2 = '^def';
+$pat3 = '.def.';
+$pat4 = 'abc';
+$pat5 = '^abc';
+$pat6 = 'abc$';
+$pat7 = 'ghi';
+$pat8 = '\w*ghi';
+$pat9 = 'ghi$';
+
+$t1=$t2=$t3=$t4=$t5=$t6=$t7=$t8=$t9=0;
+
+for $iter (1..5) {
+ $t1++ if /$pat1/o;
+ $t2++ if /$pat2/o;
+ $t3++ if /$pat3/o;
+ $t4++ if /$pat4/o;
+ $t5++ if /$pat5/o;
+ $t6++ if /$pat6/o;
+ $t7++ if /$pat7/o;
+ $t8++ if /$pat8/o;
+ $t9++ if /$pat9/o;
+}
+
+$x = "$t1$t2$t3$t4$t5$t6$t7$t8$t9";
+print $x eq '505550555' ? "ok 48\n" : "not ok 48 $x\n";