diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-08-23 16:08:53 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-08-23 16:08:53 -0300 |
| commit | 02060b7a37d88d4e92cf64a008c0651eae432c12 (patch) | |
| tree | 6640e82d6dc7fe3f8e1601b490ad33babac6d95e /testes | |
| parent | a1f77a234a053da46b06d5d4be00ffb30d3eb45b (diff) | |
| download | lua-02060b7a37d88d4e92cf64a008c0651eae432c12.tar.gz lua-02060b7a37d88d4e92cf64a008c0651eae432c12.tar.bz2 lua-02060b7a37d88d4e92cf64a008c0651eae432c12.zip | |
Simpler handling of Byte Order Mark (BOM)
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/main.lua | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/testes/main.lua b/testes/main.lua index 9def6386..9187420e 100644 --- a/testes/main.lua +++ b/testes/main.lua | |||
| @@ -94,6 +94,33 @@ RUN('echo "print(10)\nprint(2)\n" | lua > %s', out) | |||
| 94 | checkout("10\n2\n") | 94 | checkout("10\n2\n") |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | -- testing BOM | ||
| 98 | prepfile("\xEF\xBB\xBF") | ||
| 99 | RUN('lua %s > %s', prog, out) | ||
| 100 | checkout("") | ||
| 101 | |||
| 102 | prepfile("\xEF\xBB\xBFprint(3)") | ||
| 103 | RUN('lua %s > %s', prog, out) | ||
| 104 | checkout("3\n") | ||
| 105 | |||
| 106 | prepfile("\xEF\xBB\xBF# comment!!\nprint(3)") | ||
| 107 | RUN('lua %s > %s', prog, out) | ||
| 108 | checkout("3\n") | ||
| 109 | |||
| 110 | -- bad BOMs | ||
| 111 | prepfile("\xEF") | ||
| 112 | NoRun("unexpected symbol", 'lua %s > %s', prog, out) | ||
| 113 | |||
| 114 | prepfile("\xEF\xBB") | ||
| 115 | NoRun("unexpected symbol", 'lua %s > %s', prog, out) | ||
| 116 | |||
| 117 | prepfile("\xEFprint(3)") | ||
| 118 | NoRun("unexpected symbol", 'lua %s > %s', prog, out) | ||
| 119 | |||
| 120 | prepfile("\xEF\xBBprint(3)") | ||
| 121 | NoRun("unexpected symbol", 'lua %s > %s', prog, out) | ||
| 122 | |||
| 123 | |||
| 97 | -- test option '-' | 124 | -- test option '-' |
| 98 | RUN('echo "print(arg[1])" | lua - -h > %s', out) | 125 | RUN('echo "print(arg[1])" | lua - -h > %s', out) |
| 99 | checkout("-h\n") | 126 | checkout("-h\n") |
| @@ -385,12 +412,10 @@ checkprogout("101\n13\t22\n\n") | |||
| 385 | prepfile[[#comment in 1st line without \n at the end]] | 412 | prepfile[[#comment in 1st line without \n at the end]] |
| 386 | RUN('lua %s', prog) | 413 | RUN('lua %s', prog) |
| 387 | 414 | ||
| 388 | prepfile[[#test line number when file starts with comment line | 415 | -- first-line comment with binary file |
| 389 | debug = require"debug" | 416 | prepfile("#comment\n" .. string.dump(load("print(3)"))) |
| 390 | print(debug.getinfo(1).currentline) | ||
| 391 | ]] | ||
| 392 | RUN('lua %s > %s', prog, out) | 417 | RUN('lua %s > %s', prog, out) |
| 393 | checkprogout('3\n') | 418 | checkout('3\n') |
| 394 | 419 | ||
| 395 | -- close Lua with an open file | 420 | -- close Lua with an open file |
| 396 | prepfile(string.format([[io.output(%q); io.write('alo')]], out)) | 421 | prepfile(string.format([[io.output(%q); io.write('alo')]], out)) |
