From a39f24f204a15cb4587e75b38424952fe444d9d2 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 11 Jan 2018 23:33:34 +1100 Subject: Move fengari specific things to src/fengaricore.js String manipulation functions now get exposed on 'fengari' object itself at top level --- tests/test-suite/calls.js | 68 +++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'tests/test-suite/calls.js') diff --git a/tests/test-suite/calls.js b/tests/test-suite/calls.js index fdd5eac..2044e5c 100644 --- a/tests/test-suite/calls.js +++ b/tests/test-suite/calls.js @@ -5,7 +5,7 @@ const test = require('tape'); const lua = require('../../src/lua.js'); const lauxlib = require('../../src/lauxlib.js'); const lualib = require('../../src/lualib.js'); - +const {to_luastring} = require("../../src/fengaricore.js"); test("[test-suite] calls: test 'type'", function (t) { let luaCode = ` @@ -22,7 +22,7 @@ test("[test-suite] calls: test 'type'", function (t) { assert(type(f) == 'function') assert(not pcall(type)) `, L; - + t.plan(2); t.doesNotThrow(function () { @@ -31,7 +31,7 @@ test("[test-suite] calls: test 'type'", function (t) { lualib.luaL_openlibs(L); - lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + lauxlib.luaL_loadstring(L, to_luastring(luaCode)); }, "Lua program loaded without error"); @@ -56,11 +56,11 @@ test("[test-suite] calls: test error in 'print'", function (t) { _ENV.tostring = function () return {} end local st, msg = pcall(print, 1) assert(st == false and string.find(msg, "must return a string")) - + _ENV.tostring = tostring end `, L; - + t.plan(2); t.doesNotThrow(function () { @@ -69,7 +69,7 @@ test("[test-suite] calls: test error in 'print'", function (t) { lualib.luaL_openlibs(L); - lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + lauxlib.luaL_loadstring(L, to_luastring(luaCode)); }, "Lua program loaded without error"); @@ -96,7 +96,7 @@ test("[test-suite] calls: testing local-function recursion", function (t) { end assert(fact == false) `, L; - + t.plan(2); t.doesNotThrow(function () { @@ -105,7 +105,7 @@ test("[test-suite] calls: testing local-function recursion", function (t) { lualib.luaL_openlibs(L); - lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + lauxlib.luaL_loadstring(L, to_luastring(luaCode)); }, "Lua program loaded without error"); @@ -203,7 +203,7 @@ test("[test-suite] calls: testing declarations", function (t) { (function (x) a=x end)(23) assert(a == 23 and (function (x) return x*2 end)(20) == 40) `, L; - + t.plan(2); t.doesNotThrow(function () { @@ -212,7 +212,7 @@ test("[test-suite] calls: testing declarations", function (t) { lualib.luaL_openlibs(L); - lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + lauxlib.luaL_loadstring(L, to_luastring(luaCode)); }, "Lua program loaded without error"); @@ -261,7 +261,7 @@ test("[test-suite] calls: testing closures", function (t) { Z, F, f = nil `, L; - + t.plan(2); t.doesNotThrow(function () { @@ -270,7 +270,7 @@ test("[test-suite] calls: testing closures", function (t) { lualib.luaL_openlibs(L); - lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + lauxlib.luaL_loadstring(L, to_luastring(luaCode)); }, "Lua program loaded without error"); @@ -319,7 +319,7 @@ test("[test-suite] calls: testing multiple returns", function (t) { a = ret2{ unlpack{1,2,3}, unlpack{3,2,1}, unlpack{"a", "b"}} assert(a[1] == 1 and a[2] == 3 and a[3] == "a" and a[4] == "b") `, L; - + t.plan(2); t.doesNotThrow(function () { @@ -328,7 +328,7 @@ test("[test-suite] calls: testing multiple returns", function (t) { lualib.luaL_openlibs(L); - lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + lauxlib.luaL_loadstring(L, to_luastring(luaCode)); }, "Lua program loaded without error"); @@ -348,7 +348,7 @@ test("[test-suite] calls: testing calls with 'incorrect' arguments", function (t assert(math.sin(1,2) == math.sin(1)) table.sort({10,9,8,4,19,23,0,0}, function (a,b) return a