Commit | Line | Data |
---|---|---|
8d063cd8 LW |
1 | #!./perl |
2 | ||
79072805 | 3 | # $RCSfile: lex.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:04 $ |
8d063cd8 | 4 | |
f27ffc4a | 5 | print "1..30\n"; |
8d063cd8 | 6 | |
79072805 | 7 | $x = 'x'; |
8d063cd8 | 8 | |
79072805 LW |
9 | print "#1 :$x: eq :x:\n"; |
10 | if ($x eq 'x') {print "ok 1\n";} else {print "not ok 1\n";} | |
8d063cd8 LW |
11 | |
12 | $x = $#; # this is the register $# | |
13 | ||
14 | if ($x eq '') {print "ok 2\n";} else {print "not ok 2\n";} | |
15 | ||
16 | $x = $#x; | |
17 | ||
18 | if ($x eq '-1') {print "ok 3\n";} else {print "not ok 3\n";} | |
19 | ||
20 | $x = '\\'; # '; | |
21 | ||
22 | if (length($x) == 1) {print "ok 4\n";} else {print "not ok 4\n";} | |
a559c259 LW |
23 | |
24 | eval 'while (0) { | |
25 | print "foo\n"; | |
26 | } | |
27 | /^/ && (print "ok 5\n"); | |
28 | '; | |
29 | ||
30 | eval '$foo{1} / 1;'; | |
79072805 | 31 | if (!$@) {print "ok 6\n";} else {print "not ok 6 $@\n";} |
378cc40b LW |
32 | |
33 | eval '$foo = 123+123.4+123e4+123.4E5+123.4e+5+.12;'; | |
34 | ||
35 | $foo = int($foo * 100 + .5); | |
87250799 | 36 | if ($foo eq 2591024652) {print "ok 7\n";} else {print "not ok 7 :$foo:\n";} |
a687059c LW |
37 | |
38 | print <<'EOF'; | |
39 | ok 8 | |
40 | EOF | |
41 | ||
42 | $foo = 'ok 9'; | |
43 | print <<EOF; | |
44 | $foo | |
45 | EOF | |
46 | ||
47 | eval <<\EOE, print $@; | |
48 | print <<'EOF'; | |
49 | ok 10 | |
50 | EOF | |
51 | ||
52 | $foo = 'ok 11'; | |
53 | print <<EOF; | |
54 | $foo | |
55 | EOF | |
56 | EOE | |
57 | ||
58 | print <<`EOS` . <<\EOF; | |
59 | echo ok 12 | |
60 | EOS | |
61 | ok 13 | |
62 | EOF | |
63 | ||
64 | print qq/ok 14\n/; | |
65 | print qq(ok 15\n); | |
66 | ||
67 | print qq | |
a0d0e21e | 68 | [ok 16\n] |
a687059c LW |
69 | ; |
70 | ||
71 | print q<ok 17 | |
72 | >; | |
73 | ||
74 | print <<; # Yow! | |
75 | ok 18 | |
76 | ||
77 | # previous line intentionally left blank. | |
79072805 | 78 | |
2ba53c57 HS |
79 | print <<E1 eq "foo\n\n" ? "ok 19\n" : "not ok 19\n"; |
80 | @{[ <<E2 ]} | |
81 | foo | |
82 | E2 | |
83 | E1 | |
84 | ||
85 | print <<E1 eq "foo\n\n" ? "ok 20\n" : "not ok 20\n"; | |
86 | @{[ | |
87 | <<E2 | |
88 | foo | |
89 | E2 | |
90 | ]} | |
91 | E1 | |
92 | ||
79072805 LW |
93 | $foo = FOO; |
94 | $bar = BAR; | |
95 | $foo{$bar} = BAZ; | |
96 | $ary[0] = ABC; | |
97 | ||
2ba53c57 | 98 | print "$foo{$bar}" eq "BAZ" ? "ok 21\n" : "not ok 21\n"; |
79072805 | 99 | |
2ba53c57 HS |
100 | print "${foo}{$bar}" eq "FOO{BAR}" ? "ok 22\n" : "not ok 22\n"; |
101 | print "${foo{$bar}}" eq "BAZ" ? "ok 23\n" : "not ok 23\n"; | |
79072805 | 102 | |
2ba53c57 HS |
103 | print "FOO:" =~ /$foo[:]/ ? "ok 24\n" : "not ok 24\n"; |
104 | print "ABC" =~ /^$ary[$A]$/ ? "ok 25\n" : "not ok 25\n"; | |
105 | print "FOOZ" =~ /^$foo[$A-Z]$/ ? "ok 26\n" : "not ok 26\n"; | |
1bcde0ca | 106 | |
f27ffc4a GS |
107 | # MJD 19980425 |
108 | ($X, @X) = qw(a b c d); | |
109 | print "d" =~ /^$X[-1]$/ ? "ok 27\n" : "not ok 27\n"; | |
110 | print "a1" !~ /^$X[-1]$/ ? "ok 28\n" : "not ok 28\n"; | |
a2c06652 | 111 | |
f27ffc4a GS |
112 | print (((q{{\{\(}} . q{{\)\}}}) eq '{{\(}{\)}}') ? "ok 29\n" : "not ok 29\n"); |
113 | ||
114 | ||
115 | $foo = "not ok 30\n"; | |
a2c06652 HS |
116 | $foo =~ s/^not /substr(<<EOF, 0, 0)/e; |
117 | Ignored | |
118 | EOF | |
119 | print $foo; |