From 7fc4ecaf203924becd9c88d800216ddad7ecbd4b Mon Sep 17 00:00:00 2001 From: James Halliday Date: Thu, 26 Aug 2010 19:51:36 -0800 Subject: [PATCH] tests for update, concat, and merge all pass --- test/hash.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/hash.js b/test/hash.js index 0442b0f..f59d739 100755 --- a/test/hash.js +++ b/test/hash.js @@ -37,5 +37,25 @@ exports['hash traversal'] = function (assert) { assert.equal(Hash(ref3).values.sort().join(' '), '2 5 7 leet'); assert.equal(Hash(ref3).length, 4); + + assert.equal( + Object.keys(Hash.concat([ ref1, ref2 ])).sort().join(' '), + 'a b bar foo' + ); + + var hash3 = Hash(ref1).clone; + var updated = hash3.update({ c : 3, a : 0 }); + assert.equal(updated.keys.sort().join(' '), 'a b c'); + assert.equal(updated.items.a, 0); + assert.equal(updated.items.b, 2); + assert.equal(updated.items.c, 3); + assert.equal(Object.keys(hash3.items).sort().join(' '), 'a b c'); + assert.equal(hash3.items.a, 0); + assert.equal(hash3.items.b, 2); + assert.equal(hash3.items.c, 3); + assert.equal(Object.keys(ref1).sort().join(' '), 'a b'); + assert.equal(ref1.a, 1); + assert.equal(ref1.b, 2); + };