File: hints.t

package info (click to toggle)
libdevel-pragma-perl 0.60-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 456 kB
  • ctags: 812
  • sloc: perl: 719; makefile: 2
file content (188 lines) | stat: -rw-r--r-- 3,130 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/env perl

use strict;
use warnings;

no warnings 'portable'; # suppress "v-string in use/require non-portable" warnings

use lib qw(t/lib);

use Test::More tests => 24;
use Devel::Pragma qw(hints);
use File::Spec;

# make sure use VERSION still works OK
use 5;
use 5.006;
use 5.006_000;
use 5.6.0;
use v5.6.0;

{
    BEGIN {
        hints();
        $^H{'Devel::Pragma::Test'} = 1;
    }

    BEGIN {
        require test_2;
    }

    BEGIN {
        is($^H{'Devel::Pragma::Test'}, 1, "compile-time require doesn't clobber %^H");
    }

    ok (test_2::test(), 'compile-time require');
}

{
    BEGIN {
        hints();
        $^H{'Devel::Pragma::Test'} = 1;
    }

    require test_3;

    ok (test_3::test(), 'runtime require');
}

{
    BEGIN {
        hints();
        $^H{'Devel::Pragma::Test'} = 1;
    }

    use test_4;

    BEGIN {
        is($^H{'Devel::Pragma::Test'}, 1, "use doesn't clobber %^H");
    }

    ok (test_4::test(), 'use');
}

{
    BEGIN {
        hints();
        $^H{'Devel::Pragma::Test'} = 1;
    }

    use test_4;

    BEGIN {
        is($^H{'Devel::Pragma::Test'}, 1, "reuse doesn't clobber %^H");
    }

    ok(test_4::test(), 'reuse');
}

{
    BEGIN {
        hints();
        $^H{'Devel::Pragma::Test'} = 1;
    }

    BEGIN {
        my $file = File::Spec->catfile('t', 'lib', 'test_5.pm');
        do $file;
    }

    BEGIN {
        is($^H{'Devel::Pragma::Test'}, 1, "compile-time do FILE doesn't clobber %^H");
    }

    ok(test_5::test(), 'compile-time do FILE');
}

{
    BEGIN {
        hints();
        $^H{'Devel::Pragma::Test'} = 1;
    }

    my $file = File::Spec->catfile('t', 'lib', 'test_6.pm');
    do $file;

    ok(test_6::test(), 'runtime do FILE');
}

eval {
    BEGIN {
        hints();
        $^H{'Devel::Pragma::Test'} = 1;
    }

    use test_7;

    BEGIN {
        is($^H{'Devel::Pragma::Test'}, 1, "eval block doesn't clobber %^H");
    }

    ok(test_7::test(), 'eval BLOCK');
};

ok(not($@), 'eval BLOCK OK');

eval q|
    {
        BEGIN {
            hints();
            $^H{'Devel::Pragma::Test'} = 1;
        }

        use test_8;

        BEGIN {
            is($^H{'Devel::Pragma::Test'}, 1, "eval EXPR doesn't clobber %^H");
        }

        ok(test_7::test(), 'eval EXPR');
    }
|;

ok(not($@), 'eval EXPR OK');

{
    BEGIN {
        hints();
        $^H{'Devel::Pragma::Test'} = 1;
    }

    use test_9;

    BEGIN {
        is($^H{'Devel::Pragma::Test'}, 1, "scope: %^H isn't clobbered");
    }

    ok (test_9::test(), 'scope');

    {
        use test_10;

        BEGIN {
            is($^H{'Devel::Pragma::Test'}, 1, "nested scope: %^H isn't clobbered");
        }

        ok (test_10::test(), 'nested scope');
    }

    use test_11;

    BEGIN {
        is($^H{'Devel::Pragma::Test'}, 1, "scope again: %^H isn't clobbered");
    }

    ok (test_11::test(), 'scope again');
}

{
    BEGIN {
        $^H{'Devel::Pragma::Test'} = 1;
        hints;
    }

    BEGIN {
        ok((($^H & 0x20000) == 0x20000), 'hints sets LOCALIZE_HH');
        is(hints->{'Devel::Pragma::Test'}, 1, 'hints returns a reference to %^H');
    }
}