summaryrefslogtreecommitdiff
path: root/testes/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/main.lua')
-rw-r--r--testes/main.lua35
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)
checkout("10\n2\n")
+-- testing BOM
+prepfile("\xEF\xBB\xBF")
+RUN('lua %s > %s', prog, out)
+checkout("")
+
+prepfile("\xEF\xBB\xBFprint(3)")
+RUN('lua %s > %s', prog, out)
+checkout("3\n")
+
+prepfile("\xEF\xBB\xBF# comment!!\nprint(3)")
+RUN('lua %s > %s', prog, out)
+checkout("3\n")
+
+-- bad BOMs
+prepfile("\xEF")
+NoRun("unexpected symbol", 'lua %s > %s', prog, out)
+
+prepfile("\xEF\xBB")
+NoRun("unexpected symbol", 'lua %s > %s', prog, out)
+
+prepfile("\xEFprint(3)")
+NoRun("unexpected symbol", 'lua %s > %s', prog, out)
+
+prepfile("\xEF\xBBprint(3)")
+NoRun("unexpected symbol", 'lua %s > %s', prog, out)
+
+
-- test option '-'
RUN('echo "print(arg[1])" | lua - -h > %s', out)
checkout("-h\n")
@@ -385,12 +412,10 @@ checkprogout("101\n13\t22\n\n")
prepfile[[#comment in 1st line without \n at the end]]
RUN('lua %s', prog)
-prepfile[[#test line number when file starts with comment line
-debug = require"debug"
-print(debug.getinfo(1).currentline)
-]]
+-- first-line comment with binary file
+prepfile("#comment\n" .. string.dump(load("print(3)")))
RUN('lua %s > %s', prog, out)
-checkprogout('3\n')
+checkout('3\n')
-- close Lua with an open file
prepfile(string.format([[io.output(%q); io.write('alo')]], out))