Basic integrate of lastest perl into ansiperl
[p5sagit/p5-mst-13.2.git] / t / base / lex.t
1 #!./perl
2
3 # $RCSfile: lex.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:04 $
4
5 print "1..27\n";
6
7 $x = 'x';
8
9 print "#1       :$x: eq :x:\n";
10 if ($x eq 'x') {print "ok 1\n";} else {print "not ok 1\n";}
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";}
23
24 eval 'while (0) {
25     print "foo\n";
26 }
27 /^/ && (print "ok 5\n");
28 ';
29
30 eval '$foo{1} / 1;';
31 if (!$@) {print "ok 6\n";} else {print "not ok 6 $@\n";}
32
33 eval '$foo = 123+123.4+123e4+123.4E5+123.4e+5+.12;';
34
35 $foo = int($foo * 100 + .5);
36 if ($foo eq 2591024652) {print "ok 7\n";} else {print "not ok 7 :$foo:\n";}
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
68 [ok 16\n]
69 ;
70
71 print q<ok 17
72 >;
73
74 print <<;   # Yow!
75 ok 18
76
77 # previous line intentionally left blank.
78
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
93 $foo = FOO;
94 $bar = BAR;
95 $foo{$bar} = BAZ;
96 $ary[0] = ABC;
97
98 print "$foo{$bar}" eq "BAZ" ? "ok 21\n" : "not ok 21\n";
99
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";
102
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";
106
107 print (((q{{\{\(}} . q{{\)\}}}) eq '{{\(}{\)}}') ? "ok 27\n" : "not ok 27\n");