fix up tests

This commit is contained in:
rhiannon morris 2023-03-31 23:43:25 +02:00
parent 5e220da2f4
commit a17752f31c
5 changed files with 38 additions and 35 deletions

View file

@ -5,6 +5,7 @@ import Quox.Syntax.Qty.Three
import Quox.Typechecker as Lib
import public TypingImpls
import TAP
import Quox.EffExtra
data Error'
@ -25,13 +26,10 @@ ToInfo Error' where
("wanted", prettyStr True bad)]
0 M : Type -> Type
M = ReaderT (Definitions Three) $ Either Error'
M = Eff [Except Error', DefsReader Three]
inj : (forall m. CanTC Three m => m a) -> M a
inj act = do
env <- ask
let res = runReaderT env act {m = Either (Typing.Error Three)}
either (throwError . TCError) pure res
inj : TC Three a -> M a
inj = rethrow . mapFst TCError <=< lift . runExcept
reflTy : IsQty q => Term q d n
@ -92,10 +90,12 @@ defGlobals = fromList
parameters (label : String) (act : Lazy (M ()))
{default defGlobals globals : Definitions Three}
testTC : Test
testTC = test label $ runReaderT globals act
testTC = test label {e = Error', a = ()} $
extract $ runExcept $ runReader globals act
testTCFail : Test
testTCFail = testThrows label (const True) $ runReaderT globals act $> "()"
testTCFail = testThrows label (const True) $
(extract $ runExcept $ runReader globals act) $> "()"
anys : {n : Nat} -> QContext Three n
@ -114,12 +114,10 @@ empty01 = eqDim (K Zero) (K One) empty
inferredTypeEq : TyContext Three d n -> (exp, got : Term Three d n) -> M ()
inferredTypeEq ctx exp got =
catchError
(inj $ equalType ctx exp got)
(\_ : Error' => throwError $ WrongInfer exp got)
wrapErr (const $ WrongInfer exp got) $ inj $ equalType ctx exp got
qoutEq : (exp, got : QOutput Three n) -> M ()
qoutEq qout res = unless (qout == res) $ throwError $ WrongQOut qout res
qoutEq qout res = unless (qout == res) $ throw $ WrongQOut qout res
inferAs : TyContext Three d n -> (sg : SQty Three) ->
Elim Three d n -> Term Three d n -> M ()
@ -395,7 +393,7 @@ tests = "typechecker" :- [
testTC "0 · ⇐ ★₇" $ check_ empty szero Nat (TYPE 7),
testTCFail "1 · ⇍ ★₀" $ check_ empty sone Nat (TYPE 0),
testTC "1 · zero ⇐ " $ check_ empty sone Zero Nat,
testTC "1 · zero ⇍ ×" $ check_ empty sone Zero (Nat `And` Nat),
testTCFail "1 · zero ⇍ ×" $ check_ empty sone Zero (Nat `And` Nat),
testTC "ω·n : ⊢ 1 · succ n ⇐ " $
check_ (ctx [< ("n", Nat)]) sone (Succ (BVT 0)) Nat,
testTC "1 · λ n ⇒ succ n ⇐ 1." $