deleted
[urisagit/Perl-Docs.git] / t / binmode.t
CommitLineData
6290dc09 1#!/usr/local/bin/perl -w
2
3use strict ;
4use Test::More ;
5use Carp ;
6use File::Slurp ;
7
8if ( $] < 5.008001 ) {
9 plan skip_all => 'Older Perl lacking unicode support' ;
10 exit ;
11}
12
13plan tests => 2 ;
14
15my $mode = ':utf8' ;
16
17my $orig_text = "\x{20ac}\n" ;
18my $unicode_length = length $orig_text ;
19
20my $control_file = "control.$mode" ;
21my $slurp_file = "slurp.$mode" ;
22
23open( my $fh, ">$mode", $control_file ) or
24 die "cannot create control unicode file '$control_file' $!" ;
25print $fh $orig_text ;
26close $fh ;
27
28my $slurp_utf = read_file( $control_file, binmode => $mode ) ;
29ok( $slurp_utf eq $orig_text, "read_file of $mode file" ) ;
30
31# my $slurp_utf_length = length $slurp_utf ;
32# my $slurp_text = read_file( $control_file ) ;
33# my $slurp_text_length = length $slurp_text ;
34# print "LEN UTF $slurp_utf_length TXT $slurp_text_length\n" ;
35
36write_file( $slurp_file, {binmode => $mode}, $orig_text ) ;
37
38open( $fh, "<$mode", $slurp_file ) or
39 die "cannot open slurp test file '$slurp_file' $!" ;
40my $read_length = read( $fh, my $utf_text, $unicode_length ) ;
41close $fh ;
42
43ok( $utf_text eq $orig_text, "write_file of $mode file" ) ;
44
45unlink( $control_file, $slurp_file ) ;