This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test preamble: unify chdir 't' if -d 't';
[perl5.git] / t / lib / mypragma.t
CommitLineData
32645610
NC
1#!./perl
2
32645610
NC
3use strict;
4use warnings;
eaa79d3d
NC
5
6BEGIN {
7 unshift @INC, 'lib';
8 require './test.pl';
9 plan(tests => 14);
10}
32645610
NC
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
NC
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;
27eaf14c 25 use Sans_mypragma;
fd9f6265 26 is(mypragma::in_effect(), 42, "pragma is in effect within this block");
27eaf14c
RD
27 is(Sans_mypragma::affected(), undef,
28 "pragma not in effect outside this file");
fd9f6265 29 eval qq{is(mypragma::in_effect(), 42,
f52edb18 30 "pragma is in effect within this eval"); 1} or die $@;
2643c356
NC
31
32 {
33 no mypragma;
34 is(mypragma::in_effect(), 0, "pragma no longer in effect");
35 eval qq{is(mypragma::in_effect(), 0, "pragma no longer in effect"); 1}
36 or die $@;
37 }
38
fd9f6265
JJ
39 is(mypragma::in_effect(), 42, "pragma is in effect within this block");
40 eval qq{is(mypragma::in_effect(), 42,
2643c356 41 "pragma is in effect within this eval"); 1} or die $@;
32645610
NC
42}
43is(mypragma::in_effect(), undef, "pragma no longer in effect");
f52edb18 44eval qq{is(mypragma::in_effect(), undef, "pragma not in effect"); 1} or die $@;
32645610
NC
45
46
47BEGIN {
48 is($^H{mypragma}, undef, "Should no longer be in %^H");
49}