try-catch

This commit is contained in:
2024-10-04 13:29:34 +02:00
parent fb7f5c936a
commit 46aa789d64
66 changed files with 564 additions and 0 deletions

View File

@ -65,6 +65,22 @@ pureTests =
--
testCase "Div0" $
eval' (Div (CstInt 7) (CstInt 0))
@?= ([], Left "Division by zero"),
--
testCase "TryCatch try1" $
eval' (TryCatch (CstInt 1) (CstInt 2))
@?= ([], Right (ValInt 1)),
--
testCase "TryCatch try2" $
eval' (TryCatch (CstInt 1) (Div (CstInt 1) (CstInt 0)))
@?= ([], Right (ValInt 1)),
--
testCase "TryCatch catch1" $
eval' (TryCatch (Div (CstInt 1) (CstInt 0)) (CstInt 1))
@?= ([], Right (ValInt 1)),
--
testCase "TryCatch catch1" $
eval' (TryCatch (Div (CstInt 1) (CstInt 0)) (Div (CstInt 1) (CstInt 0)))
@?= ([], Left "Division by zero")
]