Skip to content

Commit

Permalink
more clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Dec 16, 2023
1 parent 6070ff0 commit 3846bdf
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions property_tests/arbitraries/candid/candid_definition_arb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,8 @@ import { VariantDefinitionArb } from '../constructed/variant_arb/definition_arbs
import { VecDefinitionArb } from '../constructed/vec_arb/definition_arb';
import {
CandidDefinition,
FuncCandidDefinition,
OptCandidDefinition,
RecordCandidDefinition,
TupleCandidDefinition,
VariantCandidDefinition,
VecCandidDefinition,
CandidDefinitionArb,
RecursiveGlobalDefinition,
ServiceCandidDefinition,
RecursiveCandidDefinition,
RecCandidDefMemo,
CandidDefMemo
} from './types';
import { BlobDefinitionArb } from '../constructed/blob_arb/definition_arb';
Expand All @@ -56,8 +47,11 @@ export function candidDefinitionMemo(
return primitiveCandidDefinitionArb();
}
return fc.oneof(
primitiveCandidDefinitionArb(),
complexCandidDefinitionMemo(parents)(n - 1),
{ arbitrary: primitiveCandidDefinitionArb(), weight: 16 },
{
arbitrary: complexCandidDefinitionMemo(parents)(n - 1),
weight: 9
},
{
arbitrary: recursiveCandidDefinitionMemo(parents)(n - 1),
weight: 1
Expand All @@ -70,7 +64,6 @@ export function complexCandidDefinitionMemo(
parents: RecursiveCandidDefinition[],
constraints: ComplexDefinitionConstraints = {}
): CandidDefMemo {
// TODO Implement constraints
return fc.memo((n) => {
return fc.oneof(
{
Expand Down Expand Up @@ -100,6 +93,10 @@ export function complexCandidDefinitionMemo(
{
arbitrary: VecDefinitionArb(candidDefinitionMemo([])(n)),
weight: constraints.vec ?? 1
},
{
arbitrary: ServiceDefinitionArb(candidDefinitionMemo([])(n)),
weight: constraints.service ?? 0
}
);
});
Expand Down

0 comments on commit 3846bdf

Please sign in to comment.