summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-11 17:05:04 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-11 17:05:04 +1000
commit6f93b0a3af9e64d3f69a2442af3c21b6fa794ed7 (patch)
treef6d0db7aeb2245990101475e58a2cc3e1a6052f9 /tests
parent4405575ad986ee0ea652a069bae72d9984cb6a9f (diff)
downloadfengari-6f93b0a3af9e64d3f69a2442af3c21b6fa794ed7.tar.gz
fengari-6f93b0a3af9e64d3f69a2442af3c21b6fa794ed7.tar.bz2
fengari-6f93b0a3af9e64d3f69a2442af3c21b6fa794ed7.zip
tests/ltablib.js: Use better filter for numeric keys
Diffstat (limited to 'tests')
-rw-r--r--tests/ltablib.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/ltablib.js b/tests/ltablib.js
index e209db3..43e742b 100644
--- a/tests/ltablib.js
+++ b/tests/ltablib.js
@@ -14,7 +14,7 @@ const inttable2array = function(t) {
let a = [];
t.strong.forEach(function (v, k) {
- if (typeof k === 'number')
+ if (v.key.ttisnumber())
a[k - 1] = v.value;
});
@@ -73,7 +73,7 @@ test('table.pack', function (t) {
t.deepEqual(
[...lua.lua_topointer(L, -1).strong.entries()]
- .filter(e => typeof e[0] === 'number') // Filter out the 'n' field
+ .filter(e => e[1].key.ttisnumber()) // Filter out the 'n' field
.map(e => e[1].value.value).reverse(),
[1, 2, 3],
"Correct element(s) on the stack"
@@ -148,7 +148,7 @@ test('table.insert', function (t) {
t.deepEqual(
[...lua.lua_topointer(L, -1).strong.entries()]
- .filter(e => typeof e[0] === 'number')
+ .filter(e => e[1].key.ttisnumber())
.map(e => e[1].value.value).sort(),
[1, 2, 3, 4, 5],
"Correct element(s) on the stack"
@@ -182,7 +182,7 @@ test('table.remove', function (t) {
t.deepEqual(
[...lua.lua_topointer(L, -1).strong.entries()]
- .filter(e => typeof e[0] === 'number')
+ .filter(e => e[1].key.ttisnumber())
.map(e => e[1].value.value).sort(),
[1, 2, 3, 4],
"Correct element(s) on the stack"
@@ -215,7 +215,7 @@ test('table.move', function (t) {
t.deepEqual(
[...lua.lua_topointer(L, -1).strong.entries()]
- .filter(e => typeof e[0] === 'number')
+ .filter(e => e[1].key.ttisnumber())
.map(e => e[1].value.value).sort(),
[1, 2, 3, 4, 5, 6],
"Correct element(s) on the stack"