Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (23 sloc) 0.71 kb
use v6;
use Test;
plan 2;
# L<S32::IO/IO/"getc">
sub nonce () { return (".{$*PID}." ~ 1000.rand.Int) }
my $tmpfile = "temp-test" ~ nonce();
{
my $fh = open($tmpfile, :w) or die "Couldn't open \"$tmpfile\" for writing: $!\n";
$fh.print: "TestÄÖÜ\n\n0";
close $fh or die "Couldn't close \"$tmpfile\": $!\n";
}
{
my $fh = open $tmpfile or die "Couldn't open \"$tmpfile\" for reading: $!\n";
my @chars;
push @chars, $_ while defined($_ = getc $fh);
close $fh or die "Couldn't close \"$tmpfile\": $!\n";
is ~@chars, "T e s t Ä Ö Ü \n \n 0", "getc() works even for utf-8 input";
}
{
dies_ok { open('t').getc }, 'getc on a directory fails';
}
END { unlink $tmpfile }
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.