Skip to content

Commit

Permalink
delete map redux test also passes for deleted element construction sy…
Browse files Browse the repository at this point in the history
…ntax [,,,] etc
  • Loading branch information
James Halliday committed Jun 6, 2011
1 parent bfdc40e commit 56553ff
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions test/mutability.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,45 @@ exports.deleteMap = function () {
});

assert.ok(Traverse.deepEqual(
res,
obj,
{ a : 1, b : 2, c : [ 3, 4 ] }
));

var xs = [ 3, 4 ];
delete xs[1];

assert.ok(Traverse.deepEqual(
res,
{ a : 1, c : [ 3, undefined ] }
res, { a : 1, c : xs }
));

assert.ok(Traverse.deepEqual(
res, { a : 1, c : [ 3, ] }
));

assert.ok(Traverse.deepEqual(
res, { a : 1, c : [ 3 ] }
));
};

exports.deleteMapRedux = function () {
var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] };
var res = Traverse(obj).map(function (x) {
if (this.isLeaf && x % 2 == 0) this.delete();
});

assert.ok(Traverse.deepEqual(
obj,
{ a : 1, b : 2, c : [ 3, 4, 5 ] }
));

var xs = [ 3, 4, 5 ];
delete xs[1];

assert.ok(Traverse.deepEqual(
res, { a : 1, c : xs }
));

assert.ok(Traverse.deepEqual(
res, { a : 1, c : [ 3 ,, 5 ] }
));
};

0 comments on commit 56553ff

Please sign in to comment.