Skip to content

Commit

Permalink
Move the block with manual encoding up as a subtest
Browse files Browse the repository at this point in the history
  • Loading branch information
genio committed Jul 29, 2023
1 parent 64a5643 commit 00da986
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions t/mojo/file.t
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,18 @@ subtest 'I/O with encoding' => sub {
is $file->slurp('UTF-8'), '♥1', 'right content';
is decode('UTF-8', $file->slurp()), '♥1', 'right content';
is $file->spew('works too!')->slurp, 'works too!', 'right content';

subtest 'I/O with manual encoding' => sub {
$file->spew(encode('UTF-8', '♥1'));
is $file->slurp('UTF-8'), '♥1', 'right content';
is decode('UTF-8', $file->slurp()), '♥1', 'right content';
};

{
local $@;
eval { $file->spew('♥1') };
like $@, qr/Wide character/, 'right error';
}
};

subtest 'I/O with manual encoding' => sub {
my $dir = tempdir;
my $file = $dir->child('test.txt')->spew(encode('UTF-8', '♥1'));
is $file->slurp('UTF-8'), '♥1', 'right content';
is decode('UTF-8', $file->slurp()), '♥1', 'right content';
};

done_testing();

0 comments on commit 00da986

Please sign in to comment.