Skip to content

Commit

Permalink
[io grant] Test IO::CatHandle.encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed May 27, 2017
1 parent 0479087 commit 71953e3
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion S32-io/io-cathandle.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,29 @@ subtest 'DESTROY method' => {
}

subtest 'encoding method' => {
plan 0;
plan 4;
is-deeply IO::CatHandle.new.encoding, 'utf8', 'default';
is-deeply IO::CatHandle.new(:encoding<utf8-c8>).encoding, 'utf8-c8',
'can change via .new';

subtest 'can change via .encoding while iterating through handles' => {
plan 3;

$_ = IO::CatHandle.new: make-files 'foo', '', Buf.new: 200;
.encoding: 'ascii';
is-deeply .readchars(3), 'foo', 'ascii';
.encoding: 'utf8';
is-deeply .readchars(1), '', 'utf8';
.encoding: 'utf8-c8';
is-deeply .readchars(1), Buf.new(200).decode('utf8-c8'), 'utf8-c8';
.close;
}

with IO::CatHandle.new {
.encoding: 'utf8-c8';
is-deeply .encoding, 'utf8-c8',
'can change via .encoding when no @handles are left';
}
}

subtest 'eof method' => {
Expand Down

0 comments on commit 71953e3

Please sign in to comment.