From 8ab279d4881c727961dc7a6f1fad99e335c7f1f3 Mon Sep 17 00:00:00 2001 From: Nikolaj Gade Date: Fri, 11 Oct 2024 15:46:28 +0200 Subject: [PATCH] :clown_face: onlyCheckedErrors --- a5/src/APL/Tests.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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)) ]