on 7bc78ff help sign in
26 lines 1.0 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2import Test.HUnit
3import ProjectM36.Base
4import qualified ProjectM36.Attribute as A
5import TutorialD.Interpreter.Import.TutorialD
6import System.Exit
7import System.IO.Temp
8import qualified ProjectM36.DatabaseContext as DC
9import qualified Data.Vector as V
10import 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" (ExistingRelation (Relation expectedAttrs $ RelationTupleSet [RelationTuple expectedAttrs $ V.fromList [IntAtom 5, StringAtom "spam"]]))]
24 expectedAttrs = A.attributesFromList [Attribute "a" IntAtomType, Attribute "b" StringAtomType]
25 imported <- importTutorialD tempPath DC.empty
26 assertEqual "import tutd" (Right expectedExpr) imported