xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/if.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate}
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gateuse Test::More tests => 6;
9*0Sstevel@tonic-gate
10*0Sstevel@tonic-gatemy $v_plus = $] + 1;
11*0Sstevel@tonic-gatemy $v_minus = $] - 1;
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate
14*0Sstevel@tonic-gateok( eval "use if ($v_minus > \$]), strict => 'subs'; \${'f'} = 12" eq 12,
15*0Sstevel@tonic-gate    '"use if" with a false condition, fake pragma');
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gateok( eval "use if ($v_minus > \$]), strict => 'refs'; \${'f'} = 12" eq 12,
18*0Sstevel@tonic-gate    '"use if" with a false condition and a pragma');
19*0Sstevel@tonic-gate
20*0Sstevel@tonic-gateok( eval "use if ($v_plus > \$]), strict => 'subs'; \${'f'} = 12" eq 12,
21*0Sstevel@tonic-gate    '"use if" with a true condition, fake pragma');
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gateok( (not defined eval "use if ($v_plus > \$]), strict => 'refs'; \${'f'} = 12"
24*0Sstevel@tonic-gate     and $@ =~ /while "strict refs" in use/),
25*0Sstevel@tonic-gate    '"use if" with a true condition and a pragma');
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gateok( eval "use if 1, Cwd; cwd() || 1;",
28*0Sstevel@tonic-gate    '"use if" with a true condition, module, no arguments, exports');
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gateok( eval "use if qw/ 1 if 1 strict subs /; \${'f'} = 12" eq 12,
31*0Sstevel@tonic-gate    '"use if" with a module named after keyword');
32