Created
August 31, 2015 18:04
-
-
Save jberger/2d8e7767b1bd470c8551 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojo::Base -strict; | |
use Test::More; | |
use Mojo::Util qw/slurp spurt/; | |
package My::Handle { | |
use parent 'IO::File'; | |
use overload '-X' => sub { | |
my ($self, $op) = @_; | |
if ($op eq 's') { return 0 } | |
die "-$op unimplemented"; | |
}; | |
} | |
use File::Temp (); | |
my $tmp = File::Temp->new; | |
spurt 'lalala' => $tmp->filename; | |
my $h = My::Handle->new; | |
$h->open($tmp->filename, '<'); | |
is -s($h), 0, 'correct mock size'; | |
BEGIN { *CORE::GLOBAL::open = sub { $tmp } } | |
is slurp($tmp->filename), 'lalala', 'correct content'; | |
done_testing; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment