3 BEGIN { chdir 't' if -d 't'; }
7 use Test::More tests => 9;
9 my $Class = 'IO::File';
10 my $All_Chars = join '', "\r\n", map( chr, 1..255 ), "zzz\n\r";
12 my $Expect = quotemeta $All_Chars;
15 can_ok( $Class, "binmode" );
17 ### file the file with binary data;
18 ### use standard open to make sure we can compare binmodes
21 open $tmp, ">$File" or die "Could not open '$File': $!";
23 print $tmp $All_Chars;
27 ### now read in the file, once without binmode, once with.
28 ### without binmode should fail at least on win32...
29 if( $^O =~ /MSWin32/ ) {
32 isa_ok( $fh, $Class );
33 ok( $fh->open($File), " Opened '$File'" );
35 my $cont = do { local $/; <$fh> };
36 unlike( $cont, qr/$Expect/, " Content match fails without binmode" );
39 ### now with binmode, it must pass
40 { my $fh = $Class->new;
42 isa_ok( $fh, $Class );
43 ok( $fh->open($File), " Opened '$File' $!" );
44 ok( $fh->binmode, " binmode enabled" );
46 my $cont = do { local $/; <$fh> };
47 like( $cont, qr/$Expect/, " Content match passes with binmode" );