11 # Runs a separate perl interpreter with the appropriate lint options
14 my ($opts,$prog,$result,$testname) = @_;
16 switches => [ "-MO=Lint,$opts" ],
20 $res =~ s/-e syntax OK\n$//;
21 is( $res, $result, $testname || $opts );
24 runlint 'context', '$foo = @bar', <<'RESULT';
25 Implicit scalar context for array in scalar assignment at -e line 1
28 runlint 'context', '$foo = length @bar', <<'RESULT';
29 Implicit scalar context for array in length at -e line 1
32 runlint 'implicit-read', '/foo/', <<'RESULT';
33 Implicit match on $_ at -e line 1
36 runlint 'implicit-write', 's/foo/bar/', <<'RESULT';
37 Implicit substitution on $_ at -e line 1
43 skip("Doesn't work with threaded perls",9)
44 if $Config{useithreads} || $Config{use5005threads};
46 runlint 'implicit-read', '1 for @ARGV', <<'RESULT', 'implicit-read in foreach';
47 Implicit use of $_ in foreach at -e line 1
50 runlint 'dollar-underscore', '$_ = 1', <<'RESULT';
51 Use of $_ at -e line 1
54 runlint 'dollar-underscore', 'print', <<'RESULT', 'dollar-underscore in print';
55 Use of $_ at -e line 1
58 runlint 'private-names', 'sub A::_f{};A::_f()', <<'RESULT';
59 Illegal reference to private name _f at -e line 1
62 runlint 'private-names', '$A::_x', <<'RESULT';
63 Illegal reference to private name _x at -e line 1
66 runlint 'private-names', 'sub A::_f{};A->_f()', <<'RESULT',
67 Illegal reference to private method name _f at -e line 1
69 'private-names (method)';
71 runlint 'undefined-subs', 'foo()', <<'RESULT';
72 Undefined subroutine foo called at -e line 1
75 runlint 'regexp-variables', 'print $&', <<'RESULT';
76 Use of regexp variable $& at -e line 1
79 runlint 'regexp-variables', 's/./$&/', <<'RESULT';
80 Use of regexp variable $& at -e line 1