xref: /openbsd-src/gnu/usr.bin/perl/t/lib/mypragma.t (revision b8851fcc53cbe24fd20b090f26dd149e353f6174)
1850e2753Smillert#!./perl
2850e2753Smillert
3b39c5158SmillertBEGIN {
4*b8851fccSafresh1    chdir 't' if -d 't';
5b39c5158Smillert    require './test.pl';
6*b8851fccSafresh1    @INC = qw(lib ../lib);
7b39c5158Smillert    plan(tests => 14);
8b39c5158Smillert}
9850e2753Smillert
10*b8851fccSafresh1use strict;
11*b8851fccSafresh1use warnings;
12*b8851fccSafresh1
13850e2753Smillertuse mypragma (); # don't enable this pragma yet
14850e2753Smillert
15850e2753SmillertBEGIN {
16850e2753Smillert   is($^H{mypragma}, undef, "Shouldn't be in %^H yet");
17850e2753Smillert}
18850e2753Smillert
19850e2753Smillertis(mypragma::in_effect(), undef, "pragma not in effect yet");
20850e2753Smillert{
21850e2753Smillert    is(mypragma::in_effect(), undef, "pragma not in effect yet");
22850e2753Smillert    eval qq{is(mypragma::in_effect(), undef, "pragma not in effect yet"); 1}
23850e2753Smillert	or die $@;
24850e2753Smillert
25850e2753Smillert    use mypragma;
2643003dfeSmillert    use Sans_mypragma;
27850e2753Smillert    is(mypragma::in_effect(), 42, "pragma is in effect within this block");
2843003dfeSmillert    is(Sans_mypragma::affected(), undef,
2943003dfeSmillert	"pragma not in effect outside this file");
30850e2753Smillert    eval qq{is(mypragma::in_effect(), 42,
31850e2753Smillert	       "pragma is in effect within this eval"); 1} or die $@;
32850e2753Smillert
33850e2753Smillert    {
34850e2753Smillert      no mypragma;
35850e2753Smillert      is(mypragma::in_effect(), 0, "pragma no longer in effect");
36850e2753Smillert      eval qq{is(mypragma::in_effect(), 0, "pragma no longer in effect"); 1}
37850e2753Smillert	or die $@;
38850e2753Smillert    }
39850e2753Smillert
40850e2753Smillert    is(mypragma::in_effect(), 42, "pragma is in effect within this block");
41850e2753Smillert    eval qq{is(mypragma::in_effect(), 42,
42850e2753Smillert	       "pragma is in effect within this eval"); 1} or die $@;
43850e2753Smillert}
44850e2753Smillertis(mypragma::in_effect(), undef, "pragma no longer in effect");
45850e2753Smillerteval qq{is(mypragma::in_effect(), undef, "pragma not in effect"); 1} or die $@;
46850e2753Smillert
47850e2753Smillert
48850e2753SmillertBEGIN {
49850e2753Smillert   is($^H{mypragma}, undef, "Should no longer be in %^H");
50850e2753Smillert}
51