summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/t/opbasic/magic_phase.t
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/perl/t/opbasic/magic_phase.t')
-rw-r--r--gnu/usr.bin/perl/t/opbasic/magic_phase.t49
1 files changed, 49 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/t/opbasic/magic_phase.t b/gnu/usr.bin/perl/t/opbasic/magic_phase.t
new file mode 100644
index 00000000000..d7217058575
--- /dev/null
+++ b/gnu/usr.bin/perl/t/opbasic/magic_phase.t
@@ -0,0 +1,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';
+}