blob: a6fa55f1275b1f6eecb9a1a866601824a7f25b09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/*jshint esversion: 6 */
"use strict";
const test = require('tape');
const beautify = require('js-beautify').js_beautify;
const tests = require("./tests.js");
const getState = tests.getState;
const toByteCode = tests.toByteCode;
const lvm = require("../src/lvm.js");
const ldo = require("../src/ldo.js");
const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
test('luaG_typeerror', function (t) {
let luaCode = `
local a = true
return #a
`, L;
t.plan(1);
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");
console.log(lapi.lua_tostring(L, -1));
});
|