3 push @INC, "::lib:$MacPerl::Architecture:" if $^O eq 'MacOS';
4 require Config; import Config;
5 if ($Config{'extensions'} !~ /\bXS\/APItest\b/) {
6 print "1..0 # Skip: XS::APItest was not built\n";
9 # Hush the used only once warning.
10 $XS::APItest::WARNINGS_ON_BOOTSTRAP = $MacPerl::Architecture;
11 $XS::APItest::WARNINGS_ON_BOOTSTRAP = 1;
20 use Test::More tests => $uc ? 103 : 83;
22 # Doing this longhand cut&paste makes it clear
23 # BEGIN and INIT are FIFO, CHECK and END are LIFO
25 print "# First BEGIN\n";
26 is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
27 is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
28 is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
30 is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called")
32 is($XS::APItest::CHECK_called, undef, "CHECK not called");
33 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called");
34 is($XS::APItest::INIT_called, undef, "INIT not called");
35 is($XS::APItest::INIT_called_PP, undef, "INIT not called");
36 is($XS::APItest::END_called, undef, "END not yet called");
37 is($XS::APItest::END_called_PP, undef, "END not yet called");
41 print "# First CHECK\n";
42 is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
43 is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
44 is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
46 is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called")
48 is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
49 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
50 is($XS::APItest::INIT_called, undef, "INIT not called");
51 is($XS::APItest::INIT_called_PP, undef, "INIT not called");
52 is($XS::APItest::END_called, undef, "END not yet called");
53 is($XS::APItest::END_called_PP, undef, "END not yet called");
57 print "# First INIT\n";
58 is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
59 is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
60 is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
62 is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called")
64 is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
65 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
66 is($XS::APItest::INIT_called, undef, "INIT not called");
67 is($XS::APItest::INIT_called_PP, undef, "INIT not called");
68 is($XS::APItest::END_called, undef, "END not yet called");
69 is($XS::APItest::END_called_PP, undef, "END not yet called");
73 print "# First END\n";
74 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
75 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
76 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
77 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
78 is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
79 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
80 is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
81 is($XS::APItest::INIT_called_PP, undef, "INIT not called (too late)");
82 is($XS::APItest::END_called, 1, "END called");
83 is($XS::APItest::END_called_PP, 1, "END called");
86 print "# First body\n";
87 is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
88 is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
89 is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called") if $uc;
90 is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called") if $uc;
91 is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
92 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
93 is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
94 is($XS::APItest::INIT_called_PP, undef, "INIT not called (too late)");
95 is($XS::APItest::END_called, undef, "END not yet called");
96 is($XS::APItest::END_called_PP, undef, "END not yet called");
100 local $SIG{__WARN__} = sub { push @trap, join "!", @_ };
104 is(scalar @trap, 2, "There were 2 warnings");
105 is($trap[0], "Too late to run CHECK block.\n");
106 is($trap[1], "Too late to run INIT block.\n");
109 print "# Second body\n";
110 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
111 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
112 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
113 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
114 is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
115 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
116 is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
117 is($XS::APItest::INIT_called_PP, undef, "INIT not called (too late)");
118 is($XS::APItest::END_called, undef, "END not yet called");
119 is($XS::APItest::END_called_PP, undef, "END not yet called");
122 print "# Second BEGIN\n";
123 is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
124 is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
125 is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
127 is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not called")
129 is($XS::APItest::CHECK_called, undef, "CHECK not called");
130 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called");
131 is($XS::APItest::INIT_called, undef, "INIT not called");
132 is($XS::APItest::INIT_called_PP, undef, "INIT not called");
133 is($XS::APItest::END_called, undef, "END not yet called");
134 is($XS::APItest::END_called_PP, undef, "END not yet called");
138 print "# Second CHECK\n";
139 is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
140 is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
141 is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
143 is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called")
145 is($XS::APItest::CHECK_called, undef, "CHECK not called");
146 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called");
147 is($XS::APItest::INIT_called, undef, "INIT not called");
148 is($XS::APItest::INIT_called_PP, undef, "INIT not called");
149 is($XS::APItest::END_called, undef, "END not yet called");
150 is($XS::APItest::END_called_PP, undef, "END not yet called");
154 print "# Second INIT\n";
155 is($XS::APItest::BEGIN_called, undef, "BEGIN not yet called");
156 is($XS::APItest::BEGIN_called_PP, undef, "BEGIN not yet called");
157 is($XS::APItest::UNITCHECK_called, undef, "UNITCHECK not yet called")
159 is($XS::APItest::UNITCHECK_called_PP, undef, "UNITCHECK not yet called")
161 is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
162 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
163 is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
164 is($XS::APItest::INIT_called_PP, undef, "INIT not called (too late)");
165 is($XS::APItest::END_called, undef, "END not yet called");
166 is($XS::APItest::END_called_PP, undef, "END not yet called");
170 print "# Second END\n";
171 is($XS::APItest::BEGIN_called, 1, "BEGIN called");
172 is($XS::APItest::BEGIN_called_PP, 1, "BEGIN called");
173 is($XS::APItest::UNITCHECK_called, 1, "UNITCHECK called") if $uc;
174 is($XS::APItest::UNITCHECK_called_PP, 1, "UNITCHECK called") if $uc;
175 is($XS::APItest::CHECK_called, undef, "CHECK not called (too late)");
176 is($XS::APItest::CHECK_called_PP, undef, "CHECK not called (too late)");
177 is($XS::APItest::INIT_called, undef, "INIT not called (too late)");
178 is($XS::APItest::INIT_called_PP, undef, "INIT not called (too late)");
179 is($XS::APItest::END_called, 1, "END called");
180 is($XS::APItest::END_called_PP, 1, "END called");