Skip to content

Commit 88a3154

Browse files
committed
replace hardcoded tests with submodule to the official testsuit
1 parent bb881f7 commit 88a3154

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+24
-40114
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tests/spec"]
2+
path = tests/spec
3+
url = https://github.com/WebAssembly/testsuite

src/Language/Wasm/Interpreter.hs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import Data.Word (Word8, Word16, Word32, Word64)
3737
import Data.Int (Int32, Int64)
3838
import Numeric.Natural (Natural)
3939
import qualified Control.Monad as Monad
40-
import Data.Monoid ((<>))
4140
import Data.Bits (
4241
Bits,
4342
(.|.),

src/Language/Wasm/Lexer.x

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Language.Wasm.Lexer (
1313
import qualified Data.ByteString.Lazy as LBS
1414
import qualified Data.Char as Char
1515
import qualified Data.ByteString.Lazy.UTF8 as LBSUtf8
16-
import Control.Applicative ((<$>))
1716
import Control.Monad (when)
1817
import Numeric.IEEE (infinity, nan)
1918
import Language.Wasm.FloatUtils (makeNaN, doubleToFloat)

stack.yaml.lock

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file was autogenerated by Stack.
2+
# You should not edit this file by hand.
3+
# For more information, please see the documentation at:
4+
# https://docs.haskellstack.org/en/stable/lock_files
5+
6+
packages: []
7+
snapshots:
8+
- completed:
9+
size: 531707
10+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/5.yaml
11+
sha256: 9751e25e0af5713a53ddcfcc79564b082c71b1b357fadef0d85672a5b5ba3703
12+
original: lts-16.5

tests/Test.hs

+8-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ import qualified Data.ByteString.Lazy as LBS
1212

1313
import qualified Language.Wasm as Wasm
1414
import qualified Language.Wasm.Script as Script
15+
import qualified Data.List as List
1516

1617
main :: IO ()
1718
main = do
18-
files <- Directory.listDirectory "tests/samples"
19+
files <- filter (List.isSuffixOf ".wast") <$> Directory.listDirectory "tests/spec"
1920
scriptTestCases <- (`mapM` files) $ \file -> do
20-
Right script <- Wasm.parseScript <$> LBS.readFile ("tests/samples/" ++ file)
21+
test <- LBS.readFile ("tests/spec/" ++ file)
2122
return $ testCase file $ do
22-
Script.runScript (\msg assert -> assertFailure ("Failed assert: " ++ msg ++ ". Assert " ++ show assert)) script
23+
case Wasm.parseScript test of
24+
Right script ->
25+
Script.runScript (\msg assert -> assertFailure ("Failed assert: " ++ msg ++ ". Assert " ++ show assert)) script
26+
Left error ->
27+
assertFailure $ "Failed to parse with error: " ++ show error
2328
defaultMain $ testGroup "Wasm Core Test Suit" scriptTestCases

tests/samples/address.wast

-103
This file was deleted.

tests/samples/align.wast

-33
This file was deleted.

0 commit comments

Comments
 (0)