diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-21 09:31:15 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-21 09:31:15 +0100 |
commit | 66826a03cd3215d1d25856a3d07d9d37be7fe602 (patch) | |
tree | c439c109fce94473852250cc998c859f72dbe47c /tests/ldebug.js | |
parent | 23d15010edc905a3b7c123e85ef6d1960d3da039 (diff) | |
download | fengari-66826a03cd3215d1d25856a3d07d9d37be7fe602.tar.gz fengari-66826a03cd3215d1d25856a3d07d9d37be7fe602.tar.bz2 fengari-66826a03cd3215d1d25856a3d07d9d37be7fe602.zip |
luaG_typeerror
Diffstat (limited to 'tests/ldebug.js')
-rw-r--r-- | tests/ldebug.js | 94 |
1 files changed, 92 insertions, 2 deletions
diff --git a/tests/ldebug.js b/tests/ldebug.js index a6fa55f..b627cf7 100644 --- a/tests/ldebug.js +++ b/tests/ldebug.js @@ -21,7 +21,7 @@ test('luaG_typeerror', function (t) { return #a `, L; - t.plan(1); + t.plan(2); t.doesNotThrow(function () { @@ -38,5 +38,95 @@ test('luaG_typeerror', function (t) { }, "JS Lua program ran without error"); - console.log(lapi.lua_tostring(L, -1)); + t.ok( + lapi.lua_tostring(L, -1).endsWith("attempt to get length of a boolean value (local 'a')"), + "Correct error was thrown" + ) +}); + + +test('luaG_typeerror', function (t) { + let luaCode = ` + local a = true + return a.yo + `, 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 index a boolean value (local 'a')"), + "Correct error was thrown" + ) +}); + + +test('luaG_typeerror', function (t) { + let luaCode = ` + local a = true + return a.yo + `, 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 index a boolean value (local 'a')"), + "Correct error was thrown" + ) +}); + + +test('luaG_typeerror', function (t) { + let luaCode = ` + local a = true + a.yo = 1 + `, 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 index a boolean value (local 'a')"), + "Correct error was thrown" + ) });
\ No newline at end of file |