more green test

This commit is contained in:
Ilya Rezvov
2023-08-21 19:28:54 -06:00
parent 724973b15e
commit a5ffe38a1c
3 changed files with 10 additions and 4 deletions
+2 -2
View File
@@ -948,7 +948,7 @@ eval budget store FunctionInstance { funcType, moduleInstance, code = Function {
let dest = fromIntegral d let dest = fromIntegral d
let len = fromIntegral n let len = fromIntegral n
dropped <- readIORef isDropped dropped <- readIORef isDropped
if dropped || src + len > LBS.length bytes || dest + len > size if (dropped && len > 0) || src + len > LBS.length bytes || dest + len > size
then return Trap then return Trap
else do else do
mapM_ (uncurry $ ByteArray.writeByteArray memory) $ zip [fromIntegral d..] $ mapM_ (uncurry $ ByteArray.writeByteArray memory) $ zip [fromIntegral d..] $
@@ -974,7 +974,7 @@ eval budget store FunctionInstance { funcType, moduleInstance, code = Function {
isDropped <- readIORef dropFlag isDropped <- readIORef dropFlag
if src + len > Vector.length refs if src + len > Vector.length refs
|| dst + len > MVector.length els || dst + len > MVector.length els
|| isDropped || (isDropped && len > 0)
|| isDeclarative mode || isDeclarative mode
then return Trap then return Trap
else do else do
+7 -1
View File
@@ -550,9 +550,15 @@ getExpressionTypeWithInput inp = fmap (inp `Arrow`) . foldM go inp
if isRef v if isRef v
then throwError $ TypeMismatch (empty ==> empty) (empty ==> empty) then throwError $ TypeMismatch (empty ==> empty) (empty ==> empty)
else matchStack stack (subst args) (subst res) else matchStack stack (subst args) (subst res)
matchStack (Var:stack) (NonRefVar:args) res =
let subst = replace NonRefVar NonRefVar in
matchStack stack (subst args) (subst res)
matchStack (NonRefVar:stack) (Var:args) res =
let subst = replace Var NonRefVar in
matchStack stack (subst args) (subst res)
matchStack stack [] res = return $ res ++ stack matchStack stack [] res = return $ res ++ stack
matchStack [] args res = throwError $ TypeMismatch ((reverse args) `Arrow` res) ([] `Arrow` []) matchStack [] args res = throwError $ TypeMismatch ((reverse args) `Arrow` res) ([] `Arrow` [])
matchStack _ _ _ = error "inconsistent checker state" matchStack st args res = error $ "inconsistent checker state: " ++ show (st, args, res)
getExpressionType :: Expression -> Checker Arrow getExpressionType :: Expression -> Checker Arrow
getExpressionType = getExpressionTypeWithInput [] getExpressionType = getExpressionTypeWithInput []
+1 -1
View File
@@ -19,7 +19,7 @@ main = do
files <- files <-
filter (not . List.isPrefixOf "simd") . filter (List.isSuffixOf ".wast") filter (not . List.isPrefixOf "simd") . filter (List.isSuffixOf ".wast")
<$> Directory.listDirectory "tests/spec" <$> Directory.listDirectory "tests/spec"
-- let files = ["imports.wast"] -- let files = ["unreached-valid.wast"]
scriptTestCases <- (`mapM` files) $ \file -> do scriptTestCases <- (`mapM` files) $ \file -> do
test <- LBS.readFile ("tests/spec/" ++ file) test <- LBS.readFile ("tests/spec/" ++ file)
return $ testCase file $ do return $ testCase file $ do