Commit | Line | Data |
---|---|---|
8d063cd8 LW |
1 | #!./perl |
2 | ||
378cc40b LW |
3 | # $Header: op.pat,v 2.0 88/06/05 00:14:20 root Exp $ |
4 | ||
5 | print "1..30\n"; | |
8d063cd8 LW |
6 | |
7 | $x = "abc\ndef\n"; | |
8 | ||
9 | if ($x =~ /^abc/) {print "ok 1\n";} else {print "not ok 1\n";} | |
10 | if ($x !~ /^def/) {print "ok 2\n";} else {print "not ok 2\n";} | |
11 | ||
12 | $* = 1; | |
13 | if ($x =~ /^def/) {print "ok 3\n";} else {print "not ok 3\n";} | |
14 | $* = 0; | |
15 | ||
16 | $_ = '123'; | |
17 | if (/^([0-9][0-9]*)/) {print "ok 4\n";} else {print "not ok 4\n";} | |
18 | ||
19 | if ($x =~ /^xxx/) {print "not ok 5\n";} else {print "ok 5\n";} | |
20 | if ($x !~ /^abc/) {print "not ok 6\n";} else {print "ok 6\n";} | |
21 | ||
22 | if ($x =~ /def/) {print "ok 7\n";} else {print "not ok 7\n";} | |
23 | if ($x !~ /def/) {print "not ok 8\n";} else {print "ok 8\n";} | |
24 | ||
25 | if ($x !~ /.def/) {print "ok 9\n";} else {print "not ok 9\n";} | |
26 | if ($x =~ /.def/) {print "not ok 10\n";} else {print "ok 10\n";} | |
27 | ||
28 | if ($x =~ /\ndef/) {print "ok 11\n";} else {print "not ok 11\n";} | |
29 | if ($x !~ /\ndef/) {print "not ok 12\n";} else {print "ok 12\n";} | |
30 | ||
31 | $_ = 'aaabbbccc'; | |
32 | if (/(a*b*)(c*)/ && $1 eq 'aaabbb' && $2 eq 'ccc') { | |
33 | print "ok 13\n"; | |
34 | } else { | |
35 | print "not ok 13\n"; | |
36 | } | |
37 | if (/(a+b+c+)/ && $1 eq 'aaabbbccc') { | |
38 | print "ok 14\n"; | |
39 | } else { | |
40 | print "not ok 14\n"; | |
41 | } | |
42 | ||
43 | if (/a+b?c+/) {print "not ok 15\n";} else {print "ok 15\n";} | |
44 | ||
45 | $_ = 'aaabccc'; | |
46 | if (/a+b?c+/) {print "ok 16\n";} else {print "not ok 16\n";} | |
47 | if (/a*b+c*/) {print "ok 17\n";} else {print "not ok 17\n";} | |
48 | ||
49 | $_ = 'aaaccc'; | |
50 | if (/a*b?c*/) {print "ok 18\n";} else {print "not ok 18\n";} | |
51 | if (/a*b+c*/) {print "not ok 19\n";} else {print "ok 19\n";} | |
52 | ||
53 | $_ = 'abcdef'; | |
54 | if (/bcd|xyz/) {print "ok 20\n";} else {print "not ok 20\n";} | |
55 | if (/xyz|bcd/) {print "ok 21\n";} else {print "not ok 21\n";} | |
56 | ||
57 | if (m|bc/*d|) {print "ok 22\n";} else {print "not ok 22\n";} | |
378cc40b LW |
58 | |
59 | if (/^$_$/) {print "ok 23\n";} else {print "not ok 23\n";} | |
60 | ||
61 | $* = 1; # test 3 only tested the optimized version--this one is for real | |
62 | if ("ab\ncd\n" =~ /^cd/) {print "ok 24\n";} else {print "not ok 24\n";} | |
63 | $* = 0; | |
64 | ||
65 | $XXX{123} = 123; | |
66 | $XXX{234} = 234; | |
67 | $XXX{345} = 345; | |
68 | ||
69 | @XXX = ('ok 25','not ok 25', 'ok 26','not ok 26','not ok 27'); | |
70 | while ($_ = shift(XXX)) { | |
71 | ?(.*)? && (print $1,"\n"); | |
72 | /not/ && reset; | |
73 | /not ok 26/ && reset 'X'; | |
74 | } | |
75 | ||
76 | while (($key,$val) = each(XXX)) { | |
77 | print "not ok 27\n"; | |
78 | exit; | |
79 | } | |
80 | ||
81 | print "ok 27\n"; | |
82 | ||
83 | 'cde' =~ /[^ab]*/; | |
84 | 'xyz' =~ //; | |
85 | if ($& eq 'xyz') {print "ok 28\n";} else {print "not ok 28\n";} | |
86 | ||
87 | $foo = '[^ab]*'; | |
88 | 'cde' =~ /$foo/; | |
89 | 'xyz' =~ //; | |
90 | if ($& eq 'xyz') {print "ok 29\n";} else {print "not ok 29\n";} | |
91 | ||
92 | $foo = '[^ab]*'; | |
93 | 'cde' =~ /$foo/; | |
94 | 'xyz' =~ /$null/; | |
95 | if ($& eq 'xyz') {print "ok 30\n";} else {print "not ok 30\n";} |