36 additional tests for B
[p5sagit/p5-mst-13.2.git] / ext / XS / APItest / APItest.pm
CommitLineData
3e61d65a 1package XS::APItest;
2
3use 5.008;
4use strict;
5use warnings;
6use Carp;
7
8use base qw/ DynaLoader Exporter /;
9
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.
13
14# Export everything since these functions are only used by a test script
deec275f 15our @EXPORT = qw( print_double print_int print_long
9d911683 16 print_float print_long_double have_long_double print_flush
d4b90eee 17 mpushp mpushn mpushi mpushu
18 mxpushp mxpushn mxpushi mxpushu
d1f347d7 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
3e61d65a 22);
23
d1f347d7 24# from cop.h
25sub G_SCALAR() { 0 }
26sub G_ARRAY() { 1 }
27sub G_VOID() { 128 }
28sub G_DISCARD() { 2 }
29sub G_EVAL() { 4 }
30sub G_NOARGS() { 8 }
31sub G_KEEPERR() { 16 }
32sub G_NODEBUG() { 32 }
33sub G_METHOD() { 64 }
34
35our $VERSION = '0.05';
3e61d65a 36
37bootstrap XS::APItest $VERSION;
38
391;
40__END__
41
42=head1 NAME
43
44XS::APItest - Test the perl C API
45
46=head1 SYNOPSIS
47
48 use XS::APItest;
49 print_double(4);
50
51=head1 ABSTRACT
52
53This module tests the perl C API. Currently tests that C<printf>
54works correctly.
55
56=head1 DESCRIPTION
57
58This module can be used to check that the perl C API is behaving
59correctly. This module provides test functions and an associated
60test script that verifies the output.
61
62This module is not meant to be installed.
63
64=head2 EXPORT
65
66Exports all the test functions:
67
68=over 4
69
70=item B<print_double>
71
72Test that a double-precision floating point number is formatted
73correctly by C<printf>.
74
75 print_double( $val );
76
77Output is sent to STDOUT.
78
79=item B<print_long_double>
80
81Test that a C<long double> is formatted correctly by
82C<printf>. Takes no arguments - the test value is hard-wired
83into the function (as "7").
84
85 print_long_double();
86
87Output is sent to STDOUT.
88
89=item B<have_long_double>
90
91Determine whether a C<long double> is supported by Perl. This should
92be used to determine whether to test C<print_long_double>.
93
94 print_long_double() if have_long_double;
95
96=item B<print_nv>
97
98Test that an C<NV> is formatted correctly by
99C<printf>.
100
101 print_nv( $val );
102
103Output is sent to STDOUT.
104
105=item B<print_iv>
106
107Test that an C<IV> is formatted correctly by
108C<printf>.
109
110 print_iv( $val );
111
112Output is sent to STDOUT.
113
114=item B<print_uv>
115
116Test that an C<UV> is formatted correctly by
117C<printf>.
118
119 print_uv( $val );
120
121Output is sent to STDOUT.
122
123=item B<print_int>
124
125Test that an C<int> is formatted correctly by
126C<printf>.
127
128 print_int( $val );
129
130Output is sent to STDOUT.
131
132=item B<print_long>
133
134Test that an C<long> is formatted correctly by
135C<printf>.
136
137 print_long( $val );
138
139Output is sent to STDOUT.
140
141=item B<print_float>
142
143Test that a single-precision floating point number is formatted
144correctly by C<printf>.
145
146 print_float( $val );
147
148Output is sent to STDOUT.
149
d1f347d7 150=item B<call_sv>, B<call_pv>, B<call_method>
151
152These exercise the C calls of the same names. Everything after the flags
153arg is passed as the the args to the called function. They return whatever
154the C function itself pushed onto the stack, plus the return value from
155the function; for example
156
157 call_sv( sub { @_, 'c' }, G_ARRAY, 'a', 'b'); # returns 'a', 'b', 'c', 3
158 call_sv( sub { @_ }, G_SCALAR, 'a', 'b'); # returns 'b', 1
159
160=item B<eval_sv>
161
162Evalulates the passed SV. Result handling is done the same as for
163C<call_sv()> etc.
164
165=item B<eval_pv>
166
167Excercises the C function of the same name in scalar context. Returns the
168same SV that the C function returns.
169
170=item B<require_pv>
171
172Excercises the C function of the same name. Returns nothing.
173
3e61d65a 174=back
175
176=head1 SEE ALSO
177
178L<XS::Typemap>, L<perlapi>.
179
180=head1 AUTHORS
181
182Tim Jenness, E<lt>t.jenness@jach.hawaii.eduE<gt>,
183Christian Soeller, E<lt>csoelle@mph.auckland.ac.nzE<gt>,
184Hugo van der Sanden E<lt>hv@crypt.compulink.co.ukE<gt>
185
186=head1 COPYRIGHT AND LICENSE
187
d1f347d7 188Copyright (C) 2002,2004 Tim Jenness, Christian Soeller, Hugo van der Sanden.
3e61d65a 189All Rights Reserved.
190
191This library is free software; you can redistribute it and/or modify
192it under the same terms as Perl itself.
193
194=cut