diff --git a/a5/src/APL/Tests.hs b/a5/src/APL/Tests.hs index 1066ec4..57f70d4 100644 --- a/a5/src/APL/Tests.hs +++ b/a5/src/APL/Tests.hs @@ -5,6 +5,7 @@ module APL.Tests where import APL.AST (Exp (..), subExp, VName, printExp) +import APL.Eval (eval, runEval) import APL.Parser (parseAPL, keywords) import APL.Error (isVariableError, isDomainError, isTypeError) import APL.Check (checkExp) @@ -114,11 +115,13 @@ parsePrinted e = case (parseAPL "input" (printExp e)) of Right e' -> e == e' onlyCheckedErrors :: Exp -> Bool -onlyCheckedErrors _ = undefined +onlyCheckedErrors e = case runEval (eval e) of + Right _ -> True + Left err -> err `elem` (checkExp e) properties :: [(String, Property)] properties = [ ("expCoverage", property expCoverage) , ("parsePrinted", property (withMaxSuccess 10000 parsePrinted)) - , ("onlyCheckedErrors", property onlyCheckedErrors) + , ("onlyCheckedErrors", property (withMaxSuccess 1000000 onlyCheckedErrors)) ]