@@ -276,6 +276,61 @@ if system/platform = 'Windows [
276
276
--assert "a^/ b^/ c" = read /string %units/files/issue-622.txt
277
277
delete %units/files/issue-622.txt
278
278
279
+ --test-- "read write CRLF conversion"
280
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/2586
281
+ ;; In these tests are used #"a" and #"á" to have internally plain and wide strings
282
+ ;; write/binary keeps the linefeeds without modifications
283
+ --assert #{ 0A } = read write /binary %tmp next "a^/ "
284
+ --assert #{ 0A } = read write /binary %tmp next "á^/ "
285
+ --assert #{ 0D0A } = read write /binary %tmp next "a^M^/ "
286
+ --assert #{ 0D0A } = read write /binary %tmp next "á^M^/ "
287
+ --assert #{ 0D0D0A } = read write /binary %tmp next "a^M^M^/ "
288
+ --assert #{ 0D0D0A } = read write /binary %tmp next "á^M^M^/ "
289
+ --assert #{ 0D0A0A } = read write /binary %tmp next "a^M^/^/ "
290
+ --assert #{ 0D0A0A } = read write /binary %tmp next "á^M^/^/ "
291
+ ;; it is possible to get the original string using implicit conversion
292
+ --assert "a^/ " = to string! read write /binary %tmp "a^/ "
293
+ --assert "á^/ " = to string! read write /binary %tmp "á^/ "
294
+ --assert "a^M^/ " = to string! read write /binary %tmp "a^M^/ "
295
+ --assert "á^M^/ " = to string! read write /binary %tmp "á^M^/ "
296
+ --assert "a^M^M^/ " = to string! read write /binary %tmp "a^M^M^/ "
297
+ --assert "á^M^M^/ " = to string! read write /binary %tmp "á^M^M^/ "
298
+ --assert "a^M^/^/ " = to string! read write /binary %tmp "a^M^/^/ "
299
+ --assert "á^M^/^/ " = to string! read write /binary %tmp "á^M^/^/ "
300
+ either system/platform = 'Windows [
301
+ ;; on Windows by default write converts LF to CRLF (if the input is string!)
302
+ --assert #{ 0D0A } = read write %tmp next "a^/ "
303
+ --assert #{ 0D0A } = read write %tmp next "á^/ "
304
+ ;; when there is already CRLF, if does not write it like CRCRLF!
305
+ --assert #{ 0D0A } = read write %tmp next "a^M^/ "
306
+ --assert #{ 0D0A } = read write %tmp next "á^M^/ "
307
+ --assert #{ 0D0D0A } = read write %tmp next "a^M^M^/ "
308
+ --assert #{ 0D0D0A } = read write %tmp next "á^M^M^/ "
309
+ --assert #{ 0D0A0D0A } = read write %tmp next "a^M^/^/ "
310
+ --assert #{ 0D0A0D0A } = read write %tmp next "á^M^/^/ "
311
+ ][
312
+ ;; on all other platforms it does no modifications!
313
+ --assert #{ 0A } = read write %tmp next "a^/ "
314
+ --assert #{ 0A } = read write %tmp next "á^/ "
315
+ --assert #{ 0D0A } = read write %tmp next "a^M^/ "
316
+ --assert #{ 0D0A } = read write %tmp next "á^M^/ "
317
+ --assert #{ 0D0D0A } = read write %tmp next "a^M^M^/ "
318
+ --assert #{ 0D0D0A } = read write %tmp next "á^M^M^/ "
319
+ --assert #{ 0D0A0A } = read write %tmp next "a^M^/^/ "
320
+ --assert #{ 0D0A0A } = read write %tmp next "á^M^/^/ "
321
+ ]
322
+ ;; read/string converts CRLF (or plain CR) to LF
323
+ --assert "^/ " = read /string write /binary %tmp next "a^/ "
324
+ --assert "^/ " = read /string write /binary %tmp next "á^/ "
325
+ --assert "^/ " = read /string write /binary %tmp next "a^M "
326
+ --assert "^/ " = read /string write /binary %tmp next "á^M "
327
+ --assert "^/ " = read /string write /binary %tmp next "a^M^/ "
328
+ --assert "^/ " = read /string write /binary %tmp next "á^M^/ "
329
+ --assert "^/^/ " = read /string write /binary %tmp next "a^M^M^/ "
330
+ --assert "^/^/ " = read /string write /binary %tmp next "á^M^M^/ "
331
+ --assert "^/^/ " = read /string write /binary %tmp next "a^M^/^/ "
332
+ --assert "^/^/ " = read /string write /binary %tmp next "á^M^/^/ "
333
+
279
334
280
335
--test-- "write file result - wish/2337"
281
336
;@@ https://github.com/Oldes/Rebol-issues/issues/2337
0 commit comments