Throw Away Your C Compiler (after building Perl):
#!/usr/bin/perl# P5NCI.t
BEGIN { chdir 't' if -d 't'; use blib; }
use strict; use warnings;
use Test::More tests => 9;
use_ok('P5NCI') or exit;
my $double_lib = P5NCI::load_lib( '../nci_demo.so' ); my $double_double = P5NCI::load_nci_func( $double_lib, 'double_double', 'dd' ); is( $double_double->( 1.0 ), 2.0 ); is( $double_double->( 3.14 ), 6.28 );
my $double_int = P5NCI::load_nci_func( $double_lib, 'double_int', 'ii' ); is( $double_int->( 1 ), 2 ); is( $double_int->( 3 ), 6 );
my $double_float = P5NCI::load_nci_func( $double_lib, 'double_float', 'ff' ); is( $double_float->( 1.0 ), 2.0 ); ok( abs( $double_float->( 0.314 ) - 0.628) < 0.00001 );
my $multiply_ints = P5NCI::load_nci_func( $double_lib, 'multiply_ints', 'iii' ); is( $multiply_ints->( 10, 20 ), 200 ); is( $multiply_ints->( 5, 5 ), 25 );
The interface is a bit grotty, the documentation is spotty, the build system needs some help, and it only handles really simple functions right now, but it works.
