うーむ
1 use strict;2 use warnings;
3
4 use Test::More tests => 3;
5 use Test::Exception;
6 use Data::Dumper;
7
8 lives_ok { open( my $fh, "<", \"ABCD") or die $!; } 'test1';
9 lives_ok { open( my $fh, "<:raw", \"ABCD") or die $!; } 'test2';
10 lives_ok { open( my $fh, "<", \"ABCD") or die $!; binmode $fh; } 'test2';
11
12 {
13 open( my $fh, "<", \"ABCD\015\012") or die $!;
14 diag Dumper [PerlIO::get_layers($fh)];
15 diag length( do { local $/; readline $fh; } );
16 }
17
18 {
19 open( my $fh, "<", \"ABCD\015\012") or die $!;
20 binmode $fh;
21 diag Dumper [PerlIO::get_layers($fh)];
22 diag length( do { local $/; readline $fh; } );
23 }
24
25 {
26 open( my $fh, "<", \"ABCD\015\012") or die $!;
27 binmode $fh, ":crlf";
28 diag Dumper [PerlIO::get_layers($fh)];
29 diag length( do { local $/; readline $fh; } );
30 }
31
32 __END__
33 $ prove.bat -I extlib -v b.pl
34 b.......
35 1..3
36 ok 1 - test1
37
38 # Failed test 'test2'
39 # at b.pl line 9.
40 # died: No such file or directory at b.pl line 9.
41 # $VAR1 = [
42 # 'scalar'
43 # ];
44 # 6
45 # $VAR1 = [
46 # 'scalar'
47 # ];
48 # 6
49 # $VAR1 = [
50 # 'scalar',
51 # 'crlf'
52 # ];
53 # 5
54 # Looks like you failed 1 test of 3.
55 not ok 2 - test2
56 ok 3 - test2
57 Dubious, test returned 1 (wstat 256, 0x100)
58 Failed 1/3 subtests
59
60 Test Summary Report
61 -------------------
62 b.pl (Wstat: 256 Tests: 3 Failed: 1)
63 Failed test number(s): 2
64 Non-zero exit status: 1
65 Files=1, Tests=3, 0 wallclock secs ( 0.01 usr + 0.02 sys = 0.03 CPU)
66 Result: FAIL
コメントする