1#!./perl 2 3BEGIN { 4 chdir 't' and @INC = '../lib' if -f 't/TEST'; 5} 6 7my $t = 1; 8print "1..5\n"; 9sub ok { 10 print "not " unless shift; 11 print "ok $t # ", shift, "\n"; 12 $t++; 13} 14 15my $v_plus = $] + 1; 16my $v_minus = $] - 1; 17 18unless (eval 'use open ":std"; 1') { 19 # pretend that open.pm is present 20 $INC{'open.pm'} = 'open.pm'; 21 eval 'sub open::foo{}'; # Just in case... 22} 23 24 25ok( eval "use if ($v_minus > \$]), strict => 'subs'; \${'f'} = 12" eq 12, 26 '"use if" with a false condition, fake pragma'); 27 28ok( eval "use if ($v_minus > \$]), strict => 'refs'; \${'f'} = 12" eq 12, 29 '"use if" with a false condition and a pragma'); 30 31ok( eval "use if ($v_plus > \$]), strict => 'subs'; \${'f'} = 12" eq 12, 32 '"use if" with a true condition, fake pragma'); 33 34ok( (not defined eval "use if ($v_plus > \$]), strict => 'refs'; \${'f'} = 12" 35 and $@ =~ /while "strict refs" in use/), 36 '"use if" with a true condition and a pragma'); 37 38# Old version had problems with the module name `open', which is a keyword too 39# Use 'open' =>, since pre-5.6.0 could interpret differently 40ok( (eval "use if ($v_plus > \$]), 'open' => IN => ':crlf'; 12" || 0) eq 12, 41 '"use if" with open'); 42