Add Stack#size.

This commit is contained in:
John-David Dalton
2016-08-27 21:40:24 -07:00
parent 6651023f7f
commit 7c398f8019
3 changed files with 27 additions and 18 deletions

View File

@@ -1309,7 +1309,7 @@
var args,
iteration = 0,
objects = [{ 'a': 1 }, { 'a': 2 }],
stack = { '__data__': { '__data__': [objects, objects.slice().reverse()], 'size': 0 } },
stack = { '__data__': { '__data__': [objects, objects.slice().reverse()], 'size': 2 }, 'size': 2 },
expected = [1, 2, 'a', objects[0], objects[1], stack];
fp.isEqualWith(function() {
@@ -1335,7 +1335,7 @@
var args,
objects = [{ 'a': 1 }, { 'a': 2 }],
stack = { '__data__': { '__data__': [], 'size': 0 } },
stack = { '__data__': { '__data__': [], 'size': 0 }, 'size': 0 },
expected = [2, 1, 'a', objects[1], objects[0], stack];
fp.isMatchWith(function() {
@@ -1444,7 +1444,7 @@
assert.expect(1);
var args,
stack = { '__data__': { '__data__': [], 'size': 0 } },
stack = { '__data__': { '__data__': [], 'size': 0 }, 'size': 0 },
expected = [[1, 2], [3], 'a', { 'a': [1, 2] }, { 'a': [3] }, stack];
fp.mergeWith(function() {
@@ -1477,7 +1477,7 @@
assert.expect(1);
var args,
stack = { '__data__': { '__data__': [], 'size': 0 } },
stack = { '__data__': { '__data__': [], 'size': 0 }, 'size': 0 },
expected = [[1, 2], [3], 'a', { 'a': [1, 2] }, { 'a': [3] }, stack];
fp.mergeAllWith(function() {

View File

@@ -1062,8 +1062,10 @@
}
lodashStable.forOwn(createCaches(pairs), function(cache, kind) {
var isLarge = /^large/.test(kind);
QUnit.test('should implement a `Map` interface for ' + kind, function(assert) {
assert.expect(82);
assert.expect(83);
lodashStable.each(keys, function(key, index) {
var value = pairs[index][1];
@@ -1078,6 +1080,7 @@
assert.strictEqual(cache.has(key), true);
});
assert.strictEqual(cache.size, isLarge ? LARGE_ARRAY_SIZE : keys.length);
assert.strictEqual(cache.clear(), undefined);
assert.ok(lodashStable.every(keys, function(key) {
return !cache.has(key);
@@ -1090,9 +1093,7 @@
assert.expect(10);
lodashStable.each(keys, function(key) {
cache.set(key, 1);
cache.set(key, 2);
cache.set(key, 1).set(key, 2);
assert.strictEqual(cache.get(key), 2);
});
});