This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove whitespace from ends of lines (simply because it irritates me)
[perl5.git] / lib / if.t
CommitLineData
cd16c24c
IZ
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
b9761643 8use Test::More tests => 6;
cd16c24c
IZ
9
10my $v_plus = $] + 1;
11my $v_minus = $] - 1;
12
13
14ok( eval "use if ($v_minus > \$]), strict => 'subs'; \${'f'} = 12" eq 12,
15 '"use if" with a false condition, fake pragma');
16
17ok( eval "use if ($v_minus > \$]), strict => 'refs'; \${'f'} = 12" eq 12,
18 '"use if" with a false condition and a pragma');
19
20ok( eval "use if ($v_plus > \$]), strict => 'subs'; \${'f'} = 12" eq 12,
21 '"use if" with a true condition, fake pragma');
22
23ok( (not defined eval "use if ($v_plus > \$]), strict => 'refs'; \${'f'} = 12"
24 and $@ =~ /while "strict refs" in use/),
25 '"use if" with a true condition and a pragma');
26
66d45871
S
27ok( eval "use if 1, Cwd; cwd() || 1;",
28 '"use if" with a true condition, module, no arguments, exports');
29
b9761643
AT
30ok( eval "use if qw/ 1 if 1 strict subs /; \${'f'} = 12" eq 12,
31 '"use if" with a module named after keyword');