From c5601945c47c118669998947be9be94e822cf52f Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 22 May 2021 12:37:56 +0300 Subject: [PATCH] tweaks... Signed-off-by: Alex A. Naanou --- diff.js | 3 +-- test.js | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/diff.js b/diff.js index dd9bde3..0af3669 100644 --- a/diff.js +++ b/diff.js @@ -328,8 +328,7 @@ var LogicTypePrototype = { if(arguments.length < 3 || !(cmp instanceof Function)){ return Diff.cmp( cmp instanceof Function ? this : this.context(cmp), - obj) - } + obj) } /* cmp = cmp || function(a, b){ diff --git a/test.js b/test.js index c9d6205..ca55965 100755 --- a/test.js +++ b/test.js @@ -69,11 +69,32 @@ test.Tests({ test.Cases({ 'basics': function(assert){ // XXX move reference objects + expected diffs to setups - a = {} - b = {} + var a = {} + var b = {} assert(diff.Diff(a, b), 'Diff(..)') }, + recursion: function(assert){ + var a = {} + a.x = a + var b = {} + b.x = b + + assert(diff.cmp(a, b), 'recursive cmp(..)') + + a = {} + a.x = a + b = {} + b.y = b + assert(!diff.cmp(a, b), 'recursive !cmp(..)') + + + a = {} + a.x = a + b = {x: {}} + + assert(!diff.cmp(a, b), 'recursive cmp(..)') + }, })