on c6898c3 help sign in
project-m36/TutorialDInterpreterTest.hs
29 lines 1.3 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
9main = runTestTT (TestList tests)
10 where
11 tests = map (\(tutd, expected) -> TestCase $ assertTutdEqual basicRelVarContext tutd expected) simpleRelTests
12 simpleRelTests = [("true", Right relationTrue),
13 ("false", Right relationFalse),
14 ("true union false", Right relationTrue),
15 ("true; false", Right relationFalse),
16 ("a:=relation{a int}", mkRelation simpleAAttributes HS.empty),
17 ("b:=relation{c int} rename {c as d}", mkRelation simpleBAttributes HS.empty),
18 ("a:=relation{b int, c int}; a{c}", mkRelation simpleProjectionAttributes HS.empty)
19 ]
20 simpleAAttributes = M.fromList [("a", Attribute "a" IntAtomType)]
21 simpleBAttributes = M.fromList [("d", Attribute "d" IntAtomType)]
22 simpleProjectionAttributes = M.fromList [("c", Attribute "c" IntAtomType)]
25testSimple1 = TestCase $ assertTutdEqual basicRelVarContext "true" (Right relationTrue)
27assertTutdEqual relVarContext tutd expected = assertEqual tutd interpreted expected
28 where
29 interpreted = fst (interpret relVarContext tutd)