mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Ensure _.map rewrite handles objects with non-numeric length properties correctly.
Former-commit-id: 60a4f322dcd284db5bb8ad4d8d5138e52e14cce3
This commit is contained in:
13
test/test.js
13
test/test.js
@@ -41,6 +41,9 @@
|
||||
/** Shortcut used to make object properties immutable */
|
||||
var freeze = Object.freeze;
|
||||
|
||||
/** Used to set property descriptors */
|
||||
var setDescriptor = Object.defineProperty;
|
||||
|
||||
/** Shortcut used to convert array-like objects to arrays */
|
||||
var slice = [].slice;
|
||||
|
||||
@@ -946,6 +949,16 @@
|
||||
});
|
||||
deepEqual(actual, [1, 2, 3]);
|
||||
});
|
||||
|
||||
test('should handle object arguments with non-numeric length properties', function() {
|
||||
if (setDescriptor) {
|
||||
var object = {};
|
||||
setDescriptor(object, 'length', { 'value': 'x' });
|
||||
deepEqual(_.map(object, _.identity), []);
|
||||
} else {
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user