attrs.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!./perl
# Regression tests for attrs.pm and the C<sub x : attrs> syntax.
BEGIN {
chdir 't' if -d 't';
print "1..0\n";
exit 0;
}
}
sub NTESTS () ;
$test=0;
my $failed = 0;
eval 'sub t1 ($) { use attrs "locked"; $_[0]++ }';
eval 'sub t2 { use attrs "locked"; $_[0]++ }';
eval 'sub t3 ($) : locked ;';
eval 'sub t4 : locked ;';
my $anon1;
eval '$anon1 = sub ($) { use attrs qw(locked method); $_[0]++ }';
my $anon2;
eval '$anon2 = sub { use attrs qw(locked method); $_[0]++ }';
my $anon3;
eval '$anon3 = sub { use attrs "method"; $_[0]->[1] }';
eval 'sub e1 ($) : plugh ;';
my $x = $@;
$x =~ s/\n.*\z//s;
print "# $x\n";
print "not ";
$failed = 1;
}
print "ok ",++$test,"\n";
BEGIN {++$ntests}
my $x = $@;
$x =~ s/\n.*\z//s;
print "# $x\n";
print "not ";
$failed = 1;
}
eval 'sub e3 ($) : plugh(0,0 xyzzy ;';
my $x = $@;
$x =~ s/\n.*\z//s;
print "# $x\n";
print "not ";
$failed = 1;
}
eval 'sub e4 ($) : plugh + xyzzy ;';
my $x = $@;
$x =~ s/\n.*\z//s;
print "# $x\n";
print "not ";
$failed = 1;
}
{
my $w = "" ;
eval 'sub w1 ($) { use warnings "deprecated"; use attrs "locked"; $_[0]++ }';
}
# Other tests should be added above this line
exit $failed;