Skip to content

Commit

Permalink
fix: review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Oct 11, 2022
1 parent cd717ce commit 2555be2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
3 changes: 2 additions & 1 deletion packages/store/test/test-rankOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ test('compareRank totally orders ranks', async t => {
test('compareRank is transitive', async t => {
await fc.assert(
fc.property(
// operate on a set of three passables covering at least two ranks
// operate on a set of three distinct passables covering
// at least two ranks
fc
.uniqueArray(arbPassable, { minLength: 3, maxLength: 3 })
.filter(
Expand Down
53 changes: 35 additions & 18 deletions packages/store/tools/arb-passable.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const exampleCarol = Far('carol', {});
export const arbString = fc.oneof(fc.string(), fc.fullUnicodeString());

export const arbLeaf = fc.oneof(
fc.record({}),
fc.constantFrom(null, undefined, false, true),
arbString,
arbString.map(s => Symbol.for(s)),
// primordial symbols and registered lookalikes
Expand All @@ -28,7 +28,7 @@ export const arbLeaf = fc.oneof(
fc.bigInt(),
fc.integer(),
fc.constantFrom(-0, NaN, Infinity, -Infinity),
fc.constantFrom(null, undefined, false, true),
fc.record({}),
fc.constantFrom(exampleAlice, exampleBob, exampleCarol),
arbString.map(s => new Error(s)),
// unresolved promise
Expand All @@ -38,45 +38,62 @@ export const arbLeaf = fc.oneof(
const { arbDag } = fc.letrec(tie => {
return {
arbDag: fc.oneof(
{
// depthFactor: 0.5, // TODO Replace with what from new API?
withCrossShrink: true,
},
{ withCrossShrink: true },
arbLeaf,
tie('arbDag').map(v => Promise.resolve(v)),
fc.array(tie('arbDag'), { maxLength: 3 }),
fc.array(tie('arbDag')),
fc.dictionary(
arbString.filter(s => s !== 'then'),
tie('arbDag'),
{ maxKeys: 3 },
),
// a tagged value whose payload is an array of [key, leaf] pairs
// where each key is unique within the payload
// XXX can the payload be generalized further?
// A tagged value, either of arbitrary type with arbitrary payload
// or of known type with arbitrary or explicitly valid payload.
// Ordered by increasing complexity.
fc
.oneof(
fc.record({ type: arbString, payload: tie('arbDag') }),
fc.record({
type: fc.constantFrom('copySet'),
payload: fc.oneof(fc.array(tie('arbDag')), tie('arbDag')),
payload: fc.oneof(
tie('arbDag'),
// copySet valid payload is an array of unique passables.
// TODO: it must be a reverse sorted array, so we should
// generate some of those
fc.uniqueArray(tie('arbDag')),
),
}),
fc.record({
type: fc.constantFrom('copyBag'),
payload: fc.oneof(
fc.array(fc.tuple(tie('arbDag'), fc.bigInt())),
tie('arbDag'),
// copyBag valid payload is an array of [passable, count] tuples
// in which each passable is unique.
// TODO: it must be a reverse sorted array, so we should
// generate some of those
fc.uniqueArray(fc.tuple(tie('arbDag'), fc.bigInt()), {
selector: entry => entry[0],
}),
),
}),
fc.record({
type: fc.constantFrom('copyMap'),
payload: fc.oneof(
fc.record({
keys: fc.array(tie('arbDag')),
values: fc.array(tie('arbDag')),
}),
tie('arbDag'),
// copyMap valid payload is a {keys: Array<Passable>, values: Array<Passable>} record
// in which keys are unique and both arrays have the same length.
// TODO: keys must be a reverse sorted array, so we should
// generate some of those
fc
.uniqueArray(
fc.record({ key: tie('arbDag'), value: tie('arbDag') }),
{ selector: entry => entry.key },
)
.map(entries => ({
keys: entries.map(({ key }) => key),
values: entries.map(({ value }) => value),
})),
),
}),
fc.record({ type: arbString, payload: tie('arbDag') }),
)
.map(({ type, payload }) => makeTagged(type, payload)),
),
Expand Down

0 comments on commit 2555be2

Please sign in to comment.