From 6f93b0a3af9e64d3f69a2442af3c21b6fa794ed7 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 11 May 2017 17:05:04 +1000 Subject: tests/ltablib.js: Use better filter for numeric keys --- tests/ltablib.js | 10 +++++----- 1 file 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" -- cgit v1.2.3-70-g09d2