8 use base qw/ DynaLoader Exporter /;
10 # Items to export into callers namespace by default. Note: do not export
11 # names by default without a very good reason. Use EXPORT_OK instead.
12 # Do not simply export all your public functions/methods/constants.
14 # Export everything since these functions are only used by a test script
15 our @EXPORT = qw( print_double print_int print_long
16 print_float print_long_double have_long_double print_flush
17 mpushp mpushn mpushi mpushu
18 mxpushp mxpushn mxpushi mxpushu
19 call_sv call_pv call_method eval_sv eval_pv require_pv
20 G_SCALAR G_ARRAY G_VOID G_DISCARD G_EVAL G_NOARGS
21 G_KEEPERR G_NODEBUG G_METHOD G_WANT
22 apitest_exception mycroak strtab
23 my_cxt_getint my_cxt_getsv my_cxt_setint my_cxt_setsv
24 sv_setsv_cow_hashkey_core sv_setsv_cow_hashkey_notcore
25 rmagical_cast rmagical_flags
26 DPeek utf16_to_utf8 utf16_to_utf8_reversed my_exit
30 our $VERSION = '0.20';
32 use vars '$WARNINGS_ON_BOOTSTRAP';
33 use vars map "\$${_}_called_PP", qw(BEGIN UNITCHECK CHECK INIT END);
36 # This is arguably a hack, but it disposes of the UNITCHECK block without
37 # needing to preprocess the source code
39 eval 'sub UNITCHECK (&) {}; 1' or die $@;
43 # Do these here to verify that XS code and Perl code get called at the same
49 $UNITCHECK_called_PP++;
52 # Need $W false by default, as some tests run under -w, and under -w we
53 # can get warnings about "Too late to run CHECK" block (and INIT block)
66 if ($WARNINGS_ON_BOOTSTRAP) {
67 bootstrap XS::APItest $VERSION;
69 # More CHECK and INIT blocks that could warn:
71 bootstrap XS::APItest $VERSION;
79 XS::APItest - Test the perl C API
88 This module tests the perl C API. Also exposes various bit of the perl
89 internals for the use of core test scripts.
93 This module can be used to check that the perl C API is behaving
94 correctly. This module provides test functions and an associated
95 test script that verifies the output.
97 This module is not meant to be installed.
101 Exports all the test functions:
105 =item B<print_double>
107 Test that a double-precision floating point number is formatted
108 correctly by C<printf>.
110 print_double( $val );
112 Output is sent to STDOUT.
114 =item B<print_long_double>
116 Test that a C<long double> is formatted correctly by
117 C<printf>. Takes no arguments - the test value is hard-wired
118 into the function (as "7").
122 Output is sent to STDOUT.
124 =item B<have_long_double>
126 Determine whether a C<long double> is supported by Perl. This should
127 be used to determine whether to test C<print_long_double>.
129 print_long_double() if have_long_double;
133 Test that an C<NV> is formatted correctly by
138 Output is sent to STDOUT.
142 Test that an C<IV> is formatted correctly by
147 Output is sent to STDOUT.
151 Test that an C<UV> is formatted correctly by
156 Output is sent to STDOUT.
160 Test that an C<int> is formatted correctly by
165 Output is sent to STDOUT.
169 Test that an C<long> is formatted correctly by
174 Output is sent to STDOUT.
178 Test that a single-precision floating point number is formatted
179 correctly by C<printf>.
183 Output is sent to STDOUT.
185 =item B<call_sv>, B<call_pv>, B<call_method>
187 These exercise the C calls of the same names. Everything after the flags
188 arg is passed as the the args to the called function. They return whatever
189 the C function itself pushed onto the stack, plus the return value from
190 the function; for example
192 call_sv( sub { @_, 'c' }, G_ARRAY, 'a', 'b'); # returns 'a', 'b', 'c', 3
193 call_sv( sub { @_ }, G_SCALAR, 'a', 'b'); # returns 'b', 1
197 Evaluates the passed SV. Result handling is done the same as for
202 Exercises the C function of the same name in scalar context. Returns the
203 same SV that the C function returns.
207 Exercises the C function of the same name. Returns nothing.
213 L<XS::Typemap>, L<perlapi>.
217 Tim Jenness, E<lt>t.jenness@jach.hawaii.eduE<gt>,
218 Christian Soeller, E<lt>csoelle@mph.auckland.ac.nzE<gt>,
219 Hugo van der Sanden E<lt>hv@crypt.compulink.co.ukE<gt>
221 =head1 COPYRIGHT AND LICENSE
223 Copyright (C) 2002,2004 Tim Jenness, Christian Soeller, Hugo van der Sanden.
226 This library is free software; you can redistribute it and/or modify
227 it under the same terms as Perl itself.