mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Isolate caches of tests.
This commit is contained in:
30
test/test.js
30
test/test.js
@@ -1022,21 +1022,24 @@
|
||||
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() {
|
||||
largeStack.set({}, {});
|
||||
});
|
||||
lodashStable.times(LARGE_ARRAY_SIZE - length + 1, function() {
|
||||
largeStack.set({}, {});
|
||||
});
|
||||
|
||||
var caches = {
|
||||
'hashes': new mapCaches.Hash(pairs),
|
||||
'list caches': new mapCaches.ListCache(pairs),
|
||||
'map caches': new mapCaches.MapCache(pairs),
|
||||
'stack caches': new mapCaches.Stack(pairs),
|
||||
'large stacks': largeStack
|
||||
};
|
||||
return {
|
||||
'hashes': new mapCaches.Hash(pairs),
|
||||
'list caches': new mapCaches.ListCache(pairs),
|
||||
'map caches': new mapCaches.MapCache(pairs),
|
||||
'stack caches': new mapCaches.Stack(pairs),
|
||||
'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) {
|
||||
assert.expect(82);
|
||||
|
||||
@@ -1058,7 +1061,9 @@
|
||||
return !cache.has(key);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
lodashStable.forOwn(createCaches(), function(cache, kind) {
|
||||
QUnit.test('should support changing values of ' + kind, function(assert) {
|
||||
assert.expect(10);
|
||||
|
||||
@@ -1067,7 +1072,6 @@
|
||||
cache.set(key, 2);
|
||||
|
||||
assert.strictEqual(cache.get(key), 2);
|
||||
cache.clear();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user