Commit | Line | Data |
---|---|---|
cd16c24c IZ |
1 | #!./perl |
2 | ||
80b774e4 | 3 | use strict; |
14735530 | 4 | use Test::More tests => 10; |
cd16c24c IZ |
5 | |
6 | my $v_plus = $] + 1; | |
7 | my $v_minus = $] - 1; | |
8 | ||
2f761939 NC |
9 | unless (eval 'use open ":std"; 1') { |
10 | # pretend that open.pm is present | |
11 | $INC{'open.pm'} = 'open.pm'; | |
12 | eval 'sub open::foo{}'; # Just in case... | |
13 | } | |
14 | ||
80b774e4 | 15 | no strict; |
cd16c24c | 16 | |
80b774e4 | 17 | is( eval "use if ($v_minus > \$]), strict => 'subs'; \${'f'} = 12", 12, |
cd16c24c | 18 | '"use if" with a false condition, fake pragma'); |
80b774e4 | 19 | is( eval "use if ($v_minus > \$]), strict => 'refs'; \${'f'} = 12", 12, |
cd16c24c IZ |
20 | '"use if" with a false condition and a pragma'); |
21 | ||
80b774e4 | 22 | is( eval "use if ($v_plus > \$]), strict => 'subs'; \${'f'} = 12", 12, |
cd16c24c IZ |
23 | '"use if" with a true condition, fake pragma'); |
24 | ||
80b774e4 | 25 | is( eval "use if ($v_plus > \$]), strict => 'refs'; \${'f'} = 12", undef, |
cd16c24c | 26 | '"use if" with a true condition and a pragma'); |
80b774e4 | 27 | like( $@, qr/while "strict refs" in use/, 'expected error message'), |
cd16c24c | 28 | |
882ce583 | 29 | # Old version had problems with the module name 'open', which is a keyword too |
2f761939 | 30 | # Use 'open' =>, since pre-5.6.0 could interpret differently |
80b774e4 | 31 | is( (eval "use if ($v_plus > \$]), 'open' => IN => ':crlf'; 12" || 0), 12, |
2f761939 | 32 | '"use if" with open'); |
14735530 KW |
33 | |
34 | is(eval "use if ($v_plus > \$])", undef, | |
35 | "Too few args to 'use if' returns <undef>"); | |
36 | like($@, qr/Too few arguments to 'use if'/, " ... and returns correct error"); | |
37 | ||
38 | is(eval "no if ($v_plus > \$])", undef, | |
39 | "Too few args to 'no if' returns <undef>"); | |
40 | like($@, qr/Too few arguments to 'no if'/, " ... and returns correct error"); |