in reply to Testing a XS module

Don't mix and match Test::More with print "ok".

use Test::More tests => 4; BEGIN { use_ok('Mytest') } ok( Mytest::is_even(0) == 1 ); ok( Mytest::is_even(1) == 0 ); ok( Mytest::is_even(2) == 1 );

In detail:

>type !.pl use Test::More tests => 4; BEGIN { use_ok('Mytest') } print &Mytest::is_even(0) == 1 ? "ok 2" : "not ok 2", "\n"; print &Mytest::is_even(1) == 0 ? "ok 3" : "not ok 3", "\n"; print &Mytest::is_even(2) == 1 ? "ok 4" : "not ok 4", "\n"; >perl !.pl 1..4 ok 1 - use Mytest; ok 2 ok 3 ok 4 # Looks like you planned 4 tests but only ran 1. >type @.pl use Test::More tests => 4; BEGIN { use_ok('Mytest') } ok( Mytest::is_even(0) == 1 ); ok( Mytest::is_even(1) == 0 ); ok( Mytest::is_even(2) == 1 ); >perl @.pl 1..4 ok 1 - use Mytest; ok 2 ok 3 ok 4

Replies are listed 'Best First'.
Re^2: Testing a XS module
by technojosh (Priest) on Aug 29, 2007 at 19:29 UTC
    Thank you very much for the help. I had to re-run the Makefile.pl to get the same output as you, but otherwise it works perfect...