on runtime_constructors help sign in
23 lines 852 B history raw
1{-# LANGUAGE OverloadedStrings #-}
2import Test.HUnit
3import ProjectM36.Base
4import ProjectM36.Atom
5import TutorialD.Interpreter.Import.TutorialD
6import System.Exit
7import System.IO.Temp
8import qualified Data.Map as M
9import System.IO
11main :: IO ()
12main = do
13 tcounts <- runTestTT $ TestList [testTutdImport]
14 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
16testTutdImport :: Test
17testTutdImport = TestCase $ do
18 withSystemTempFile "m.tutd" $ \tempPath handle -> do
19 hPutStrLn handle "x:=relation{tuple{a 5,b \"spam\"}}"
20 hClose handle
21 let expectedExpr = MultipleExpr [Assign "x" (MakeRelationFromExprs Nothing [TupleExpr (M.fromList [("a",NakedAtomExpr $ intAtom 5),("b",NakedAtomExpr $ textAtom "spam")])])]
22 imported <- importTutorialD tempPath
23 assertEqual "import tutd" (Right expectedExpr) imported