on 3a76afa help sign in
27 lines 1.1 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 ProjectM36.DatabaseContext as DC
10import qualified Data.Vector as V
11import System.IO
14main :: IO ()
15main = do
16 tcounts <- runTestTT $ TestList [testTutdImport]
17 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
19testTutdImport :: Test
20testTutdImport = TestCase $ do
21 withSystemTempFile "m.tutd" $ \tempPath handle -> do
22 hPutStrLn handle "x:=relation{tuple{a 5,b \"spam\"}}"
23 hClose handle
24 let expectedExpr = MultipleExpr [Assign "x" (ExistingRelation (Relation expectedAttrs $ RelationTupleSet [RelationTuple expectedAttrs $ V.fromList [intAtom 5, stringAtom "spam"]]))]
25 expectedAttrs = A.attributesFromList [Attribute "a" intAtomType, Attribute "b" stringAtomType]
26 imported <- importTutorialD tempPath DC.empty
27 assertEqual "import tutd" (Right expectedExpr) imported