7 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
8 print "1..0 # Skip -- Perl configured without B module\n";
14 plan tests => 15; # adjust also number of skipped tests !
16 # Runs a separate perl interpreter with the appropriate lint options
19 my ($opts,$prog,$result,$testname) = @_;
21 switches => [ "-MO=Lint,$opts" ],
25 $res =~ s/-e syntax OK\n$//;
26 is( $res, $result, $testname || $opts );
29 runlint 'context', '$foo = @bar', <<'RESULT';
30 Implicit scalar context for array in scalar assignment at -e line 1
33 runlint 'context', '$foo = length @bar', <<'RESULT';
34 Implicit scalar context for array in length at -e line 1
37 runlint 'implicit-read', '/foo/', <<'RESULT';
38 Implicit match on $_ at -e line 1
41 runlint 'implicit-write', 's/foo/bar/', <<'RESULT';
42 Implicit substitution on $_ at -e line 1
48 skip("Doesn't work with threaded perls",11)
49 if $Config{useithreads};
51 runlint 'implicit-read', '1 for @ARGV', <<'RESULT', 'implicit-read in foreach';
52 Implicit use of $_ in foreach at -e line 1
55 runlint 'dollar-underscore', '$_ = 1', <<'RESULT';
56 Use of $_ at -e line 1
59 runlint 'dollar-underscore', 'print', <<'RESULT', 'dollar-underscore in print';
60 Use of $_ at -e line 1
63 runlint 'private-names', 'sub A::_f{};A::_f()', <<'RESULT';
64 Illegal reference to private name _f at -e line 1
67 runlint 'private-names', '$A::_x', <<'RESULT';
68 Illegal reference to private name _x at -e line 1
71 runlint 'private-names', 'sub A::_f{};A->_f()', <<'RESULT',
72 Illegal reference to private method name _f at -e line 1
74 'private-names (method)';
76 runlint 'undefined-subs', 'foo()', <<'RESULT';
77 Undefined subroutine foo called at -e line 1
80 runlint 'regexp-variables', 'print $&', <<'RESULT';
81 Use of regexp variable $& at -e line 1
84 runlint 'regexp-variables', 's/./$&/', <<'RESULT';
85 Use of regexp variable $& at -e line 1
88 runlint 'bare-subs', 'sub bare(){1};$x=bare', '';
90 runlint 'bare-subs', 'sub bare(){1}; $x=[bare=>0]; $x=$y{bare}', <<'RESULT';
91 Bare sub name 'bare' interpreted as string at -e line 1
92 Bare sub name 'bare' interpreted as string at -e line 1