Skip to content

Commit

Permalink
More generators for types
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Dec 17, 2024
1 parent 4cd1e56 commit e7af810
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/haz3lmenhir/AST.re
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ let rec gen_exp_sized = (n: int): QCheck.Gen.t(exp) =>
self((n - 1) / 2),
self((n - 1) / 2),
),
// Gen.map2((op, e) => UnOp(op, e), gen_op_un, self(n - 1)), // TODO ExpToSegment broken for UnOp
Gen.map3(
(e1, e2, e3) => If(e1, e2, e3),
self((n - 1) / 3),
Expand All @@ -313,8 +314,17 @@ let rec gen_exp_sized = (n: int): QCheck.Gen.t(exp) =>

gen
)
and gen_typ_sized = (_n: int): QCheck.Gen.t(typ) => QCheck.Gen.pure(IntType)
and gen_pat_sized = (_n: int): QCheck.Gen.t(pat) => QCheck.Gen.pure(WildPat);
and gen_typ_sized = (_n: int): QCheck.Gen.t(typ) =>
QCheck.Gen.(
oneof([
return(StringType),
return(FloatType),
return(BoolType),
return(UnitType),
])
)
and gen_pat_sized = (_n: int): QCheck.Gen.t(pat) =>
QCheck.Gen.pure(WildPat);
// TODO Printers, shrinkers stuff

let gen_exp = QCheck.Gen.sized(gen_exp_sized);
Expand Down

0 comments on commit e7af810

Please sign in to comment.