Make extensions in ext run their tests from the extension's own directory.
[p5sagit/p5-mst-13.2.git] / ext / XS-APItest / t / xs_special_subs.t
CommitLineData
a6ea7cf3 1#!perl -w
2
84ac5fd7 3BEGIN {
84ac5fd7 4 push @INC, "::lib:$MacPerl::Architecture:" if $^O eq 'MacOS';
5 require Config; import Config;
6 if ($Config{'extensions'} !~ /\bXS\/APItest\b/) {
7 print "1..0 # Skip: XS::APItest was not built\n";
8 exit 0;
9 }
a6ea7cf3 10 # Hush the used only once warning.
11 $XS::APItest::WARNINGS_ON_BOOTSTRAP = $MacPerl::Architecture;
12 $XS::APItest::WARNINGS_ON_BOOTSTRAP = 1;
84ac5fd7 13}
14
15use strict;
16use warnings;
9568a123 17my $uc;
18BEGIN {
19 $uc = $] > 5.009;
20}
21use Test::More tests => $uc ? 100 : 80;
84ac5fd7 22
23# Doing this longhand cut&paste makes it clear
24# BEGIN and INIT are FIFO, CHECK and END are LIFO
25BEGIN {
0932863f 26 print "# First BEGIN\n";
84ac5fd7 27 is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
0932863f 28 is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
9568a123 29 is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
30 if $uc;
31 is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called")
32 if $uc;
84ac5fd7 33 is($XS::APItest::CHECK_called, undef, "CHECK not yet called");
0932863f 34 is($XS::APItest::CHECK_called_PP, undef, "CHECK not yet called");
84ac5fd7 35 is($XS::APItest::INIT_called, undef, "INIT not yet called");
0932863f 36 is($XS::APItest::INIT_called_PP, undef, "INIT not yet called");
84ac5fd7 37 is($XS::APItest::END_called, undef, "END not yet called");
0932863f 38 is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 39}
40
41CHECK {
0932863f 42 print "# First CHECK\n";
84ac5fd7 43 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 44 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 45 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
46 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
84ac5fd7 47 is($XS::APItest::CHECK_called, 1, "CHECK called");
0932863f 48 is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
84ac5fd7 49 is($XS::APItest::INIT_called, undef, "INIT not yet called");
0932863f 50 is($XS::APItest::INIT_called_PP, undef, "INIT not yet called");
84ac5fd7 51 is($XS::APItest::END_called, undef, "END not yet called");
0932863f 52 is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 53}
54
55INIT {
0932863f 56 print "# First INIT\n";
84ac5fd7 57 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 58 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 59 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
60 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
84ac5fd7 61 is($XS::APItest::CHECK_called, 1, "CHECK called");
0932863f 62 is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
84ac5fd7 63 is($XS::APItest::INIT_called, undef, "INIT not yet called");
0932863f 64 is($XS::APItest::INIT_called_PP, undef, "INIT not yet called");
84ac5fd7 65 is($XS::APItest::END_called, undef, "END not yet called");
0932863f 66 is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 67}
68
69END {
0932863f 70 print "# First END\n";
84ac5fd7 71 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 72 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 73 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
74 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
84ac5fd7 75 is($XS::APItest::CHECK_called, 1, "CHECK called");
0932863f 76 is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
84ac5fd7 77 is($XS::APItest::INIT_called, 1, "INIT called");
0932863f 78 is($XS::APItest::INIT_called_PP, 1, "INIT called");
84ac5fd7 79 is($XS::APItest::END_called, 1, "END called");
0932863f 80 is($XS::APItest::END_called_PP, 1, "END called");
84ac5fd7 81}
82
0932863f 83print "# First body\n";
84ac5fd7 84is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 85is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 86is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
87is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
84ac5fd7 88is($XS::APItest::CHECK_called, 1, "CHECK called");
0932863f 89is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
84ac5fd7 90is($XS::APItest::INIT_called, 1, "INIT called");
0932863f 91is($XS::APItest::INIT_called_PP, 1, "INIT called");
84ac5fd7 92is($XS::APItest::END_called, undef, "END not yet called");
0932863f 93is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 94
95use XS::APItest;
96
0932863f 97print "# Second body\n";
84ac5fd7 98is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 99is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 100is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
101is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
84ac5fd7 102is($XS::APItest::CHECK_called, 1, "CHECK called");
0932863f 103is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
84ac5fd7 104is($XS::APItest::INIT_called, 1, "INIT called");
0932863f 105is($XS::APItest::INIT_called_PP, 1, "INIT called");
84ac5fd7 106is($XS::APItest::END_called, undef, "END not yet called");
0932863f 107is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 108
109BEGIN {
0932863f 110 print "# Second BEGIN\n";
84ac5fd7 111 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 112 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 113 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
114 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
84ac5fd7 115 is($XS::APItest::CHECK_called, undef, "CHECK not yet called");
0932863f 116 is($XS::APItest::CHECK_called_PP, undef, "CHECK not yet called");
84ac5fd7 117 is($XS::APItest::INIT_called, undef, "INIT not yet called");
0932863f 118 is($XS::APItest::INIT_called_PP, undef, "INIT not yet called");
84ac5fd7 119 is($XS::APItest::END_called, undef, "END not yet called");
0932863f 120 is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 121}
122
123CHECK {
0932863f 124 print "# Second CHECK\n";
84ac5fd7 125 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 126 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 127 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK yet called") if $uc;
128 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK yet called") if $uc;
84ac5fd7 129 is($XS::APItest::CHECK_called, undef, "CHECK not yet called");
0932863f 130 is($XS::APItest::CHECK_called_PP, undef, "CHECK not yet called");
84ac5fd7 131 is($XS::APItest::INIT_called, undef, "INIT not yet called");
0932863f 132 is($XS::APItest::INIT_called_PP, undef, "INIT not yet called");
84ac5fd7 133 is($XS::APItest::END_called, undef, "END not yet called");
0932863f 134 is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 135}
136
137INIT {
0932863f 138 print "# Second INIT\n";
84ac5fd7 139 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 140 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 141 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
142 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
84ac5fd7 143 is($XS::APItest::CHECK_called, 1, "CHECK called");
0932863f 144 is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
84ac5fd7 145 is($XS::APItest::INIT_called, 1, "INIT called");
0932863f 146 is($XS::APItest::INIT_called_PP, 1, "INIT called");
84ac5fd7 147 is($XS::APItest::END_called, undef, "END not yet called");
0932863f 148 is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 149}
150
151END {
0932863f 152 print "# Second END\n";
84ac5fd7 153 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
0932863f 154 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
9568a123 155 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
156 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
84ac5fd7 157 is($XS::APItest::CHECK_called, 1, "CHECK called");
0932863f 158 is($XS::APItest::CHECK_called_PP, 1, "CHECK called");
84ac5fd7 159 is($XS::APItest::INIT_called, 1, "INIT called");
0932863f 160 is($XS::APItest::INIT_called_PP, 1, "INIT called");
84ac5fd7 161 is($XS::APItest::END_called, undef, "END not yet called");
0932863f 162 is($XS::APItest::END_called_PP, undef, "END not yet called");
84ac5fd7 163}