on f25ce68 help sign in
25 lines 1.0 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2import Test.HUnit
3import ProjectM36.Base
4import ProjectM36.Atom
5import qualified ProjectM36.Attribute as A
6import TutorialD.Interpreter.Import.TutorialD
7import System.Exit
8import System.IO.Temp
9import qualified Data.Vector as V
10import System.IO
12main :: IO ()
13main = do
14 tcounts <- runTestTT $ TestList [testTutdImport]
15 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
17testTutdImport :: Test
18testTutdImport = TestCase $ do
19 withSystemTempFile "m.tutd" $ \tempPath handle -> do
20 hPutStrLn handle "x:=relation{tuple{a 5,b \"spam\"}}"
21 hClose handle
22 let expectedExpr = MultipleExpr [Assign "x" (ExistingRelation (Relation expectedAttrs $ RelationTupleSet [RelationTuple expectedAttrs $ V.fromList [intAtom 5, stringAtom "spam"]]))]
23 expectedAttrs = A.attributesFromList [Attribute "a" intAtomType, Attribute "b" stringAtomType]
24 imported <- importTutorialD tempPath
25 assertEqual "import tutd" (Right expectedExpr) imported