File: magic_phase.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (49 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (8)
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
#!./perl

use strict;
use warnings;

# Test ${^GLOBAL_PHASE}
#
# Test::More, t/test.pl, etc., assert plans in END, which happens before global
# destruction. We do not want to use those programs/libraries here, so we
# place this file in directory t/opbasic.

BEGIN { print "1..7\n" }

sub ok ($$) {
    print "not " if !$_[0];
    print "ok";
    print " - $_[1]" if defined $_[1];
    print "\n";
}

BEGIN {
    ok ${^GLOBAL_PHASE} eq 'START', 'START';
}

CHECK {
    ok ${^GLOBAL_PHASE} eq 'CHECK', 'CHECK';
}

INIT {
    ok ${^GLOBAL_PHASE} eq 'INIT', 'INIT';
}

ok ${^GLOBAL_PHASE} eq 'RUN', 'RUN';

sub Moo::DESTROY {
    ok ${^GLOBAL_PHASE} eq 'RUN', 'DESTROY is run-time too, usually';
}

my $tiger = bless {}, Moo::;

sub Kooh::DESTROY {
    ok ${^GLOBAL_PHASE} eq 'DESTRUCT', 'DESTRUCT';
}

our $affe = bless {}, Kooh::;

END {
    ok ${^GLOBAL_PHASE} eq 'END', 'END';
}