diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-05-13 20:32:47 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-05-13 20:32:47 +0200 |
commit | 29445c09adc02dcf2f904bdb589bd7cb2b2931b5 (patch) | |
tree | 364a60c972da8eeb709b7b5e726510f3a8e1480f /tests/test-suite/literals.js | |
parent | ac1b5edf6c6026a9f097223dff45e0435fe946ef (diff) | |
download | fengari-29445c09adc02dcf2f904bdb589bd7cb2b2931b5.tar.gz fengari-29445c09adc02dcf2f904bdb589bd7cb2b2931b5.tar.bz2 fengari-29445c09adc02dcf2f904bdb589bd7cb2b2931b5.zip |
Removed useless save(0) in llex
Diffstat (limited to 'tests/test-suite/literals.js')
-rw-r--r-- | tests/test-suite/literals.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/test-suite/literals.js b/tests/test-suite/literals.js index fa11959..8dac1fa 100644 --- a/tests/test-suite/literals.js +++ b/tests/test-suite/literals.js @@ -184,3 +184,68 @@ test("[test-suite] events: UTF-8 sequences", function (t) { }); + +test("[test-suite] events: Error in escape sequences", function (t) { + let luaCode = ` + local function lexerror (s, err) + local st, msg = load('return ' .. s, '') + if err ~= '<eof>' then err = err .. "'" end + assert(not st and string.find(msg, "near .-" .. err)) + end + + lexerror([["abc\\x"]], [[\\x"]]) + lexerror([["abc\\x]], [[\\x]]) + lexerror([["\\x]], [[\\x]]) + lexerror([["\\x5"]], [[\\x5"]]) + lexerror([["\\x5]], [[\\x5]]) + lexerror([["\\xr"]], [[\\xr]]) + lexerror([["\\xr]], [[\\xr]]) + lexerror([["\\x.]], [[\\x.]]) + lexerror([["\\x8%"]], [[\\x8%%]]) + lexerror([["\\xAG]], [[\\xAG]]) + lexerror([["\\g"]], [[\\g]]) + lexerror([["\\g]], [[\\g]]) + lexerror([["\\."]], [[\\%.]]) + + lexerror([["\\999"]], [[\\999"]]) + lexerror([["xyz\\300"]], [[\\300"]]) + lexerror([[" \\256"]], [[\\256"]]) + + -- errors in UTF-8 sequences + lexerror([["abc\\u{110000}"]], [[abc\\u{110000]]) -- too large + lexerror([["abc\\u11r"]], [[abc\\u1]]) -- missing '{' + lexerror([["abc\\u"]], [[abc\\u"]]) -- missing '{' + lexerror([["abc\\u{11r"]], [[abc\\u{11r]]) -- missing '}' + lexerror([["abc\\u{11"]], [[abc\\u{11"]]) -- missing '}' + lexerror([["abc\\u{11]], [[abc\\u{11]]) -- missing '}' + lexerror([["abc\\u{r"]], [[abc\\u{r]]) -- no digits + + -- unfinished strings + lexerror("[=[alo]]", "<eof>") + lexerror("[=[alo]=", "<eof>") + lexerror("[=[alo]", "<eof>") + lexerror("'alo", "<eof>") + lexerror("'alo \\\\z \\n\\n", "<eof>") + lexerror("'alo \\\\z", "<eof>") + lexerror([['alo \\98]], "<eof>") + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + L = lauxlib.luaL_newstate(); + + lualib.luaL_openlibs(L); + + lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + + }, "Lua program loaded without error"); + + t.doesNotThrow(function () { + + lua.lua_call(L, 0, -1); + + }, "Lua program ran without error"); + +});
\ No newline at end of file |