Test that user pragmas work inside string eval.
[p5sagit/p5-mst-13.2.git] / t / lib / mypragma.t
CommitLineData
32645610 1#!./perl
2
3BEGIN {
4 chdir 't';
5 @INC = ('../lib', 'lib');
6}
7
8use strict;
9use warnings;
f52edb18 10use Test::More tests => 9;
32645610 11
12use mypragma (); # don't enable this pragma yet
13
14BEGIN {
15 is($^H{mypragma}, undef, "Shouldn't be in %^H yet");
16}
17
18is(mypragma::in_effect(), undef, "pragma not in effect yet");
19{
f52edb18 20 is(mypragma::in_effect(), undef, "pragma not in effect yet");
21 eval qq{is(mypragma::in_effect(), undef, "pragma not in effect yet"); 1}
22 or die $@;
23
32645610 24 use mypragma;
25 is(mypragma::in_effect(), 1, "pragma is in effect within this block");
f52edb18 26 eval qq{is(mypragma::in_effect(), 1,
27 "pragma is in effect within this eval"); 1} or die $@;
32645610 28}
29is(mypragma::in_effect(), undef, "pragma no longer in effect");
f52edb18 30eval qq{is(mypragma::in_effect(), undef, "pragma not in effect"); 1} or die $@;
32645610 31
32
33BEGIN {
34 is($^H{mypragma}, undef, "Should no longer be in %^H");
35}