Skip to content

Commit fc67365

Browse files
committed
wasm: include a function in toAst fast-check arbitraryMapping
1 parent bc373bb commit fc67365

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/wasm/test/test-toAST.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ function arbitraryMapping() {
244244
// …then for each rule, generate a "node template" where:
245245
// - the keys are a single letter
246246
// - the values are either a number or a string.
247+
// - a function that return an array of each child's `ctorName`.
247248
// If a number, it's constrained to be less than the rule arity, because
248249
// the meaning is "put child[i] in this prop".
249250
const arities = new Map(
@@ -256,7 +257,11 @@ function arbitraryMapping() {
256257
ruleName,
257258
fc.dictionary(
258259
fc.constantFrom(...'abcdefghijklmnopqrstuvwxyz'),
259-
fc.oneof(fc.nat({max: arity - 1}), fc.string()),
260+
fc.oneof(
261+
fc.nat({max: arity - 1}),
262+
fc.string(),
263+
fc.constant(children => children.map(c => c.ctorName)),
264+
),
260265
),
261266
];
262267
}),

0 commit comments

Comments
 (0)