6 @INC = ('.', '../lib');
12 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
13 print "1..0 # Skip -- Perl configured without B module\n";
19 plan tests => 16; # 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
52 switches => [ "-MB::Lint" ],
53 prog => 'BEGIN{B::Lint->register_plugin(X=>[q[x]])};use O(qw[Lint x]);sub X::match{warn qq[X ok.\n]};dummy()',
56 like( $res, qr/X ok\./, 'Lint plugin' );
62 skip("Doesn't work with threaded perls",11)
63 if $Config{useithreads} || ($] < 5.009 && $Config{use5005threads});
65 runlint 'implicit-read', '1 for @ARGV', <<'RESULT', 'implicit-read in foreach';
66 Implicit use of $_ in foreach at -e line 1
69 runlint 'dollar-underscore', '$_ = 1', <<'RESULT';
70 Use of $_ at -e line 1
73 runlint 'dollar-underscore', 'print', <<'RESULT', 'dollar-underscore in print';
74 Use of $_ at -e line 1
77 runlint 'private-names', 'sub A::_f{};A::_f()', <<'RESULT';
78 Illegal reference to private name _f at -e line 1
81 runlint 'private-names', '$A::_x', <<'RESULT';
82 Illegal reference to private name _x at -e line 1
85 runlint 'private-names', 'sub A::_f{};A->_f()', <<'RESULT',
86 Illegal reference to private method name _f at -e line 1
88 'private-names (method)';
90 runlint 'undefined-subs', 'foo()', <<'RESULT';
91 Undefined subroutine foo called at -e line 1
94 runlint 'regexp-variables', 'print $&', <<'RESULT';
95 Use of regexp variable $& at -e line 1
98 runlint 'regexp-variables', 's/./$&/', <<'RESULT';
99 Use of regexp variable $& at -e line 1
102 runlint 'bare-subs', 'sub bare(){1};$x=bare', '';
104 runlint 'bare-subs', 'sub bare(){1}; $x=[bare=>0]; $x=$y{bare}', <<'RESULT';
105 Bare sub name 'bare' interpreted as string at -e line 1
106 Bare sub name 'bare' interpreted as string at -e line 1