1N/ACheck strict subs functionality
1N/A
1N/A__END__
1N/A
1N/A# no strict, should build & run ok.
1N/AFred ;
1N/Amy $fred ;
1N/A$b = "fred" ;
1N/A$a = $$b ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/Ause strict qw(refs vars);
1N/AFred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/Ause strict ;
1N/Ano strict 'subs' ;
1N/AFred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# strict subs - error
1N/Ause strict 'subs' ;
1N/Amy @a = (1..2);
1N/Amy $b = xyz;
1N/AEXPECT
1N/ABareword "xyz" not allowed while "strict subs" in use at - line 5.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# strict subs - error
1N/Ause strict 'subs' ;
1N/AFred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 4.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# strict subs - error
1N/Ause strict 'subs' ;
1N/Amy @a = (A..Z);
1N/AEXPECT
1N/ABareword "Z" not allowed while "strict subs" in use at - line 4.
1N/ABareword "A" not allowed while "strict subs" in use at - line 4.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# strict subs - error
1N/Ause strict 'subs' ;
1N/Amy $a = (B..Y);
1N/AEXPECT
1N/ABareword "Y" not allowed while "strict subs" in use at - line 4.
1N/ABareword "B" not allowed while "strict subs" in use at - line 4.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# strict subs - error
1N/Ause strict ;
1N/AFred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 4.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# strict subs - no error
1N/Ause strict 'subs' ;
1N/Asub Fred {}
1N/AFred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# Check compile time scope of strict subs pragma
1N/Ause strict 'subs' ;
1N/A{
1N/A no strict ;
1N/A my $a = Fred ;
1N/A}
1N/Amy $a = Fred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 8.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check compile time scope of strict subs pragma
1N/Ano strict;
1N/A{
1N/A use strict 'subs' ;
1N/A my $a = Fred ;
1N/A}
1N/Amy $a = Fred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 6.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check compile time scope of strict vars pragma
1N/Ause strict 'vars' ;
1N/A{
1N/A no strict ;
1N/A $joe = 1 ;
1N/A}
1N/A$joe = 1 ;
1N/AEXPECT
1N/AVariable "$joe" is not imported at - line 8.
1N/AGlobal symbol "$joe" requires explicit package name at - line 8.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check compile time scope of strict vars pragma
1N/Ano strict;
1N/A{
1N/A use strict 'vars' ;
1N/A $joe = 1 ;
1N/A}
1N/A$joe = 1 ;
1N/AEXPECT
1N/AGlobal symbol "$joe" requires explicit package name at - line 6.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check runtime scope of strict refs pragma
1N/Ause strict 'refs';
1N/Amy $fred ;
1N/Amy $b = "fred" ;
1N/A{
1N/A no strict ;
1N/A my $a = $$b ;
1N/A}
1N/Amy $a = $$b ;
1N/AEXPECT
1N/ACan't use string ("fred") as a SCALAR ref while "strict refs" in use at - line 10.
1N/A########
1N/A
1N/A# Check runtime scope of strict refs pragma
1N/Ano strict ;
1N/Amy $fred ;
1N/Amy $b = "fred" ;
1N/A{
1N/A use strict 'refs' ;
1N/A my $a = $$b ;
1N/A}
1N/Amy $a = $$b ;
1N/AEXPECT
1N/ACan't use string ("fred") as a SCALAR ref while "strict refs" in use at - line 8.
1N/A########
1N/A
1N/A# Check runtime scope of strict refs pragma
1N/Ano strict ;
1N/Amy $fred ;
1N/Amy $b = "fred" ;
1N/A{
1N/A use strict 'refs' ;
1N/A $a = sub { my $c = $$b ; }
1N/A}
1N/A&$a ;
1N/AEXPECT
1N/ACan't use string ("fred") as a SCALAR ref while "strict refs" in use at - line 8.
1N/A########
1N/A
1N/Ause strict 'subs' ;
1N/Amy $a = Fred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 3.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A--FILE-- abc
1N/Amy $a = Fred ;
1N/A1;
1N/A--FILE--
1N/Ause strict 'subs' ;
1N/Arequire "./abc";
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A--FILE-- abc
1N/Ause strict 'subs' ;
1N/A1;
1N/A--FILE--
1N/Arequire "./abc";
1N/Amy $a = Fred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A--FILE-- abc
1N/Ause strict 'subs' ;
1N/Amy $a = Fred ;
1N/A1;
1N/A--FILE--
1N/AFred ;
1N/Arequire "./abc";
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at ./abc line 2.
1N/ACompilation failed in require at - line 2.
1N/A########
1N/A
1N/A--FILE-- abc.pm
1N/Ause strict 'subs' ;
1N/Amy $a = Fred ;
1N/A1;
1N/A--FILE--
1N/AFred ;
1N/Ause abc;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at abc.pm line 2.
1N/ACompilation failed in require at - line 2.
1N/ABEGIN failed--compilation aborted at - line 2.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ano strict ;
1N/Aeval {
1N/A my $a = Fred ;
1N/A};
1N/Aprint STDERR $@;
1N/Amy $a = Fred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ano strict ;
1N/Aeval {
1N/A use strict 'subs' ;
1N/A my $a = Fred ;
1N/A};
1N/Aprint STDERR $@;
1N/Amy $a = Fred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 6.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ause strict 'subs' ;
1N/Aeval {
1N/A my $a = Fred ;
1N/A};
1N/Aprint STDERR $@;
1N/Amy $a = Fred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 5.
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 8.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ause strict 'subs' ;
1N/Aeval {
1N/A no strict ;
1N/A my $a = Fred ;
1N/A};
1N/Aprint STDERR $@;
1N/Amy $a = Fred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 9.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ano strict ;
1N/Aeval '
1N/A Fred ;
1N/A'; print STDERR $@ ;
1N/AFred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ano strict ;
1N/Aeval q[
1N/A use strict 'subs' ;
1N/A Fred ;
1N/A]; print STDERR $@;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at (eval 1) line 3.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ause strict 'subs' ;
1N/Aeval '
1N/A Fred ;
1N/A'; print STDERR $@ ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at (eval 1) line 2.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ause strict 'subs' ;
1N/Aeval '
1N/A no strict ;
1N/A my $a = Fred ;
1N/A'; print STDERR $@;
1N/Amy $a = Fred ;
1N/AEXPECT
1N/ABareword "Fred" not allowed while "strict subs" in use at - line 8.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# see if Foo->Bar(...) etc work under strictures
1N/Ause strict;
1N/Apackage Foo; sub Bar { print "@_\n" }
1N/AFoo->Bar('a',1);
1N/ABar Foo ('b',2);
1N/AFoo->Bar(qw/c 3/);
1N/ABar Foo (qw/d 4/);
1N/AFoo::->Bar('A',1);
1N/ABar Foo:: ('B',2);
1N/AFoo::->Bar(qw/C 3/);
1N/ABar Foo:: (qw/D 4/);
1N/AEXPECT
1N/AFoo a 1
1N/AFoo b 2
1N/AFoo c 3
1N/AFoo d 4
1N/AFoo A 1
1N/AFoo B 2
1N/AFoo C 3
1N/AFoo D 4
1N/A########
1N/A
1N/A# Check that barewords on the RHS of a regex match are caught
1N/Ause strict;
1N/A"" =~ foo;
1N/AEXPECT
1N/ABareword "foo" not allowed while "strict subs" in use at - line 4.
1N/AExecution of - aborted due to compilation errors.
1N/A
1N/A########
1N/A
1N/A# ID 20020703.002
1N/Ause strict;
1N/Ause warnings;
1N/Amy $abc = XYZ ? 1 : 0;
1N/Aprint "$abc\n";
1N/AEXPECT
1N/ABareword "XYZ" not allowed while "strict subs" in use at - line 5.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# [perl #10021]
1N/Ause strict;
1N/Ause warnings;
1N/Aprint "" if BAREWORD;
1N/AEXPECT
1N/ABareword "BAREWORD" not allowed while "strict subs" in use at - line 5.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A# Ticket: 18927
1N/Ause strict 'subs';
1N/Aprint 1..1, bad;
1N/AEXPECT
1N/ABareword "bad" not allowed while "strict subs" in use at - line 3.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A# [perl #25147]
1N/Ause strict;
1N/Aprint "" if BAREWORD;
1N/AEXPECT
1N/ABareword "BAREWORD" not allowed while "strict subs" in use at - line 3.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A# [perl #26910] hints not propagated into (?{...})
1N/Ause strict 'subs';
1N/Aqr/(?{my $x=foo})/;
1N/AEXPECT
1N/ABareword "foo" not allowed while "strict subs" in use at (re_eval 1) line 1.
1N/ACompilation failed in regexp at - line 3.
1N/A########
1N/A# [perl #27628] strict 'subs' didn't warn on bareword array index
1N/Ause strict 'subs';
1N/Amy $x=$a[FOO];
1N/AEXPECT
1N/ABareword "FOO" not allowed while "strict subs" in use at - line 3.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/Ause strict 'subs';
1N/Amy @a;my $x=$a[FOO];
1N/AEXPECT
1N/ABareword "FOO" not allowed while "strict subs" in use at - line 2.
1N/AExecution of - aborted due to compilation errors.