Parse add.json in tests
This commit is contained in:
parent
4376596afd
commit
7874b384a5
|
|
@ -5,7 +5,9 @@ import Data.Aeson (eitherDecode, decode, toJSON, parseJSON, Result(..))
|
||||||
import Data.Aeson.Types (parse)
|
import Data.Aeson.Types (parse)
|
||||||
import Data.Text
|
import Data.Text
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import Data.Either
|
||||||
import Data.Function ((&))
|
import Data.Function ((&))
|
||||||
|
import Control.Exception (try)
|
||||||
|
|
||||||
import Test.HUnit
|
import Test.HUnit
|
||||||
import qualified System.Exit as Exit
|
import qualified System.Exit as Exit
|
||||||
|
|
@ -77,11 +79,20 @@ testInstrs = TestCase $ do
|
||||||
(eitherDecode "{\"op\": \"br\", \"labels\": [\"a\", \"b\"], \"args\": [\"z\"]}")
|
(eitherDecode "{\"op\": \"br\", \"labels\": [\"a\", \"b\"], \"args\": [\"z\"]}")
|
||||||
(Right $ B.EffectInstr B.Br ["z"] [] ["a", "b"])
|
(Right $ B.EffectInstr B.Br ["z"] [] ["a", "b"])
|
||||||
|
|
||||||
|
testProgramFromFiles :: Test
|
||||||
|
testProgramFromFiles = TestCase $ do
|
||||||
|
res <- try $ (B.parseBrilFromPath "bril-sources/add.json") :: IO (Either IOError (Either String B.Program))
|
||||||
|
case res of
|
||||||
|
(Right parseResult) -> assertBool "parse add.json" $ isRight parseResult
|
||||||
|
_ -> assertFailure "cannot open file"
|
||||||
|
|
||||||
|
|
||||||
tests :: Test
|
tests :: Test
|
||||||
tests = TestList [
|
tests = TestList [
|
||||||
TestLabel "bril parser: type" testTypes,
|
TestLabel "bril parser: type" testTypes,
|
||||||
TestLabel "bril parser: literal" testLiterals,
|
TestLabel "bril parser: literal" testLiterals,
|
||||||
TestLabel "bril parser: instruction" testInstrs
|
TestLabel "bril parser: instruction" testInstrs,
|
||||||
|
TestLabel "bril parser: parse files" testProgramFromFiles
|
||||||
]
|
]
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue