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