Skip to content

Commit 60a7a88

Browse files
committed
Test IO::Handle.open with '-' paths sets encoding
RT#131503: https://rt.perl.org/Ticket/Display.html?id=131503 Rakudo fix: rakudo/rakudo@90d129de8e7ae62
1 parent 6a78d5d commit 60a7a88

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

S32-io/open.t

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use lib <t/spec/packages>;
33
use Test;
44
use Test::Util;
55

6-
plan 62;
6+
plan 63;
77

88
my \PATH = 't-S32-io-open.tmp';
99
my \PATH-RX = rx/'t-S32-io-open.tmp'/;
@@ -382,4 +382,23 @@ subtest '.open uses attributes by default' => {
382382
$fh.close;
383383
}
384384

385+
# RT #131503
386+
subtest '.open with "-" as path uses STDIN/STDOUT' => {
387+
plan 2;
388+
subtest 'STDOUT' => { plan 3;
389+
temp $*OUT = make-temp-file.open: :w;
390+
is-deeply '-'.IO.open(:bin, :w), $*OUT, 'returned handle is STDOUT';
391+
is-deeply $*OUT.encoding, Nil, 'set binary mode';
392+
'-'.IO.open: :enc<utf8-c8>, :w;
393+
is-deeply $*OUT.encoding, 'utf8-c8', 'changed encoding';
394+
}
395+
subtest 'STDIN' => { plan 3;
396+
temp $*IN = make-temp-file(:content<meows>).open;
397+
is-deeply '-'.IO.open(:bin), $*IN, 'returned handle is STDIN';
398+
is-deeply $*IN.encoding, Nil, 'set binary mode';
399+
'-'.IO.open: :enc<utf8-c8>;
400+
is-deeply $*IN.encoding, 'utf8-c8', 'changed encoding';
401+
}
402+
}
403+
385404
# vim: ft=perl6

S32-io/slurp.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use lib <t/spec/packages>;
33
use Test;
44
use Test::Util;
55

6-
plan 18;
6+
plan 19;
77

88
# older: L<S16/"Unfiled"/"=item IO.slurp">
99
# old: L<S32::IO/IO::FileNode/slurp>
@@ -115,4 +115,8 @@ subtest '&slurp(IO::Handle)' => {
115115
}
116116
}
117117

118+
# RT #131503
119+
is_run '-'.IO.slurp.print, 'meows', {:out<meows>, :err(''), :0status},
120+
'can .slurp from "-".IO path';
121+
118122
# vim: ft=perl6

0 commit comments

Comments
 (0)