Skip to content

Commit

Permalink
Merge pull request gcanti#59 from huevy/master
Browse files Browse the repository at this point in the history
[test] memory saving in update operations
  • Loading branch information
gcanti committed Oct 28, 2014
2 parents aea42db + e5917f8 commit 80679a5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,39 @@ describe('defaultUpdate', function () {
});
});

describe('memory saving', function () {
it('should reuse members that are not updated', function () {
var Struct = struct({
a: Num,
b: Str,
c: tuple([Num, Num]),
});
var List = list(Struct);
var instance = List([{
a: 1,
b: 'one',
c: [1000, 1000000]
},{
a: 2,
b: 'two',
c: [2000, 2000000]
}]);

var updated = defaultUpdate(instance, {
1: {
a: {$set: 119}
}
});

assert.strictEqual(updated[0], instance[0]);
assert.notStrictEqual(updated[1], instance[1]);

assert.strictEqual(updated[1].c, instance[1].c);


});
});

describe('all together now', function () {

it('should handle mixed commands', function () {
Expand Down

0 comments on commit 80679a5

Please sign in to comment.