mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Simplify Stack test.
This commit is contained in:
30
test/test.js
30
test/test.js
@@ -2344,12 +2344,9 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('`_.cloneDeepWith` should provide `stack` to `customizer`', function(assert) {
|
QUnit.test('`_.cloneDeepWith` should provide `stack` to `customizer`', function(assert) {
|
||||||
assert.expect(166);
|
assert.expect(164);
|
||||||
|
|
||||||
var stack1,
|
var Stack,
|
||||||
stack2,
|
|
||||||
object1 = { 'v0': 0 },
|
|
||||||
object2 = {},
|
|
||||||
symbol = Symbol ? Symbol() : {},
|
symbol = Symbol ? Symbol() : {},
|
||||||
keys = [true, false, 1, -Infinity, NaN, {}, null, 'a', symbol, undefined];
|
keys = [true, false, 1, -Infinity, NaN, {}, null, 'a', symbol, undefined];
|
||||||
|
|
||||||
@@ -2358,28 +2355,19 @@
|
|||||||
return [key, keys[lastIndex - index]];
|
return [key, keys[lastIndex - index]];
|
||||||
});
|
});
|
||||||
|
|
||||||
lodashStable.times(LARGE_ARRAY_SIZE + 1, function(index) {
|
_.cloneDeepWith({ 'a': 1 }, function() {
|
||||||
object2['v' + index] = [index ? object2['v' + (index - 1)] : object2];
|
|
||||||
});
|
|
||||||
|
|
||||||
var clone1 = _.cloneDeepWith(object1, function() {
|
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
stack1 || (stack1 = _.last(arguments));
|
Stack || (Stack = _.last(arguments).constructor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var clone2 = _.cloneDeepWith(object2, function() {
|
var stacks = [new Stack(pairs), new Stack(pairs)];
|
||||||
if (arguments.length > 1) {
|
|
||||||
stack2 || (stack2 = _.last(arguments));
|
lodashStable.times(LARGE_ARRAY_SIZE - pairs.length + 1, function() {
|
||||||
}
|
stacks[1].set({}, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.strictEqual(stack1.get(object1), clone1);
|
lodashStable.each(stacks, function(stack) {
|
||||||
assert.strictEqual(stack2.get(object2), clone2);
|
|
||||||
|
|
||||||
lodashStable.each([stack1.constructor, stack2.constructor], function(Stack) {
|
|
||||||
var stack = new Stack(pairs);
|
|
||||||
|
|
||||||
lodashStable.each(keys, function(key, index) {
|
lodashStable.each(keys, function(key, index) {
|
||||||
var value = pairs[index][1];
|
var value = pairs[index][1];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user