summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-01 10:23:32 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-01 10:56:03 +0100
commitae8b95ee9c3871f506b20c74367fdc9e8cb098e2 (patch)
tree6348ab52aad93905af66196f5d071628ac60adb5 /tests
parent74dda64eab7951da520dc451a1f3bbb8c7d62706 (diff)
downloadfengari-ae8b95ee9c3871f506b20c74367fdc9e8cb098e2.tar.gz
fengari-ae8b95ee9c3871f506b20c74367fdc9e8cb098e2.tar.bz2
fengari-ae8b95ee9c3871f506b20c74367fdc9e8cb098e2.zip
lua_load will load both binary and text
Diffstat (limited to 'tests')
-rw-r--r--tests/lapi.js1
-rw-r--r--tests/lbaselib.js1
-rw-r--r--tests/lcorolib.js1
-rw-r--r--tests/ldebug.js1
-rw-r--r--tests/llex.js1
-rw-r--r--tests/lmathlib.js1
-rw-r--r--tests/load.js68
-rw-r--r--tests/ltablib.js1
-rw-r--r--tests/ltm.js1
-rw-r--r--tests/lvm.js1
-rw-r--r--tests/tests.js1
11 files changed, 68 insertions, 10 deletions
diff --git a/tests/lapi.js b/tests/lapi.js
index 30366d5..6761425 100644
--- a/tests/lapi.js
+++ b/tests/lapi.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
index be5cdad..72a2f15 100644
--- a/tests/lbaselib.js
+++ b/tests/lbaselib.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/lcorolib.js b/tests/lcorolib.js
index 78024dd..022cda6 100644
--- a/tests/lcorolib.js
+++ b/tests/lcorolib.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/ldebug.js b/tests/ldebug.js
index 491b8ba..45194e9 100644
--- a/tests/ldebug.js
+++ b/tests/ldebug.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/llex.js b/tests/llex.js
index 1457af3..8b69acc 100644
--- a/tests/llex.js
+++ b/tests/llex.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/lmathlib.js b/tests/lmathlib.js
index ba6853c..48ae1a2 100644
--- a/tests/lmathlib.js
+++ b/tests/lmathlib.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/load.js b/tests/load.js
new file mode 100644
index 0000000..4df3f6a
--- /dev/null
+++ b/tests/load.js
@@ -0,0 +1,68 @@
+"use strict";
+
+const test = require('tape');
+const beautify = require('js-beautify').js_beautify;
+
+const tests = require("./tests.js");
+const toByteCode = tests.toByteCode;
+
+const lapi = require("../src/lapi.js");
+const lauxlib = require("../src/lauxlib.js");
+const linit = require('../src/linit.js');
+
+test('lua_load, binary mode', function (t) {
+ let luaCode = `
+ return "hello world"
+ `, L;
+
+ t.plan(2);
+
+ t.doesNotThrow(function () {
+
+ let bc = toByteCode(luaCode).dataView;
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, null, bc, "test-math", "binary");
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_tostring(L, -1),
+ "hello world",
+ "Correct element(s) on the stack"
+ );
+
+});
+
+
+test('lua_load, text mode', function (t) {
+ let luaCode = `
+ return "hello world"
+ `, L;
+
+ t.plan(2);
+
+ // t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, null, luaCode, "test-math", "text");
+
+ lapi.lua_call(L, 0, -1);
+
+ // }, "JS Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_tostring(L, -1),
+ "hello world",
+ "Correct element(s) on the stack"
+ );
+
+}); \ No newline at end of file
diff --git a/tests/ltablib.js b/tests/ltablib.js
index fa15d6a..2ebf98c 100644
--- a/tests/ltablib.js
+++ b/tests/ltablib.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/ltm.js b/tests/ltm.js
index a05d2b5..d749d7b 100644
--- a/tests/ltm.js
+++ b/tests/ltm.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/lvm.js b/tests/lvm.js
index 4f02ed5..5d4eae1 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const test = require('tape');
diff --git a/tests/tests.js b/tests/tests.js
index 0963159..a47aee5 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -1,4 +1,3 @@
-/*jshint esversion: 6 */
"use strict";
const fs = require('fs');