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
1 #!./perl
2
3 use strict;
4 use warnings;
5
6 BEGIN {
7     unshift @INC, 'lib';
8     require './test.pl';
9     plan(tests => 14);
10 }
11
12 use mypragma (); # don't enable this pragma yet
13
14 BEGIN {
15    is($^H{mypragma}, undef, "Shouldn't be in %^H yet");
16 }
17
18 is(mypragma::in_effect(), undef, "pragma not in effect yet");
19 {
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
24     use mypragma;
25     use Sans_mypragma;
26     is(mypragma::in_effect(), 42, "pragma is in effect within this block");
27     is(Sans_mypragma::affected(), undef,
28         "pragma not in effect outside this file");
29     eval qq{is(mypragma::in_effect(), 42,
30                "pragma is in effect within this eval"); 1} or die $@;
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
39     is(mypragma::in_effect(), 42, "pragma is in effect within this block");
40     eval qq{is(mypragma::in_effect(), 42,
41                "pragma is in effect within this eval"); 1} or die $@;
42 }
43 is(mypragma::in_effect(), undef, "pragma no longer in effect");
44 eval qq{is(mypragma::in_effect(), undef, "pragma not in effect"); 1} or die $@;
45
46
47 BEGIN {
48    is($^H{mypragma}, undef, "Should no longer be in %^H");
49 }