6 @INC = ('.', '../lib');
12 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
13 print "1..0 # Skip -- Perl configured without B module\n";
19 plan tests => 15; # adjust also number of skipped tests !
21 # Runs a separate perl interpreter with the appropriate lint options
24 my ($opts,$prog,$result,$testname) = @_;
26 switches => [ "-MO=Lint,$opts" ],
30 $res =~ s/-e syntax OK\n$//;
31 is( $res, $result, $testname || $opts );
34 runlint 'context', '$foo = @bar', <<'RESULT';
35 Implicit scalar context for array in scalar assignment at -e line 1
38 runlint 'context', '$foo = length @bar', <<'RESULT';
39 Implicit scalar context for array in length at -e line 1
42 runlint 'implicit-read', '/foo/', <<'RESULT';
43 Implicit match on $_ at -e line 1
46 runlint 'implicit-write', 's/foo/bar/', <<'RESULT';
47 Implicit substitution on $_ at -e line 1
53 skip("Doesn't work with threaded perls",11)
54 if $Config{useithreads} || ($] < 5.009 && $Config{use5005threads});
56 runlint 'implicit-read', '1 for @ARGV', <<'RESULT', 'implicit-read in foreach';
57 Implicit use of $_ in foreach at -e line 1
60 runlint 'dollar-underscore', '$_ = 1', <<'RESULT';
61 Use of $_ at -e line 1
64 runlint 'dollar-underscore', 'print', <<'RESULT', 'dollar-underscore in print';
65 Use of $_ at -e line 1
68 runlint 'private-names', 'sub A::_f{};A::_f()', <<'RESULT';
69 Illegal reference to private name _f at -e line 1
72 runlint 'private-names', '$A::_x', <<'RESULT';
73 Illegal reference to private name _x at -e line 1
76 runlint 'private-names', 'sub A::_f{};A->_f()', <<'RESULT',
77 Illegal reference to private method name _f at -e line 1
79 'private-names (method)';
81 runlint 'undefined-subs', 'foo()', <<'RESULT';
82 Undefined subroutine foo called at -e line 1
85 runlint 'regexp-variables', 'print $&', <<'RESULT';
86 Use of regexp variable $& at -e line 1
89 runlint 'regexp-variables', 's/./$&/', <<'RESULT';
90 Use of regexp variable $& at -e line 1
93 runlint 'bare-subs', 'sub bare(){1};$x=bare', '';
95 runlint 'bare-subs', 'sub bare(){1}; $x=[bare=>0]; $x=$y{bare}', <<'RESULT';
96 Bare sub name 'bare' interpreted as string at -e line 1
97 Bare sub name 'bare' interpreted as string at -e line 1