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