Acme-Alien-DontPanic
view release on metacpan or search on metacpan
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
t/acme_alien_dontpanic.t view on Meta::CPAN
use Test2::V0 -no_srand => 1;
use Test::Alien 0.05;
use Acme::Alien::DontPanic;
use Data::Dumper qw( Dumper );
alien_ok 'Acme::Alien::DontPanic';
xs_ok do { local $/; <DATA> }, with_subtest {
my($module) = @_;
plan 1;
is $module->answer, 42, 'answer is 42';
};
ffi_ok { symbols => ['answer'] }, with_subtest {
my($ffi) = @_;
my $answer = $ffi->function(answer=>[]=>'int')->call;
plan 1;
is $answer, 42;
t/acme_alien_dontpanic.t view on Meta::CPAN
run_ok('dontpanic')
->success
->out_like(qr{the answer to life the universe and everything is 42})
->note;
note Dumper(Acme::Alien::DontPanic->Inline("C"));
note Dumper(Acme::Alien::DontPanic->runtime_prop);
done_testing;
__DATA__
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <libdontpanic.h>
MODULE = TA_MODULE PACKAGE = TA_MODULE
int answer(class)
const char *class;
use Test2::V0 -no_srand => 1;
use Path::Tiny qw( path );
use File::Temp qw( tempdir );
BEGIN { $ENV{PERL_INLINE_DIRECTORY} = tempdir( DIR => path('.')->absolute->stringify, CLEANUP => 1, TEMPLATE => 'inlineXXXXX') }
use Acme::Alien::DontPanic;
use Inline 0.56 with => 'Acme::Alien::DontPanic';
use Inline C => 'DATA', ENABLE => 'AUTOWRAP';
is string_answer(), "the answer to life the universe and everything is 42", "indirect call";
is answer(), 42, "direct call";
done_testing;
__DATA__
__C__
#include <stdio.h>
char *string_answer()
{
static char buffer[1024];
sprintf(buffer, "the answer to life the universe and everything is %d", answer());
return buffer;
}
t/inline_cpp.t view on Meta::CPAN
use Test2::V0 -no_srand => 1;
use Path::Tiny qw( path );
use File::Temp qw( tempdir );
BEGIN { $ENV{PERL_INLINE_DIRECTORY} = tempdir( DIR => path('.')->absolute->stringify, CLEANUP => 1, TEMPLATE => 'inlineXXXXX') }
use Acme::Alien::DontPanic;
use Inline 0.56 with => 'Acme::Alien::DontPanic';
use Inline CPP => 'DATA', ENABLE => 'AUTOWRAP';
is Foo->new->string_answer, "the answer to life the universe and everything is 42", 'indirect';
is answer(), 42, "direct";
done_testing;
__DATA__
__CPP__
#include <stdio.h>
class Foo {
public:
char *string_answer()
{
static char buffer[1024];
sprintf(buffer, "the answer to life the universe and everything is %d", answer());
( run in 1.930 second using v1.01-cache-2.11-cpan-7e94247ccb0 )