Ensure the callback of _.filter can't modify the resulting value.

Former-commit-id: 6652dc5926390e8418b524c7ffd2347c2fa65c82
This commit is contained in:
John-David Dalton
2012-07-26 23:20:36 -07:00
parent 4ff12e0426
commit 943004844a
3 changed files with 59 additions and 30 deletions

View File

@@ -427,6 +427,20 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.filter');
(function() {
test('should not modify the resulting value from within `callback`', function() {
var actual = _.filter([0], function(value, index, array) {
return (array[index] = 1);
});
deepEqual(actual, [0]);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.find');
(function() {