@@ -8,8 +8,6 @@ import qualified Data.HashSet as HS
8import qualified Data.Map as M
8import qualified Data.Map as M
9import System.Exit
9import System.Exit
14 counts <- runTestTT (TestList tests)
12 counts <- runTestTT (TestList tests)
15 if errors counts + failures counts > 0 then exitFailure else exitSuccess
13 if errors counts + failures counts > 0 then exitFailure else exitSuccess
@@ -22,6 +20,7 @@ main = do
22 ("x:=relation{a int}", mkRelation simpleAAttributes HS.empty),
20 ("x:=relation{a int}", mkRelation simpleAAttributes HS.empty),
23 ("x:=relation{c int} rename {c as d}", mkRelation simpleBAttributes HS.empty),
21 ("x:=relation{c int} rename {c as d}", mkRelation simpleBAttributes HS.empty),
24 ("y:=relation{b int, c int}; x:=y{c}", mkRelation simpleProjectionAttributes HS.empty),
22 ("y:=relation{b int, c int}; x:=y{c}", mkRelation simpleProjectionAttributes HS.empty),
23+ ("x:=relation{tuple{a char(\"spam\"), b int(5)}}", mkRelation simpleCAttributes (HS.fromList $ map RelationTuple [M.fromList [("a", StringAtom "spam"),("b",IntAtom 5)]])),
25 ("constraint failc true in false; x:=true", Left $ InclusionDependencyCheckError "failc"),
24 ("constraint failc true in false; x:=true", Left $ InclusionDependencyCheckError "failc"),
26 ("x:=true where true", Right relationTrue),
25 ("x:=true where true", Right relationTrue),
27 ("x:=true where false", Right relationFalse),
26 ("x:=true where false", Right relationFalse),
@@ -34,12 +33,13 @@ main = do
35 simpleAAttributes = M.fromList [("a", Attribute "a" IntAtomType)]
34 simpleAAttributes = M.fromList [("a", Attribute "a" IntAtomType)]
36 simpleBAttributes = M.fromList [("d", Attribute "d" IntAtomType)]
35 simpleBAttributes = M.fromList [("d", Attribute "d" IntAtomType)]
36+ simpleCAttributes = M.fromList [("a", Attribute "a" StringAtomType), ("b", Attribute "b" IntAtomType)]
37 simpleProjectionAttributes = M.fromList [("c", Attribute "c" IntAtomType)]
37 simpleProjectionAttributes = M.fromList [("c", Attribute "c" IntAtomType)]
38 dateExampleRelTests = [("x:=S where true", Right s),
38 dateExampleRelTests = [("x:=S where true", Right s),
39 ("x:=S where CITY = \"London\"", restrict (\(RelationTuple tupMap) -> tupMap M.! "CITY" == StringAtom "London") s),
39 ("x:=S where CITY = \"London\"", restrict (\(RelationTuple tupMap) -> tupMap M.! "CITY" == StringAtom "London") s),
40 ("x:=S where false", Right $ Relation (attributes s) HS.empty),
40 ("x:=S where false", Right $ Relation (attributes s) HS.empty),
41 ("a:=S; update a (STATUS:=50); x:=a{STATUS}", mkRelation (M.fromList [("STATUS", Attribute "STATUS" IntAtomType)]) (HS.fromList [RelationTuple $ M.fromList [("STATUS", IntAtom 50)]])),
41 ("a:=S; update a (STATUS:=50); x:=a{STATUS}", mkRelation (M.fromList [("STATUS", Attribute "STATUS" IntAtomType)]) (HS.fromList [RelationTuple $ M.fromList [("STATUS", IntAtom 50)]])),
42− ("x:=S; update x where SNAME=\"Blake\" (CITY:=\"Boston\")", relMap (\(RelationTuple tupMap) -> RelationTuple $ if (traceShowId tupMap) M.! "SNAME" == StringAtom "Blake" then M.insert "CITY" (StringAtom "Boston") tupMap else tupMap) s)
42+ ("x:=S; update x where SNAME=\"Blake\" (CITY:=\"Boston\")", relMap (\(RelationTuple tupMap) -> RelationTuple $ if tupMap M.! "SNAME" == StringAtom "Blake" then M.insert "CITY" (StringAtom "Boston") tupMap else tupMap) s)
45testSimple1 = TestCase $ assertTutdEqual basicDatabaseContext "true" (Right relationTrue)
45testSimple1 = TestCase $ assertTutdEqual basicDatabaseContext "true" (Right relationTrue)