This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
warnings for perlio + others
[perl5.git] / ext / PerlIO / t / via.t
CommitLineData
2b8740d8
JH
1#!./perl
2
99ef548b
PM
3use strict;
4use warnings;
5
2b8740d8
JH
6BEGIN {
7 chdir 't' if -d 't';
8 @INC = '../lib';
9 unless (find PerlIO::Layer 'perlio') {
10 print "1..0 # Skip: not perlio\n";
11 exit 0;
12 }
13}
14
15my $tmp = "via$$";
16
99ef548b
PM
17use Test::More tests => 11;
18
19my $fh;
20my $a = join("", map { chr } 0..255) x 10;
21my $b;
2b8740d8 22
99ef548b 23BEGIN { use_ok('MIME::QuotedPrint'); }
2b8740d8 24
99ef548b
PM
25ok( open($fh,">Via(MIME::QuotedPrint)", $tmp), 'open QuotedPrint for output');
26ok( (print $fh $a), "print to output file");
27ok( close($fh), 'close output file');
2b8740d8 28
99ef548b 29ok( open($fh,"<Via(MIME::QuotedPrint)", $tmp), 'open QuotedPrint for input');
2b8740d8 30{ local $/; $b = <$fh> }
99ef548b
PM
31ok( close($fh), "close input file");
32
33is($a, $b, 'compare original data with filtered version');
34
35
36{
37 my $warnings = '';
38 local $SIG{__WARN__} = sub { $warnings = join '', @_ };
39
40 use warnings 'layer';
41 ok( ! open($fh,">Via(Unknown::Module)", $tmp), 'open Via Unknown::Module will fail');
42 like( $warnings, qr/^Cannot find package 'Unknown::Module'/, 'warn about unknown package' );
2b8740d8 43
99ef548b
PM
44 $warnings = '';
45 no warnings 'layer';
46 ok( ! open($fh,">Via(Unknown::Module)", $tmp), 'open Via Unknown::Module will fail');
47 is( $warnings, "", "don't warn about unknown package" );
48}
2b8740d8
JH
49
50END {
51 1 while unlink $tmp;
52}