@@ -8,8 +8,6 @@ import qualified Data.HashSet as HS
88import qualified Data.Map as M
99import System.Exit
1010
11−import Debug.Trace
12−
1311main = do
1412 counts <- runTestTT (TestList tests)
1513 if errors counts + failures counts > 0 then exitFailure else exitSuccess
@@ -22,6 +20,7 @@ main = do
2220 ("x:=relation{a int}", mkRelation simpleAAttributes HS.empty),
2321 ("x:=relation{c int} rename {c as d}", mkRelation simpleBAttributes HS.empty),
2422 ("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)]])),
2524 ("constraint failc true in false; x:=true", Left $ InclusionDependencyCheckError "failc"),
2625 ("x:=true where true", Right relationTrue),
2726 ("x:=true where false", Right relationFalse),
@@ -34,12 +33,13 @@ main = do
3433 ]
3534 simpleAAttributes = M.fromList [("a", Attribute "a" IntAtomType)]
3635 simpleBAttributes = M.fromList [("d", Attribute "d" IntAtomType)]
36+ simpleCAttributes = M.fromList [("a", Attribute "a" StringAtomType), ("b", Attribute "b" IntAtomType)]
3737 simpleProjectionAttributes = M.fromList [("c", Attribute "c" IntAtomType)]
3838 dateExampleRelTests = [("x:=S where true", Right s),
3939 ("x:=S where CITY = \"London\"", restrict (\(RelationTuple tupMap) -> tupMap M.! "CITY" == StringAtom "London") s),
4040 ("x:=S where false", Right $ Relation (attributes s) HS.empty),
4141 ("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)
4343 ]
4444
4545testSimple1 = TestCase $ assertTutdEqual basicDatabaseContext "true" (Right relationTrue)