Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wip
  • Loading branch information
MaximilianAlgehed committed May 23, 2022
1 parent adc8415 commit 78c592b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions plutus-core/plutus-ir/test/GeneratorSpec.hs
Expand Up @@ -169,15 +169,18 @@ prop_stats_leaves :: Property
prop_stats_leaves =
-- No shrinking here because we are only collecting stats
forAllDoc "_,tm" genTypeAndTerm_ (const []) $ \ (_, tm) ->
tabulate "vars" (map (filter isAlpha . show . prettyPirReadable) $ vars tm) $ property True
tabulate "leaves" (map (filter isAlpha . show . prettyPirReadable) $ leaves tm) $ property True
where
vars (Var _ x) = [x]
vars (TyInst _ a _) = vars a
vars (Let _ _ _ b) = vars b
vars (LamAbs _ _ _ b) = vars b
vars (Apply _ a b) = vars a ++ vars b
vars Error{} = [Name "error" $ toEnum 0]
vars _ = []
-- Figure out what's at the leaves of the AST,
-- including variable names, error, and builtins.
leavesish (Var _ x) = [x]
leavesish (TyInst _ a _) = leavesish a
leavesish (Let _ _ _ b) = leavesish b
leavesish (LamAbs _ _ _ b) = leavesish b
leavesish (Apply _ a b) = leavesish a ++ leavesish b
leavesish Error{} = [Name "error" $ toEnum 0]
leavesish Builtin{} = [Name "builtin" $ toEnum 0]
leavesish _ = []

-- | Check the ratio of duplicate shrinks
prop_stats_numShrink :: Property
Expand Down

0 comments on commit 78c592b

Please sign in to comment.