Skip to content

Commit 1db2692

Browse files
committed
Test slurp on $*ARGFILES passes through :bin and :enc args
Fixed in Rakudo in rakudo/rakudo@15f51a52bd
1 parent a8b70cc commit 1db2692

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

S16-filehandles/argfiles.t

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,62 @@ is $output, "True\n", 'Can change $*IN.nl-in and it has effect';
9292
is-deeply @lines, [<one two three one two>], '.lines with limit works across files';
9393
}
9494

95+
subtest ':bin and :enc get passed through in slurp' => {
96+
my ($file-bin, $fh-bin) = create-temporary-file 'bin';
97+
$fh-bin.print: "\x[10]\x[20]\x[30]";
98+
$fh-bin.close;
99+
100+
my ($file-enc, $fh-enc) = create-temporary-file 'enc';
101+
$fh-enc.write: Buf[uint8].new: 174; # char ® in Latin-1
102+
$fh-enc.close;
103+
104+
is_run say slurp :bin, :args[$file-bin], {
105+
:out("Buf[uint8]:0x<10 20 30>\n"),
106+
:err(''),
107+
:0status,
108+
}, 'slurp(:bin), 1 file';
109+
110+
is_run say slurp :bin, :args[$file-bin, $file-bin], {
111+
:out("Buf[uint8]:0x<10 20 30 10 20 30>\n"),
112+
:err(''),
113+
:0status,
114+
}, 'slurp(:bin), 2 files';
115+
116+
is_run $*ARGFILES.lines(0); say slurp :bin, :args[$file-bin], {
117+
:out("Buf[uint8]:0x<10 20 30>\n"),
118+
:err(''),
119+
:0status,
120+
}, 'slurp(:bin), $*ARGFILES filehandle already opened';
121+
122+
is_run say slurp :bin, "\x[10]\x[20]\x[30]", {
123+
:out("Buf[uint8]:0x<10 20 30>\n"),
124+
:err(''),
125+
:0status,
126+
}, 'slurp(:bin), STDIN';
127+
128+
is_run say slurp :enc<Latin-1>, :args[$file-enc], {
129+
:out("®\n"),
130+
:err(''),
131+
:0status,
132+
}, 'slurp(:enc<Latin-1>), 1 file';
133+
134+
is_run say slurp :enc<Latin-1>, :args[$file-enc, $file-enc], {
135+
:out("®®\n"),
136+
:err(''),
137+
:0status,
138+
}, 'slurp(:enc<Latin-1>), 2 files';
139+
140+
is_run $*ARGFILES.lines(0); say slurp :enc<Latin-1>, :args[$file-enc], {
141+
:out("®\n"),
142+
:err(''),
143+
:0status,
144+
}, 'slurp(:enc<Latin-1>), $*ARGFILES filehandle already opened';
145+
146+
is_run say slurp :enc<Latin-1>, "\x[AE]", {
147+
:out("\x[c2]\x[ae]\n"), # is_run sends input in UTF-8
148+
:err(''),
149+
:0status,
150+
}, 'slurp(:enc<Latin-1>), STDIN';
151+
}
152+
95153
$tmp-file-name.IO.unlink;

0 commit comments

Comments
 (0)