diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 2001-12-31 13:18:09 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-02-14 21:54:43 +0000 |
commit | cd16c24cb16bb0bd0fa486b8e98c39fcf6ebcf5c (patch) | |
tree | c1cf25ec1a758dd34b0038c6e11438b8254d0f5e /lib/if.t | |
parent | cef228671c8f137a38217c0c077e19066320c53f (diff) | |
download | perl-cd16c24cb16bb0bd0fa486b8e98c39fcf6ebcf5c.tar.gz |
conditional pragmas
Message-ID: <20011231181809.A29528@math.ohio-state.edu>
p4raw-id: //depot/perl@14694
Diffstat (limited to 'lib/if.t')
-rw-r--r-- | lib/if.t | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/if.t b/lib/if.t new file mode 100644 index 0000000000..12ad0b0c39 --- /dev/null +++ b/lib/if.t @@ -0,0 +1,26 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +use Test::More tests => 4; + +my $v_plus = $] + 1; +my $v_minus = $] - 1; + + +ok( eval "use if ($v_minus > \$]), strict => 'subs'; \${'f'} = 12" eq 12, + '"use if" with a false condition, fake pragma'); + +ok( eval "use if ($v_minus > \$]), strict => 'refs'; \${'f'} = 12" eq 12, + '"use if" with a false condition and a pragma'); + +ok( eval "use if ($v_plus > \$]), strict => 'subs'; \${'f'} = 12" eq 12, + '"use if" with a true condition, fake pragma'); + +ok( (not defined eval "use if ($v_plus > \$]), strict => 'refs'; \${'f'} = 12" + and $@ =~ /while "strict refs" in use/), + '"use if" with a true condition and a pragma'); + |