@@ -92,4 +92,62 @@ is $output, "True\n", 'Can change $*IN.nl-in and it has effect';
92
92
is-deeply @ lines , [<one two three one two >], ' .lines with limit works across files' ;
93
93
}
94
94
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
+ : 0 status,
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
+ : 0 status,
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
+ : 0 status,
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
+ : 0 status,
126
+ }, ' slurp(:bin), STDIN' ;
127
+
128
+ is_run 「 say slurp :enc<Latin-1>」 , : args[$ file-enc ], {
129
+ : out(" ®\n " ),
130
+ : err(' ' ),
131
+ : 0 status,
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
+ : 0 status,
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
+ : 0 status,
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
+ : 0 status,
150
+ }, ' slurp(:enc<Latin-1>), STDIN' ;
151
+ }
152
+
95
153
$ tmp-file-name . IO . unlink ;
0 commit comments