on c89964e help sign in
27 lines 1.1 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2import Test.HUnit
3import ProjectM36.Base
4import qualified ProjectM36.Attribute as A
5import TutorialD.Interpreter.Import.TutorialD
6import qualified Data.HashSet as HS
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 $ HS.singleton (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