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