This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Let's remove the grep in void context warning.
[perl5.git] / t / lib / mypragma.t
1 #!./perl
2
3 BEGIN {
4     chdir 't';
5     @INC = ('../lib', 'lib');
6 }
7
8 use strict;
9 use warnings;
10 use Test::More tests => 13;
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     is(mypragma::in_effect(), 42, "pragma is in effect within this block");
26     eval qq{is(mypragma::in_effect(), 42,
27                "pragma is in effect within this eval"); 1} or die $@;
28
29     {
30       no mypragma;
31       is(mypragma::in_effect(), 0, "pragma no longer in effect");
32       eval qq{is(mypragma::in_effect(), 0, "pragma no longer in effect"); 1}
33         or die $@;
34     }
35
36     is(mypragma::in_effect(), 42, "pragma is in effect within this block");
37     eval qq{is(mypragma::in_effect(), 42,
38                "pragma is in effect within this eval"); 1} or die $@;
39 }
40 is(mypragma::in_effect(), undef, "pragma no longer in effect");
41 eval qq{is(mypragma::in_effect(), undef, "pragma not in effect"); 1} or die $@;
42
43
44 BEGIN {
45    is($^H{mypragma}, undef, "Should no longer be in %^H");
46 }