replace Context.tabulate with tabulateVar
- takes a function `Var n -> a` - results are no longer backwards lmao
This commit is contained in:
parent
e880b7165a
commit
722c05225d
4 changed files with 49 additions and 26 deletions
|
@ -26,6 +26,15 @@ ToInfo Failure where
|
|||
("expected", show f.expected),
|
||||
("got", show f.got)]
|
||||
|
||||
private
|
||||
testFreeVars1 : {d : Nat} -> HasFreeVars f =>
|
||||
(f d -> String) -> f d -> FreeVars' d -> Test
|
||||
testFreeVars1 lbl tm dims =
|
||||
test (lbl tm) $ do
|
||||
let dims = FV dims; dims' = fv tm
|
||||
unless (dims == dims') $ Left $ Fail Dim dims dims'
|
||||
Right ()
|
||||
|
||||
private
|
||||
testFreeVars : {d, n : Nat} -> (HasFreeVars (f d), HasFreeDVars f) =>
|
||||
(f d n -> String) -> f d n -> FreeVars' d -> FreeVars' n -> Test
|
||||
|
@ -45,6 +54,22 @@ private
|
|||
prettyWith : (a -> Eff Pretty Doc80) -> a -> String
|
||||
prettyWith f = trim . render _ . runPretty . f
|
||||
|
||||
parameters {d : Nat} (ds : BContext d)
|
||||
private
|
||||
withContext1 : Doc80 -> Eff Pretty Doc80
|
||||
withContext1 doc =
|
||||
if null ds then pure $ hsep ["⊢", doc]
|
||||
else pure $ sep [hsep [!(ctx1 ds), "⊢"], doc]
|
||||
where
|
||||
ctx1 : forall k. BContext k -> Eff Pretty Doc80
|
||||
ctx1 [<] = pure "·"
|
||||
ctx1 ctx = fillSeparateTight !commaD . toList' <$>
|
||||
traverse' (pure . prettyBind') ctx
|
||||
|
||||
private
|
||||
testFreeVarsD : Dim d -> FreeVars' d -> Test
|
||||
testFreeVarsD = testFreeVars1 $ prettyWith $ withContext1 <=< prettyDim ds
|
||||
|
||||
parameters {d, n : Nat} (ds : BContext d) (ts : BContext n)
|
||||
private
|
||||
withContext : Doc80 -> Eff Pretty Doc80
|
||||
|
@ -67,7 +92,13 @@ parameters {d, n : Nat} (ds : BContext d) (ts : BContext n)
|
|||
|
||||
export
|
||||
tests : Test
|
||||
tests = "free variables" :- [
|
||||
tests = "free variables (fv/fdv)" :- [
|
||||
testFreeVarsD [<] (^K Zero) [<],
|
||||
testFreeVarsD [<"i", "j"] (^K Zero) [<False, False],
|
||||
testFreeVarsD [<"i", "j"] (^BV 0) [<False, True],
|
||||
testFreeVarsD [<"i", "j"] (^BV 1) [<True, False],
|
||||
testFreeVarsD [<"i", "j", "k", "l"] (^BV 2) [<False, True, False, False],
|
||||
|
||||
testFreeVarsT [<] [<] (^TYPE 0) [<] [<],
|
||||
testFreeVarsT [<"i", "j"] [<] (^TYPE 0) [<False, False] [<],
|
||||
testFreeVarsT [<] [<"x", "y"] (^TYPE 0) [<] [<False, False],
|
||||
|
@ -98,6 +129,10 @@ tests = "free variables" :- [
|
|||
|
||||
testFreeVarsT [<"i","j"] [<] (^DLamY "k" (E $ ^DApp (^F "eq" 0) (^BV 0)))
|
||||
[<False,False] [<],
|
||||
testFreeVarsT [<"i","j"] [<] (^DLamY "k" (E $ ^DApp (^F "eq" 0) (^BV 2)))
|
||||
[<True,False] [<],
|
||||
testFreeVarsT [<"i","j"] [<] (^DLamY "i" (E $ ^DApp (^F "eq" 0) (^BV 0)))
|
||||
[<False,False] [<],
|
||||
testFreeVarsT [<"i","j"] [<] (^DLamN (E $ ^DApp (^F "eq" 0) (^BV 0)))
|
||||
[<False,True] [<],
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue