From cafd30bad2778fc8947367edc0661d47851ed286 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 2 Jan 2026 16:04:41 +0300 Subject: [PATCH] better tests... Signed-off-by: Alex A. Naanou --- test.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/test.js b/test.js index 15c8260..d99afd5 100755 --- a/test.js +++ b/test.js @@ -218,12 +218,34 @@ test.Cases({ `"${ a }" and "${ b }" should deserialize to the samve value.`, 'got:', aa, 'and', bb, 'resp.') } }, + _make_object_with_methods: function(){ + var in_closure = 123 + return { + stateful: function(){ + return typeof(in_closure) != 'undefined' ? + 'state_retained' + : 'state_lost' }, + stateless: function(){ + return 'stateless' }, + } }, 'deep-copy-function': function(assert){ - // XXX check function isolation... - }, + var obj = this._make_object_with_methods() + var obj_copy = eJSON.deepCopy(obj, true) + + assert(obj.stateless() == 'stateless') + assert(obj.stateful() == 'state_retained') + + assert(obj_copy.stateless() == 'stateless') + assert(obj_copy.stateful() == 'state_lost') }, 'partial-deep-copy-function': function(assert){ - // XXX check function isolation... - }, + var obj = this._make_object_with_methods() + var obj_copy = eJSON.partialDeepCopy(obj) + + assert(obj.stateless() == 'stateless') + assert(obj.stateful() == 'state_retained') + + assert(obj_copy.stateless() == 'stateless') + assert(obj_copy.stateful() == 'state_retained') }, })