implemented assert_unlinkable assertion

This commit is contained in:
Ilya Rezvov
2018-04-19 13:32:07 -07:00
parent 1720730df5
commit a7962d69c2
2 changed files with 46 additions and 35 deletions
+13 -2
View File
@@ -95,8 +95,10 @@ runScript onAssertFail script = do
addModule ident m st =
case Validate.validate m of
Validate.Valid -> do
(modInst, store') <- Interpreter.instantiate (store st) (buildImports st) m
return $ addToStore ident modInst $ st { lastModule = Just modInst, store = store' }
res <- Interpreter.instantiate (store st) (buildImports st) m
case res of
Right (modInst, store') -> return $ addToStore ident modInst $ st { lastModule = Just modInst, store = store' }
Left reason -> error $ "Module instantiation failed dut to invalid module with reason: " ++ show reason
reason -> error $ "Module instantiation failed dut to invalid module with reason: " ++ show reason
getModule :: ScriptState -> Maybe Ident -> Maybe Interpreter.ModuleInstance
@@ -206,6 +208,15 @@ runScript onAssertFail script = do
case Binary.decodeModuleLazy binaryRep of
Right _ -> onAssertFail ("Module decoding should fail with failure string " ++ show failureString) assert
Left _ -> return ()
runAssert st assert@(AssertUnlinkable moduleDef failureString) =
let (_, m) = buildModule moduleDef in
case Validate.validate m of
Validate.Valid -> do
res <- Interpreter.instantiate (store st) (buildImports st) m
case res of
Left err -> return ()
Right _ -> onAssertFail ("Module linking should fail with failure string " ++ show failureString) assert
reason -> error $ "Module linking failed dut to invalid module with reason: " ++ show reason
runAssert _ _ = return ()
runCommand :: ScriptState -> Command -> IO ScriptState