This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/run/locale.t: use 'warnings'
[perl5.git] / t / lib / mypragma.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     require './test.pl';
6     @INC = qw(lib ../lib);
7     plan(tests => 14);
8 }
9
10 use strict;
11 use warnings;
12
13 use mypragma (); # don't enable this pragma yet
14
15 BEGIN {
16    is($^H{mypragma}, undef, "Shouldn't be in %^H yet");
17 }
18
19 is(mypragma::in_effect(), undef, "pragma not in effect yet");
20 {
21     is(mypragma::in_effect(), undef, "pragma not in effect yet");
22     eval qq{is(mypragma::in_effect(), undef, "pragma not in effect yet"); 1}
23         or die $@;
24
25     use mypragma;
26     use Sans_mypragma;
27     is(mypragma::in_effect(), 42, "pragma is in effect within this block");
28     is(Sans_mypragma::affected(), undef,
29         "pragma not in effect outside this file");
30     eval qq{is(mypragma::in_effect(), 42,
31                "pragma is in effect within this eval"); 1} or die $@;
32
33     {
34       no mypragma;
35       is(mypragma::in_effect(), 0, "pragma no longer in effect");
36       eval qq{is(mypragma::in_effect(), 0, "pragma no longer in effect"); 1}
37         or die $@;
38     }
39
40     is(mypragma::in_effect(), 42, "pragma is in effect within this block");
41     eval qq{is(mypragma::in_effect(), 42,
42                "pragma is in effect within this eval"); 1} or die $@;
43 }
44 is(mypragma::in_effect(), undef, "pragma no longer in effect");
45 eval qq{is(mypragma::in_effect(), undef, "pragma not in effect"); 1} or die $@;
46
47
48 BEGIN {
49    is($^H{mypragma}, undef, "Should no longer be in %^H");
50 }