1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
################################################################################
#
# $Project: /Convert-Binary-C $
# $Author: mhx $
# $Date: 2009/03/15 04:10:58 +0100 $
# $Revision: 24 $
# $Source: /tests/701_debug.t $
#
################################################################################
#
# Copyright (c) 2002-2009 Marcus Holland-Moritz. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
################################################################################
use Test;
use Convert::Binary::C;
$^W = 1;
BEGIN {
$debug = Convert::Binary::C::feature( 'debug' );
plan tests => 17;
}
ok( defined $debug );
$dbfile = 'tests/debug.out';
-e $dbfile and unlink $dbfile;
$SIG{__WARN__} = sub { push @warnings, $_[0] };
eval qq{
use Convert::Binary::C debug => 'all', debugfile => '$dbfile';
};
ok( $@, '' );
if( $debug ) {
ok( scalar @warnings, 0, "unexpected warning(s)" );
ok( 1 ); # dummy
}
else {
ok( scalar @warnings, 1, "wrong number of warnings" );
ok( $warnings[0], qr/Convert::Binary::C not compiled with debugging support/ );
}
ok( -e $dbfile xor not $debug );
ok( -z $dbfile xor not $debug );
eval { $p = new Convert::Binary::C };
ok( $@, '' );
ok( ref $p, 'Convert::Binary::C' );
undef $p;
@warnings = ();
eval q{
use Convert::Binary::C debugfile => '';
};
ok( $@, '', "unexpected error" );
ok( scalar @warnings, 1, "wrong number of warnings" );
ok( $warnings[0], $debug ? qr/Cannot open '', defaulting to stderr/
: qr/Convert::Binary::C not compiled with debugging support/ );
ok( -s $dbfile xor not $debug );
@warnings = ();
eval qq{
import Convert::Binary::C debug => 'foo';
};
if( $debug ) {
ok( $@, qr/^Unknown debug option 'f'/ );
ok( scalar @warnings, 0, "unexpected warning(s)" );
ok( 1 ); # dummy
}
else {
ok( $@, '', "unexpected error" );
ok( scalar @warnings, 1, "wrong number of warnings" );
ok( $warnings[0], qr/Convert::Binary::C not compiled with debugging support/ );
}
@warnings = ();
eval qq{
import Convert::Binary::C 'debug';
};
ok( $@, qr/^You must pass an even number of module arguments/ );
ok( scalar @warnings, 0, "unexpected warning(s)" );
|