1Test::Alien::Synthetic(U3s)er Contributed Perl DocumentatTieosnt::Alien::Synthetic(3)
2
3
4
6 Test::Alien::Synthetic - A mock alien object for testing
7
9 version 2.80
10
12 use Test2::V0;
13 use Test::Alien;
14
15 my $alien = synthetic {
16 cflags => '-I/foo/bar/include',
17 libs => '-L/foo/bar/lib -lbaz',
18 };
19
20 alien_ok $alien;
21
22 done_testing;
23
25 This class is used to model a synthetic Alien class that implements the
26 minimum Alien::Base interface needed by Test::Alien.
27
28 It can be useful if you have a non-Alien::Base based Alien distribution
29 that you need to test.
30
31 NOTE: The name of this class may move in the future, so do not refer to
32 this class name directly. Instead create instances of this class using
33 the Test::Alien#synthetic function.
34
36 cflags
37 String containing the compiler flags
38
39 cflags_static
40 String containing the static compiler flags
41
42 libs
43 String containing the linker and library flags
44
45 libs_static
46 String containing the static linker and library flags
47
48 dynamic_libs
49 List reference containing the dynamic libraries.
50
51 bin_dir
52 Tool binary directory.
53
54 runtime_prop
55 Runtime properties.
56
58 Here is a complete example using Alien::Libarchive which is a
59 non-Alien::Base based Alien distribution.
60
61 use strict;
62 use warnings;
63 use Test2::V0;
64 use Test::Alien;
65 use Alien::Libarchive;
66
67 my $real = Alien::Libarchive->new;
68 my $alien = synthetic {
69 cflags => scalar $real->cflags,
70 libs => scalar $real->libs,
71 dynamic_libs => [$real->dlls],
72 };
73
74 alien_ok $alien;
75
76 xs_ok do { local $/; <DATA> }, with_subtest {
77 my($module) = @_;
78 my $ptr = $module->archive_read_new;
79 like $ptr, qr{^[0-9]+$};
80 $module->archive_read_free($ptr);
81 };
82
83 ffi_ok { symbols => [qw( archive_read_new )] }, with_subtest {
84 my($ffi) = @_;
85 my $new = $ffi->function(archive_read_new => [] => 'opaque');
86 my $free = $ffi->function(archive_read_close => ['opaque'] => 'void');
87 my $ptr = $new->();
88 like $ptr, qr{^[0-9]+$};
89 $free->($ptr);
90 };
91
92 done_testing;
93
94 __DATA__
95
96 #include "EXTERN.h"
97 #include "perl.h"
98 #include "XSUB.h"
99 #include <archive.h>
100
101 MODULE = TA_MODULE PACKAGE = TA_MODULE
102
103 void *archive_read_new(class);
104 const char *class;
105 CODE:
106 RETVAL = (void*) archive_read_new();
107 OUTPUT:
108 RETVAL
109
110 void archive_read_free(class, ptr);
111 const char *class;
112 void *ptr;
113 CODE:
114 archive_read_free(ptr);
115
117 Test::Alien
118
120 Author: Graham Ollis <plicease@cpan.org>
121
122 Contributors:
123
124 Diab Jerius (DJERIUS)
125
126 Roy Storey (KIWIROY)
127
128 Ilya Pavlov
129
130 David Mertens (run4flat)
131
132 Mark Nunberg (mordy, mnunberg)
133
134 Christian Walde (Mithaldu)
135
136 Brian Wightman (MidLifeXis)
137
138 Zaki Mughal (zmughal)
139
140 mohawk (mohawk2, ETJ)
141
142 Vikas N Kumar (vikasnkumar)
143
144 Flavio Poletti (polettix)
145
146 Salvador Fandiño (salva)
147
148 Gianni Ceccarelli (dakkar)
149
150 Pavel Shaydo (zwon, trinitum)
151
152 Kang-min Liu (劉康民, gugod)
153
154 Nicholas Shipp (nshp)
155
156 Juan Julián Merelo Guervós (JJ)
157
158 Joel Berger (JBERGER)
159
160 Petr Písař (ppisar)
161
162 Lance Wicks (LANCEW)
163
164 Ahmad Fatoum (a3f, ATHREEF)
165
166 José Joaquín Atria (JJATRIA)
167
168 Duke Leto (LETO)
169
170 Shoichi Kaji (SKAJI)
171
172 Shawn Laffan (SLAFFAN)
173
174 Paul Evans (leonerd, PEVANS)
175
176 Håkon Hægland (hakonhagland, HAKONH)
177
178 nick nauwelaerts (INPHOBIA)
179
180 Florian Weimer
181
183 This software is copyright (c) 2011-2022 by Graham Ollis.
184
185 This is free software; you can redistribute it and/or modify it under
186 the same terms as the Perl 5 programming language system itself.
187
188
189
190perl v5.38.0 2023-07-20 Test::Alien::Synthetic(3)