@@ -95,12 +95,12 @@ runScript onAssertFail script = do
95
95
addModule :: Maybe Ident -> Struct. Module -> ScriptState -> IO ScriptState
96
96
addModule ident m st =
97
97
case Validate. validate m of
98
- Validate. Valid -> do
98
+ Right m -> do
99
99
res <- Interpreter. instantiate (store st) (buildImports st) m
100
100
case res of
101
101
Right (modInst, store') -> return $ addToStore ident modInst $ st { lastModule = Just modInst, store = store' }
102
102
Left reason -> error $ " Module instantiation failed dut to invalid module with reason: " ++ show reason
103
- reason -> error $ " Module instantiation failed dut to invalid module with reason: " ++ show reason
103
+ Left reason -> error $ " Module instantiation failed dut to invalid module with reason: " ++ show reason
104
104
105
105
getModule :: ScriptState -> Maybe Ident -> Maybe Interpreter. ModuleInstance
106
106
getModule st (Just (Ident i)) = Map. lookup i (modules st)
@@ -156,7 +156,7 @@ runScript onAssertFail script = do
156
156
checkModuleInvalid :: Struct. Module -> IO ()
157
157
checkModuleInvalid _ = return ()
158
158
159
- getFailureString :: Validate. ValidationResult -> [TL. Text ]
159
+ getFailureString :: Validate. ValidationError -> [TL. Text ]
160
160
getFailureString (Validate. TypeMismatch _ _) = [" type mismatch" ]
161
161
getFailureString Validate. ResultTypeDoesntMatch = [" type mismatch" ]
162
162
getFailureString Validate. MoreThanOneMemory = [" multiple memories" ]
@@ -194,8 +194,8 @@ runScript onAssertFail script = do
194
194
runAssert st assert@ (AssertInvalid moduleDef failureString) =
195
195
let (_, m) = buildModule moduleDef in
196
196
case Validate. validate m of
197
- Validate. Valid -> onAssertFail " Invalid module pass validation" assert
198
- reason ->
197
+ Right _ -> onAssertFail " Invalid module pass validation" assert
198
+ Left reason ->
199
199
if failureString `elem` getFailureString reason
200
200
then return ()
201
201
else
@@ -216,12 +216,12 @@ runScript onAssertFail script = do
216
216
runAssert st assert@ (AssertUnlinkable moduleDef failureString) =
217
217
let (_, m) = buildModule moduleDef in
218
218
case Validate. validate m of
219
- Validate. Valid -> do
219
+ Right m -> do
220
220
res <- Interpreter. instantiate (store st) (buildImports st) m
221
221
case res of
222
222
Left err -> return ()
223
223
Right _ -> onAssertFail (" Module linking should fail with failure string " ++ show failureString) assert
224
- reason -> error $ " Module linking failed dut to invalid module with reason: " ++ show reason
224
+ Left reason -> error $ " Module linking failed dut to invalid module with reason: " ++ show reason
225
225
runAssert st assert@ (AssertTrap (Left action) failureString) = do
226
226
result <- runAction st action
227
227
if isNothing result
@@ -230,12 +230,12 @@ runScript onAssertFail script = do
230
230
runAssert st assert@ (AssertTrap (Right moduleDef) failureString) =
231
231
let (_, m) = buildModule moduleDef in
232
232
case Validate. validate m of
233
- Validate. Valid -> do
233
+ Right m -> do
234
234
res <- Interpreter. instantiate (store st) (buildImports st) m
235
235
case res of
236
236
Left " Start function terminated with trap" -> return ()
237
237
_ -> onAssertFail (" Module linking should fail with trap during execution of a start function" ) assert
238
- reason -> error $ " Module linking failed dut to invalid module with reason: " ++ show reason
238
+ Left reason -> error $ " Module linking failed dut to invalid module with reason: " ++ show reason
239
239
runAssert st assert@ (AssertExhaustion action failureString) = do
240
240
result <- runAction st action
241
241
if isNothing result
0 commit comments