-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc74466
commit 88f4662
Showing
3 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import test from 'ava'; | ||
|
||
import { makeLRUCacheMap } from '../../src/error/note-log-args.js'; | ||
|
||
test('lru cache map basic', t => { | ||
const lruMap = makeLRUCacheMap(2); | ||
const key1 = {}; | ||
const key2 = {}; | ||
const key3 = {}; | ||
t.is(lruMap.has(key1), false); | ||
|
||
lruMap.set(key1, 'x'); | ||
lruMap.set(key2, 'y'); | ||
t.is(lruMap.has(key2), true); | ||
t.is(lruMap.has(key1), true); | ||
t.is(lruMap.has(key3), false); | ||
|
||
lruMap.set(key3, 'z'); | ||
t.is(lruMap.has(key1), true); | ||
t.is(lruMap.has(key2), false); | ||
t.is(lruMap.has(key3), true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import test from 'ava'; | ||
|
||
import { makeNoteLogArgsArrayKit } from '../../src/error/note-log-args.js'; | ||
|
||
test('note log args array kit basic', t => { | ||
const { addLogArgs, takeLogArgsArray } = makeNoteLogArgsArrayKit(3, 2); | ||
const e1 = Error('e1'); | ||
const e2 = Error('e2'); | ||
const e3 = Error('e3'); | ||
const e4 = Error('e4'); | ||
|
||
addLogArgs(e1, ['a']); | ||
addLogArgs(e3, ['b']); | ||
addLogArgs(e2, ['c']); | ||
addLogArgs(e4, ['d']); // drops e1 | ||
addLogArgs(e1, ['e']); // new e1 entry, drops e3 | ||
addLogArgs(e2, ['f']); | ||
addLogArgs(e2, ['g']); // drops e2,c | ||
addLogArgs(e2, ['h']); // drops e2,f | ||
t.deepEqual(takeLogArgsArray(e1), [['e']]); | ||
t.deepEqual(takeLogArgsArray(e2), [['g'], ['h']]); | ||
t.deepEqual(takeLogArgsArray(e3), undefined); | ||
t.deepEqual(takeLogArgsArray(e4), [['d']]); | ||
}); |