Isolate caches of tests.

This commit is contained in:
John-David Dalton
2016-06-07 07:20:01 -07:00
parent ecbf8cd722
commit efb4db2b86

View File

@@ -1022,21 +1022,24 @@
return [key, keys[lastIndex - index]]; return [key, keys[lastIndex - index]];
}); });
var largeStack = new mapCaches.Stack(pairs); function createCaches(pairs) {
var largeStack = new mapCaches.Stack(pairs),
length = pairs ? pairs.length : 0;
lodashStable.times(LARGE_ARRAY_SIZE - pairs.length + 1, function() { lodashStable.times(LARGE_ARRAY_SIZE - length + 1, function() {
largeStack.set({}, {}); largeStack.set({}, {});
}); });
var caches = { return {
'hashes': new mapCaches.Hash(pairs), 'hashes': new mapCaches.Hash(pairs),
'list caches': new mapCaches.ListCache(pairs), 'list caches': new mapCaches.ListCache(pairs),
'map caches': new mapCaches.MapCache(pairs), 'map caches': new mapCaches.MapCache(pairs),
'stack caches': new mapCaches.Stack(pairs), 'stack caches': new mapCaches.Stack(pairs),
'large stacks': largeStack 'large stacks': largeStack
}; };
}
lodashStable.forOwn(caches, function(cache, kind) { lodashStable.forOwn(createCaches(pairs), function(cache, kind) {
QUnit.test('should implement a `Map` interface for ' + kind, function(assert) { QUnit.test('should implement a `Map` interface for ' + kind, function(assert) {
assert.expect(82); assert.expect(82);
@@ -1058,7 +1061,9 @@
return !cache.has(key); return !cache.has(key);
})); }));
}); });
});
lodashStable.forOwn(createCaches(), function(cache, kind) {
QUnit.test('should support changing values of ' + kind, function(assert) { QUnit.test('should support changing values of ' + kind, function(assert) {
assert.expect(10); assert.expect(10);
@@ -1067,7 +1072,6 @@
cache.set(key, 2); cache.set(key, 2);
assert.strictEqual(cache.get(key), 2); assert.strictEqual(cache.get(key), 2);
cache.clear();
}); });
}); });
}); });