1Test::Alien::Synthetic(U3s)er Contributed Perl DocumentatTieosnt::Alien::Synthetic(3)
2
3
4

NAME

6       Test::Alien::Synthetic - A mock alien object for testing
7

VERSION

9       version 0.15
10

SYNOPSIS

12        use Test2::Bundle::Extended;
13        use Test::Alien;
14
15        plan 1;
16
17        my $alien = synthetic {
18          cflags => '-I/foo/bar/include',
19          libs   => '-L/foo/bar/lib -lbaz',
20        };
21
22        alien_ok $alien;
23

DESCRIPTION

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

ATTRIBUTES

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

EXAMPLE

55       Here is a complete example using Alien::Libarchive which is a
56       non-Alien::Base based Alien distribution.
57
58        use strict;
59        use warnings;
60        use Test2::Bundle::Extended;
61        use Test::Alien;
62        use Alien::Libarchive;
63
64        plan 5;
65
66        my $real = Alien::Libarchive->new;
67        my $alien = synthetic {
68          cflags       => scalar $real->cflags,
69          libs         => scalar $real->libs,
70          dynamic_libs => [$real->dlls],
71        };
72
73        alien_ok $alien;
74
75        xs_ok do { local $/; <DATA> }, with_subtest {
76          my($module) = @_;
77          plan 1;
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        __DATA__
93
94        #include "EXTERN.h"
95        #include "perl.h"
96        #include "XSUB.h"
97        #include <archive.h>
98
99        MODULE = TA_MODULE PACKAGE = TA_MODULE
100
101        void *archive_read_new(class);
102            const char *class;
103          CODE:
104            RETVAL = (void*) archive_read_new();
105          OUTPUT:
106            RETVAL
107
108        void archive_read_free(class, ptr);
109            const char *class;
110            void *ptr;
111          CODE:
112            archive_read_free(ptr);
113

SEE ALSO

115       Test::Alien
116

AUTHOR

118       Graham Ollis <plicease@cpan.org>
119
121       This software is copyright (c) 2015 by Graham Ollis.
122
123       This is free software; you can redistribute it and/or modify it under
124       the same terms as the Perl 5 programming language system itself.
125
126
127
128perl v5.30.0                      2019-07-26         Test::Alien::Synthetic(3)
Impressum