diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-21 09:55:56 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-21 09:55:56 +0100 |
commit | e111f5cb7a21455df2c62eb65cd7b38aac0d834c (patch) | |
tree | 429d0f422e536d945a9d7c7c89ca1122a981fa2f /tests/ldebug.js | |
parent | 66826a03cd3215d1d25856a3d07d9d37be7fe602 (diff) | |
download | fengari-e111f5cb7a21455df2c62eb65cd7b38aac0d834c.tar.gz fengari-e111f5cb7a21455df2c62eb65cd7b38aac0d834c.tar.bz2 fengari-e111f5cb7a21455df2c62eb65cd7b38aac0d834c.zip |
luaG_concaterror, luaG_opinterror, luaG_tointerror
Diffstat (limited to 'tests/ldebug.js')
-rw-r--r-- | tests/ldebug.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/ldebug.js b/tests/ldebug.js index b627cf7..491b8ba 100644 --- a/tests/ldebug.js +++ b/tests/ldebug.js @@ -129,4 +129,88 @@ test('luaG_typeerror', function (t) { lapi.lua_tostring(L, -1).endsWith("attempt to index a boolean value (local 'a')"), "Correct error was thrown" ) +}); + + +test('luaG_concaterror', function (t) { + let luaCode = ` + return {} .. 'hello' + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + let bc = toByteCode(luaCode).dataView; + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lapi.lua_load(L, bc, "test-typeerror"); + + lapi.lua_pcall(L, 0, -1, 0); + + }, "JS Lua program ran without error"); + + t.ok( + lapi.lua_tostring(L, -1).endsWith("attempt to concatenate a table value"), + "Correct error was thrown" + ) +}); + + +test('luaG_opinterror', function (t) { + let luaCode = ` + return {} + 'hello' + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + let bc = toByteCode(luaCode).dataView; + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lapi.lua_load(L, bc, "test-typeerror"); + + lapi.lua_pcall(L, 0, -1, 0); + + }, "JS Lua program ran without error"); + + t.ok( + lapi.lua_tostring(L, -1).endsWith("attempt to perform arithmetic on a string value"), + "Correct error was thrown" + ) +}); + + +test('luaG_tointerror', function (t) { + let luaCode = ` + return 123.5 & 12 + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + let bc = toByteCode(luaCode).dataView; + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lapi.lua_load(L, bc, "test-typeerror"); + + lapi.lua_pcall(L, 0, -1, 0); + + }, "JS Lua program ran without error"); + + t.ok( + lapi.lua_tostring(L, -1).endsWith("number has no integer representation"), + "Correct error was thrown" + ) });
\ No newline at end of file |