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