7 print "#1 :$x: eq :x:\n";
8 if ($x eq 'x') {print "ok 1\n";} else {print "not ok 1\n";}
12 if ($x eq '') {print "ok 2\n";} else {print "not ok 2\n";}
16 if ($x eq '-1') {print "ok 3\n";} else {print "not ok 3\n";}
20 if (length($x) == 1) {print "ok 4\n";} else {print "not ok 4\n";}
25 /^/ && (print "ok 5\n");
29 if (!$@) {print "ok 6\n";} else {print "not ok 6 $@\n";}
31 eval '$foo = 123+123.4+123e4+123.4E5+123.4e+5+.12;';
33 $foo = int($foo * 100 + .5);
34 if ($foo eq 2591024652) {print "ok 7\n";} else {print "not ok 7 :$foo:\n";}
45 eval <<\EOE, print $@;
56 print <<'EOS' . <<\EOF;
57 ok 12 - make sure single quotes are honored \nnot ok
72 print "ok 18 - was the test for the deprecated use of bare << to mean <<\"\"\n";
76 ## previous line intentionally left blank.
78 print <<E1 eq "foo\n\n" ? "ok 19\n" : "not ok 19\n";
84 print <<E1 eq "foo\n\n" ? "ok 20\n" : "not ok 20\n";
97 print "$foo{$bar}" eq "BAZ" ? "ok 21\n" : "not ok 21\n";
99 print "${foo}{$bar}" eq "FOO{BAR}" ? "ok 22\n" : "not ok 22\n";
100 print "${foo{$bar}}" eq "BAZ" ? "ok 23\n" : "not ok 23\n";
102 print "FOO:" =~ /$foo[:]/ ? "ok 24\n" : "not ok 24\n";
103 print "ABC" =~ /^$ary[$A]$/ ? "ok 25\n" : "not ok 25\n";
104 print "FOOZ" =~ /^$foo[$A-Z]$/ ? "ok 26\n" : "not ok 26\n";
107 ($X, @X) = qw(a b c d);
108 print "d" =~ /^$X[-1]$/ ? "ok 27\n" : "not ok 27\n";
109 print "a1" !~ /^$X[-1]$/ ? "ok 28\n" : "not ok 28\n";
111 print (((q{{\{\(}} . q{{\)\}}}) eq '{{\(}{\)}}') ? "ok 29\n" : "not ok 29\n");
114 $foo = "not ok 30\n";
115 $foo =~ s/^not /substr(<<EOF, 0, 0)/e;
120 # Tests for new extended control-character variables
127 if ($ {^XY} != 23) { print "not " }
130 # Does the syntax where we use the literal control character still work?
131 if (eval "\$ {\cX}" != 17 or $@) { print "not " }
134 eval "\$\cQ = 24"; # Literal control character
135 if ($@ or ${"\cQ"} != 24) { print "not " }
137 if ($^Q != 24) { print "not " } # Control character escape sequence
140 # Does the old UNBRACED syntax still do what it used to?
141 if ("$^XY" ne "17Y") { print "not " }
146 $^Q = 5; # This should be an unused ^Var.
148 # The second caret here should be interpreted as an xor
149 if (($^Q^XX) != 3) { print "not " }
151 # if (($N ^ XX()) != 3) { print "not " }
154 # These next two tests are trying to make sure that
155 # $^FOO is always global; it doesn't make sense to `my' it.
159 print "not " unless index ($@, 'Can\'t use global $^X in "my"') > -1;
161 # print "($@)\n" if $@;
164 print "not " unless index ($@, 'Can\'t use global $^XYZ in "my"') > -1;
166 # print "($@)\n" if $@;
168 # Now let's make sure that caret variables are all forced into the main package.
171 $ {^Quixote} = 'Someother 2';
172 $ {^M} = 'Someother 3';
174 print "not " unless $^Q eq 'Someother';
176 print "not " unless $ {^Quixote} eq 'Someother 2';
178 print "not " unless $ {^M} eq 'Someother 3';
184 # see if eval '', s///e, and heredocs mix
187 my ($where, $num) = @_;
188 my ($p,$f,$l) = caller;
189 print "# $p:$f:$l vs /$where/\nnot " unless "$p:$f:$l" =~ /$where/;
197 local $_ = "not ok ";
199 s/^not /<<EOT/e and T '^main:\(eval \d+\):2$', $test++;
202 print $_, $test++, "\n";
203 T('^main:\(eval \d+\):6$', $test++);
205 T('^main:plunk:1$', $test++);
207 print "# $@\nnot ok $test\n" if $@;
208 T '^main:plink:53$', $test++;
211 # tests 47--51 start here
212 # tests for new array interpolation semantics:
213 # arrays now *always* interpolate into "..." strings.
214 # 20000522 MJD (mjd@plover.com)
217 eval(q(">@nosuch<" eq "><")) || print "# $@", "not ";
221 # Look at this! This is going to be a common error in the future:
222 eval(q("fred@example.com" eq "fred.com")) || print "# $@", "not ";
226 # Let's make sure that normal array interpolation still works right
227 # For some reason, this appears not to be tested anywhere else.
229 print +((">@a<" eq ">1 2 3<") ? '' : 'not '), "ok $test\n";
233 eval(q{@nosuch = ('a', 'b', 'c'); ">@nosuch<" eq ">a b c<"})
234 || print "# $@", "not ";
238 # This isn't actually a lex test, but it's testing the same feature
240 my @array = ('fish', 'dog', 'carrot');
241 *R::crackers = \@array;
244 eval(q{makearray(); ">@R::crackers<" eq ">fish dog carrot<"})
245 || print "# $@", "not ";
251 # => should only quote foo::bar if it isn't a real sub. AMS, 20010621
253 sub xyz::foo { "bar" }
261 print ((exists $str{foo} ? "" : "not ")."ok $test\n"); ++$test;
262 print ((exists $str{bar} ? "" : "not ")."ok $test\n"); ++$test;
263 print ((exists $str{xyz::bar} ? "" : "not ")."ok $test\n"); ++$test;
265 sub foo::::::bar { print "ok $test\n"; $test++ }
269 if ($@ =~ /Unrecognized character \\xE2; marked by <-- HERE after \$x =<-- HERE near column 5/) { print "ok $test\n"; } else { print "not ok $test\n"; }
272 # Is "[~" scanned correctly?
274 print "not " unless($a[~~2] == 3);