Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
xaicron committed Aug 3, 2012
1 parent 657db8e commit 935620b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Win32/Unicode/File.pm
Expand Up @@ -4,8 +4,8 @@ use strict;
use warnings;
use 5.008003;
use Carp qw(croak);
use File::Basename qw/basename/;
use Scalar::Util qw/blessed/;
use File::Basename qw(basename);
use Scalar::Util qw(blessed);
use Exporter 'import';

use Win32::Unicode::Util;
Expand Down Expand Up @@ -651,7 +651,7 @@ sub flush {
}

sub sync {
_croakW('sync not implemented');
croak('sync not implemented');
}

sub autoflush {
Expand Down
61 changes: 61 additions & 0 deletions t/16_io_handle_like.t
@@ -0,0 +1,61 @@
use strict;
use warnings;
use utf8;
use lib 't/lib';
use Test::More;
use Test::Exception;
use Test::Win32::Unicode::Util;

use Win32::Unicode;

sub new_tmpfile {
my $fh = Win32::Unicode::File->new(w => 'foo') or die $!;
print $fh join q{}, map "$_\n" => qw/foo bar baz/;
return $fh->file_path;
}

sub new_read_fh {
my $file = new_tmpfile;
my $fh = Win32::Unicode::File->new(r => $file) or die $!;
}

subtest getline => sub {
safe_dir {
my $fh = new_read_fh;

dies_ok { $fh->getline('foo') };

my $lines = [];
while (my $line = $fh->getline) {
push @$lines, $line;
}
is_deeply $lines, [ map "$_\n" => qw/foo bar baz/ ];
};
};

subtest getlines => sub {
safe_dir {
my $fh = new_read_fh;

dies_ok { $fh->getlines };
dies_ok { $fh->getlines('foo') };

my $lines = [ $fh->getlines ];
is_deeply $lines, [ map "$_\n" => qw/foo bar baz/ ];
};
};

subtest 'getops / setpos' => sub {
safe_dir {
my $fh = new_read_fh;

dies_ok { $fh->getpos('foo') };
dies_ok { $fh->setpos };

is $fh->getpos, 0;
is $fh->setpos(4), 4;
is $fh->getpos, 4;
}
};

done_testing;

0 comments on commit 935620b

Please sign in to comment.