9 unless (find PerlIO::Layer 'perlio') {
10 print "1..0 # Skip: not perlio\n";
17 use Test::More tests => 16;
20 my $a = join("", map { chr } 0..255) x 10;
23 BEGIN { use_ok('MIME::QuotedPrint'); }
25 ok( !open($fh,"<Via(MIME::QuotedPrint)", $tmp), 'open QuotedPrint fails');
26 ok( open($fh,">Via(MIME::QuotedPrint)", $tmp), 'open QuotedPrint for output');
27 ok( (print $fh $a), "print to output file");
28 ok( close($fh), 'close output file');
30 ok( open($fh,"<Via(MIME::QuotedPrint)", $tmp), 'open QuotedPrint for input');
31 { local $/; $b = <$fh> }
32 ok( close($fh), "close input file");
34 is($a, $b, 'compare original data with filtered version');
39 local $SIG{__WARN__} = sub { $warnings = join '', @_ };
43 # Find fd number we should be using
44 my $fd = open($fh,">$tmp") && fileno($fh);
48 ok( ! open($fh,">Via(Unknown::Module)", $tmp), 'open Via Unknown::Module will fail');
49 like( $warnings, qr/^Cannot find package 'Unknown::Module'/, 'warn about unknown package' );
51 # Now open normally again to see if we get right fileno
52 my $fd2 = open($fh,"<$tmp") && fileno($fh);
53 is($fd2,$fd,"Wrong fd number after failed open");
57 is($data,"Hello\n","File clobbered by failed open");
65 ok( ! open($fh,">Via(Unknown::Module)", $tmp), 'open Via Unknown::Module will fail');
66 is( $warnings, "", "don't warn about unknown package" );
70 sub Foo::PUSHED { $obj = shift; -1; }
71 sub PerlIO::Via::Bar::PUSHED { $obj = shift; -1; }
72 open $fh, '<:Via(Foo)', "foo";
73 is( $obj, 'Foo', 'search for package Foo' );
74 open $fh, '<:Via(Bar)', "bar";
75 is( $obj, 'PerlIO::Via::Bar', 'search for package PerlIO::Via::Bar' );