Add tests for symbol paths.

This commit is contained in:
John-David Dalton
2016-03-03 22:42:58 -08:00
parent a19890469e
commit 16ed42b188
2 changed files with 97 additions and 13 deletions

View File

@@ -2739,7 +2739,7 @@
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
path = isKey(path, object) ? [path] : baseCastPath(path);
var index = 0,
length = path.length;
@@ -3306,12 +3306,22 @@
* @returns {Object} Returns the new object.
*/
function basePickBy(object, predicate) {
var result = {};
baseForIn(object, function(value, key) {
var props = keysIn(object);
if (!isArray(object)) {
arrayPush(props, getSymbolsIn(object));
}
var index = -1,
length = props.length,
result = {};
while (++index < length) {
var key = props[index],
value = object[key];
if (predicate(value, key)) {
result[key] = value;
}
});
}
return result;
}
@@ -3459,7 +3469,7 @@
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
path = isKey(path, object) ? [path] : baseCastPath(path);
var index = -1,
length = path.length,
@@ -3736,7 +3746,7 @@
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
path = isKey(path, object) ? [path] : baseCastPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;
@@ -5036,7 +5046,7 @@
}
/**
* Creates an array of the own symbol properties of `object`.
* Creates an array of the own enumerable symbol properties of `object`.
*
* @private
* @param {Object} object The object to query.
@@ -5046,6 +5056,23 @@
return [];
};
/**
* Creates an array of the own and inherited enumerable symbol properties
* of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbolsIn = !getOwnPropertySymbols ? getSymbols : function(object) {
var result = [];
while (object) {
arrayPush(result, getSymbols(object));
object = getPrototypeOf(object);
}
return result;
};
/**
* Gets the `toStringTag` of `value`.
*