Skip to content

Commit

Permalink
test: closed eval behaves fine with holes
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Price <[email protected]>
  • Loading branch information
brprice committed Sep 14, 2023
1 parent 5e4ed98 commit 8a6a846
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions primer/test/Tests/EvalFull.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import Primer.Eval
import Primer.EvalFull
import Primer.Examples qualified as Examples (
even,
map,
map',
odd,
)
Expand Down Expand Up @@ -426,6 +427,25 @@ unit_15 =
s <- evalFullTest maxID builtinTypes mempty (fromIntegral $ length steps) Syn expr
s <~==> Right expected

unit_map_hole :: Assertion
unit_map_hole =
let n = 3
modName = mkSimpleModuleName "TestModule"
((globals, expr, expected), maxID) = create $ do
(mapName, mapDef) <- Examples.map modName
let lst = list_ $ take n $ iterate (con1 cSucc) (con0 cZero)
e <- gvar mapName `aPP` tcon tNat `aPP` tcon tBool `app` emptyHole `app` lst
let globs = [(mapName, mapDef)]
expect <- list_ (take n $ ((emptyHole `ann` (tcon tNat `tfun` tcon tBool)) `app`) <$> iterate (con1 cSucc) (con0 cZero)) `ann` (tcon tList `tapp` tcon tBool)
pure (M.fromList globs, e, expect)
in do
sO <- evalFullTest maxID builtinTypes globals 200 Syn expr
sO <~==> Right expected
sCG <- evalFullTestClosed GroupedLets maxID builtinTypes globals 200 Syn expr
sCG <~==> Right expected
sCS <- evalFullTestClosed SingleLets maxID builtinTypes globals 300 Syn expr
sCS <~==> Right expected

unit_hole_ann_case :: Assertion
unit_hole_ann_case =
let (tm, maxID) = create $ hole $ ann (case_ emptyHole []) (tcon tBool)
Expand Down

0 comments on commit 8a6a846

Please sign in to comment.