#!./perl
print "1..55\n";
$x = 'x';
print "#1 :$x: eq :x:\n";
$x = $#; # this is the register $#
$x = $#x;
$x = '\\'; # ';
eval 'while (0) {
print "foo\n";
}
/^/ && (print "ok 5\n");
';
eval '$foo{1} / 1;';
if (!$@) {print "ok 6\n";} else {print "not ok 6 $@\n";}
eval '$foo = 123+123.4+123e4+123.4E5+123.4e+5+.12;';
print <<'EOF';
ok 8
$foo = 'ok 9';
print <<EOF;
$foo
EOF
eval <<\EOE, print $@;
print <<'EOF';
ok 10
$foo = 'ok 11';
print <<EOF;
$foo
EOF
print <<'EOS' . <<\EOF;
ok 13
print qq
[ok 16\n]
;
print q<ok 17
>;
print <<; # Yow!
ok 18
# previous line intentionally left blank.
print <<E1 eq "foo\n\n" ? "ok 19\n" : "not ok 19\n";
@{[ <<E2 ]}
foo
E2
E1
print <<E1 eq "foo\n\n" ? "ok 20\n" : "not ok 20\n";
@{[
<<E2
foo
E2
]}
E1
# MJD 19980425
print "d" =~ /^$X[-1]$/ ? "ok 27\n" : "not ok 27\n";
print "a1" !~ /^$X[-1]$/ ? "ok 28\n" : "not ok 28\n";
$foo = "not ok 30\n";
Ignored
EOF
print $foo;
# Tests for new extended control-character variables
# MJD 19990227
$ {$CX} = 17;
$ {$CXY} = 23;
print "ok 31\n";
# Does the syntax where we use the literal control character still work?
print "ok 32\n";
eval "\$\cQ = 24"; # Literal control character
print "ok 33\n";
if ($^Q != 24) { print "not " } # Control character escape sequence
print "ok 34\n";
# Does the old UNBRACED syntax still do what it used to?
print "ok 35\n";
$ {"\cQ\cXX"} = 119;
$^Q = 5; # This should be an unused ^Var.
$N = 5;
# The second caret here should be interpreted as an xor
print "ok 36\n";
# if (($N ^ XX()) != 3) { print "not " }
# print "ok 32\n";
# These next two tests are trying to make sure that
# $^FOO is always global; it doesn't make sense to `my' it.
#
eval 'my $^X;';
print "ok 37\n";
# print "($@)\n" if $@;
eval 'my $ {^XYZ};';
print "ok 38\n";
# print "($@)\n" if $@;
# Now let's make sure that caret variables are all forced into the main package.
$^Q = 'Someother';
$ {^M} = 'Someother 3';
print "ok 39\n";
print "ok 40\n";
print "ok 41\n";
}
# see if eval '', s///e, and heredocs mix
sub T {
}
my $test = 42;
{
# line 42 "plink"
local $_ = "not ok ";
eval q{
s/^not /<<EOT/e and T '^main:\(eval \d+\):2$', $test++;
# fuggedaboudit
EOT
# line 1 "plunk"
};
}
# tests 47--51 start here
# tests for new array interpolation semantics:
# arrays now *always* interpolate into "..." strings.
# 20000522 MJD (mjd@plover.com)
{
my $test = 47;
++$test;
# Look at this! This is going to be a common error in the future:
++$test;
# Let's make sure that normal array interpolation still works right
# For some reason, this appears not to be tested anywhere else.
my @a = (1,2,3);
++$test;
# Ditto.
|| print "# $@", "not ";
++$test;
# This isn't actually a lex test, but it's testing the same feature
sub makearray {
}
|| print "# $@", "not ";
++$test;
}
# Tests 52-54
# => should only quote foo::bar if it isn't a real sub. AMS, 20010621
my %str = (
foo => 1,
);
my $test = 52;