4 @INC = ("../lib", "lib");
17 # use Test::NoWarnings, if available
20 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
22 plan tests => 29 + $extra ;
25 use_ok('Compress::Zlib::Common');
27 use_ok('Compress::Zlib::ParseParameters');
29 # use_ok('Compress::Zlib', 2) ;
31 # use_ok('IO::Compress::Gzip', qw($GzipError)) ;
32 # use_ok('IO::Uncompress::Gunzip', qw($GunzipError)) ;
34 # use_ok('IO::Compress::Deflate', qw($DeflateError)) ;
35 # use_ok('IO::Uncompress::Inflate', qw($InflateError)) ;
37 # use_ok('IO::Compress::RawDeflate', qw($RawDeflateError)) ;
38 # use_ok('IO::Uncompress::RawInflate', qw($RawInflateError)) ;
42 # Compress::Zlib::Common;
44 sub My::testParseParameters()
46 eval { ParseParameters(1, {}, 1) ; };
47 like $@, mkErr(': Expected even number of parameters, got 1'),
48 "Trap odd number of params";
50 eval { ParseParameters(1, {}, undef) ; };
51 like $@, mkErr(': Expected even number of parameters, got 1'),
52 "Trap odd number of params";
54 eval { ParseParameters(1, {}, []) ; };
55 like $@, mkErr(': Expected even number of parameters, got 1'),
56 "Trap odd number of params";
58 eval { ParseParameters(1, {'Fred' => [Parse_unsigned, 0]}, Fred => undef) ; };
59 like $@, mkErr("Parameter 'Fred' must be an unsigned int, got undef"),
60 "wanted unsigned, got undef";
62 eval { ParseParameters(1, {'Fred' => [Parse_signed, 0]}, Fred => undef) ; };
63 like $@, mkErr("Parameter 'Fred' must be a signed int, got undef"),
64 "wanted signed, got undef";
66 eval { ParseParameters(1, {'Fred' => [Parse_signed, 0]}, Fred => 'abc') ; };
67 like $@, mkErr("Parameter 'Fred' must be a signed int, got 'abc'"),
68 "wanted signed, got 'abc'";
70 my $got = ParseParameters(1, {'Fred' => [Parse_store_ref, 0]}, Fred => 'abc') ;
71 is ${ $got->value('Fred') }, "abc", "Parse_store_ref" ;
73 $got = ParseParameters(1, {'Fred' => [0x1000000, 0]}, Fred => 'abc') ;
74 is $got->value('Fred'), "abc", "other" ;
78 My::testParseParameters();
83 ok isaFilename("abc"), "'abc' isaFilename";
85 ok ! isaFilename(undef), "undef ! isaFilename";
86 ok ! isaFilename([]), "[] ! isaFilename";
87 $main::X = 1; $main::X = $main::X ;
88 ok ! isaFilename(*X), "glob ! isaFilename";
95 my $lex = new LexFile($out_file) ;
96 open FH, ">$out_file" ;
97 is whatIsInput(*FH), 'handle', "Match filehandle" ;
101 is whatIsInput($stdin), 'handle', "Match '-' as stdin";
102 #is $stdin, \*STDIN, "'-' changed to *STDIN";
103 #isa_ok $stdin, 'IO::File', "'-' changed to IO::File";
104 is whatIsInput("abc"), 'filename', "Match filename";
105 is whatIsInput(\"abc"), 'buffer', "Match buffer";
106 is whatIsInput(sub { 1 }, 1), 'code', "Match code";
107 is whatIsInput(sub { 1 }), '' , "Don't match code";
112 title "whatIsOutput" ;
114 my $out_file = "abc";
115 my $lex = new LexFile($out_file) ;
116 open FH, ">$out_file" ;
117 is whatIsOutput(*FH), 'handle', "Match filehandle" ;
121 is whatIsOutput($stdout), 'handle', "Match '-' as stdout";
122 #is $stdout, \*STDOUT, "'-' changed to *STDOUT";
123 #isa_ok $stdout, 'IO::File', "'-' changed to IO::File";
124 is whatIsOutput("abc"), 'filename', "Match filename";
125 is whatIsOutput(\"abc"), 'buffer', "Match buffer";
126 is whatIsOutput(sub { 1 }, 1), 'code', "Match code";
127 is whatIsOutput(sub { 1 }), '' , "Don't match code";