on b5477e2 help sign in
project-m36/TutorialDInterpreterTest.hs
32 lines 1.4 kB history raw
1import TutorialDInterpreter
2import Test.HUnit
3import RelationExpr
4import Relation
5import RelationType
6import qualified Data.HashSet as HS
7import qualified Data.Map as M
8import System.Exit
10main = do
11 counts <- runTestTT (TestList tests)
12 if errors counts + failures counts > 0 then exitFailure else exitSuccess
13 where
14 tests = map (\(tutd, expected) -> TestCase $ assertTutdEqual basicRelVarContext tutd expected) simpleRelTests
15 simpleRelTests = [("true", Right relationTrue),
16 ("false", Right relationFalse),
17 ("true union false", Right relationTrue),
18 ("true; false", Right relationFalse),
19 ("a:=relation{a int}", mkRelation simpleAAttributes HS.empty),
20 ("b:=relation{c int} rename {c as d}", mkRelation simpleBAttributes HS.empty),
21 ("a:=relation{b int, c int}; a{c}", mkRelation simpleProjectionAttributes HS.empty)
22 ]
23 simpleAAttributes = M.fromList [("a", Attribute "a" IntAtomType)]
24 simpleBAttributes = M.fromList [("d", Attribute "d" IntAtomType)]
25 simpleProjectionAttributes = M.fromList [("c", Attribute "c" IntAtomType)]
28testSimple1 = TestCase $ assertTutdEqual basicRelVarContext "true" (Right relationTrue)
30assertTutdEqual relVarContext tutd expected = assertEqual tutd interpreted expected
31 where
32 interpreted = fst (interpret relVarContext tutd)