From e5055b4fc5c84b945a5f933fc84cc8f39041e8f1 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 15 Jun 2020 16:59:42 +0300 Subject: [PATCH] fixed the thing... Signed-off-by: Alex A. Naanou --- object.js | 5 ++--- test.js | 14 ++++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/object.js b/object.js index 077fca1..904a481 100755 --- a/object.js +++ b/object.js @@ -120,10 +120,9 @@ function(obj, stop){ var res = [] while(obj != null){ res.push(Object.keys(obj)) - obj = obj.__proto__ - // XXX need to stop but include the stop object... if(obj === stop){ - break }} + break } + obj = obj.__proto__ } return [...(new Set(res.flat()))] } diff --git a/test.js b/test.js index 2a0805c..46cd0f6 100755 --- a/test.js +++ b/test.js @@ -602,13 +602,11 @@ module.cases = { c: true, } - assert(arrayCmp(object.deepKeys(c), ['a', 'b', 'c']), 'full') - assert(arrayCmp(object.deepKeys(c, a), ['a', 'b', 'c']), 'full 2') + assert.array(object.deepKeys(c), ['c', 'b', 'a'], 'full chain') + assert.array(object.deepKeys(c, a), ['c', 'b', 'a'], 'full chain') + assert.array(object.deepKeys(c, b), ['c', 'b'], 'partial chain') + assert.array(object.deepKeys(c, c), ['c'], 'partial chain') - // XXX these are wrong... - console.log('>>>>', object.deepKeys(c, a)) // -/-> ['a', 'b', 'c'] - console.log('>>>>', object.deepKeys(c, b)) // -/-> ['b', 'c'] - console.log('>>>>', object.deepKeys(c, c)) // -/-> ['c'] } } @@ -714,6 +712,10 @@ object.Constructor('Assert', { } catch(err){ this(true, msg) return err } }, + // XXX + array: function(value, expected, msg){ + return this(arrayCmp(value, expected), + msg +':', 'expected:', expected, 'got:', value) }, __init__: function(path, stats, verbose){ this.path = path instanceof Array ?