Change PerlIO::Scalar and Via to scalar and via.
[p5sagit/p5-mst-13.2.git] / lib / PerlIO / via / t / QuotedPrint.t
1 my $file = 'test.qp';
2
3 BEGIN {
4     if ($ENV{PERL_CORE}) {      
5         chdir 't' if -d 't';
6         @INC = '../lib';
7     }
8 }
9
10 use Test::More tests => 11;
11
12 BEGIN { use_ok('PerlIO::via::QuotedPrint') }
13
14 my $decoded = <<EOD;
15 This is a tést for quoted-printable text that has hàrdly any speçial characters
16 in it.
17 EOD
18
19 my $encoded = <<EOD;
20 This is a t=E9st for quoted-printable text that has h=E0rdly any spe=E7ial =
21 characters
22 in it.
23 EOD
24
25 # Create the encoded test-file
26
27 ok(
28  open( my $out,'>:via(PerlIO::via::QuotedPrint)', $file ),
29  "opening '$file' for writing"
30 );
31
32 ok( (print $out $decoded),              'print to file' );
33 ok( close( $out ),                      'closing encoding handle' );
34
35 # Check encoding without layers
36
37 {
38 local $/ = undef;
39 ok( open( my $test,$file ),             'opening without layer' );
40 is( $encoded,readline( $test ),         'check encoded content' );
41 ok( close( $test ),                     'close test handle' );
42 }
43
44 # Check decoding _with_ layers
45
46 ok(
47  open( my $in,'<:via(PerlIO::via::QuotedPrint)', $file ),
48  "opening '$file' for reading"
49 );
50 is( $decoded,join( '',<$in> ),          'check decoding' );
51 ok( close( $in ),                       'close decoding handle' );
52
53 # Remove whatever we created now
54
55 ok( unlink( $file ),                    "remove test file '$file'" );