Skip to content

Commit

Permalink
feat(SwingSet): makeFakeVirtualObjectManager() takes options bag
Browse files Browse the repository at this point in the history
  • Loading branch information
warner committed May 21, 2021
1 parent 61c97d0 commit 40bbdee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function zotVal(arbitrary, name, tag, count) {
// prettier-ignore
test('virtual object operations', t => {
const log = [];
const { makeKind, flushCache, dumpStore } = makeFakeVirtualObjectManager(3, log);
const { makeKind, flushCache, dumpStore } = makeFakeVirtualObjectManager({ cacheSize: 3, log });

const thingMaker = makeKind(makeThingInstance);
const zotMaker = makeKind(makeZotInstance);
Expand Down Expand Up @@ -298,7 +298,9 @@ test('virtual object operations', t => {
});

test('weak store operations', t => {
const { makeWeakStore, makeKind } = makeFakeVirtualObjectManager(3);
const { makeWeakStore, makeKind } = makeFakeVirtualObjectManager({
cacheSize: 3,
});

const thingMaker = makeKind(makeThingInstance);
const zotMaker = makeKind(makeZotInstance);
Expand Down Expand Up @@ -346,7 +348,7 @@ test('virtualized weak collection operations', t => {
VirtualObjectAwareWeakMap,
VirtualObjectAwareWeakSet,
makeKind,
} = makeFakeVirtualObjectManager(3);
} = makeFakeVirtualObjectManager({ cacheSize: 3 });

const thingMaker = makeKind(makeThingInstance);
const zotMaker = makeKind(makeZotInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ test('weakMap vref handling', async t => {
VirtualObjectAwareWeakSet,
valToSlot,
slotToVal,
} = makeFakeVirtualObjectManager(3, log);
} = makeFakeVirtualObjectManager({ cacheSize: 3, log });

function addCListEntry(slot, val) {
slotToVal.set(slot, val);
Expand Down
3 changes: 2 additions & 1 deletion packages/SwingSet/tools/fakeVirtualObjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { parseVatSlot } from '../src/parseVatSlots';

import { makeVirtualObjectManager } from '../src/kernel/virtualObjectManager';

export function makeFakeVirtualObjectManager(cacheSize = 100, log) {
export function makeFakeVirtualObjectManager(options = {}) {
const { cacheSize = 100, log } = options;
const fakeStore = new Map();

function dumpStore() {
Expand Down
4 changes: 3 additions & 1 deletion packages/SwingSet/tools/prepare-test-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import './install-ses-debug';
import { makeFakeVirtualObjectManager } from './fakeVirtualObjectManager';

const { makeKind, makeWeakStore } = makeFakeVirtualObjectManager(3);
const { makeKind, makeWeakStore } = makeFakeVirtualObjectManager({
cacheSize: 3,
});

globalThis.makeKind = makeKind;
globalThis.makeWeakStore = makeWeakStore;

0 comments on commit 40bbdee

Please sign in to comment.