Simpler handling of Byte Order Mark (BOM)
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user