@@ -12,7 +12,7 @@ main = do
1212 counts <- runTestTT (TestList tests)
1313 if errors counts + failures counts > 0 then exitFailure else exitSuccess
1414 where
15− tests = map (\(tutd, expected) -> TestCase $ assertTutdEqual basicDatabaseContext tutd expected) simpleRelTests ++ map (\(tutd, expected) -> TestCase $ assertTutdEqual dateExamples tutd expected) dateExampleRelTests
15+ tests = map (\(tutd, expected) -> TestCase $ assertTutdEqual basicDatabaseContext expected tutd) simpleRelTests ++ map (\(tutd, expected) -> TestCase $ assertTutdEqual dateExamples expected tutd) dateExampleRelTests
1616 simpleRelTests = [("x:=true", Right relationTrue),
1717 ("x:=false", Right relationFalse),
1818 ("x:=true union false", Right relationTrue),
@@ -22,6 +22,7 @@ main = do
2222 ("y:=relation{b int, c int}; x:=y{c}", mkRelation simpleProjectionAttributes HS.empty),
2323 ("x:=relation{tuple{a char(\"spam\"), b int(5)}}", mkRelation simpleCAttributes (HS.fromList $ map RelationTuple [M.fromList [("a", StringAtom "spam"),("b",IntAtom 5)]])),
2424 ("constraint failc true in false; x:=true", Left $ InclusionDependencyCheckError "failc"),
25+ ("x:=y; x:=true", Left $ RelVarNotDefinedError "y"),
2526 ("x:=true where true", Right relationTrue),
2627 ("x:=true where false", Right relationFalse),
2728 ("x:=true where true or false", Right relationTrue),
@@ -30,7 +31,7 @@ main = do
3031 ("x:=true where true and true", Right relationTrue),
3132 ("x:=true=true", Right relationTrue),
3233 ("x:=true=false", Right relationFalse),
33− ("x:=true; undefine x", Right relationTrue),
34+ ("x:=true; undefine x", Left (RelVarNotDefinedError "x")),
3435 ("x:=relation {b int, a char}; insert x relation{tuple{b int(5), a char(\"spam\")}}", mkRelation simpleCAttributes (HS.fromList [RelationTuple $ M.fromList [("a", StringAtom "spam"), ("b", IntAtom 5)]])),
3536 ("x:=relation{tuple{b int(5),a char(\"spam\")},tuple{b int(6),a char(\"sam\")}}; delete x where b=6", mkRelation simpleCAttributes $ HS.fromList [RelationTuple $ M.fromList [("a", StringAtom "spam"), ("b", IntAtom 5)]])
3637 ]
@@ -45,12 +46,10 @@ main = do
4546 ("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)
4647 ]
4748
48−testSimple1 = TestCase $ assertTutdEqual basicDatabaseContext "true" (Right relationTrue)
49−
50−assertTutdEqual databaseContext tutd expected = assertEqual tutd interpreted expected
49+assertTutdEqual databaseContext expected tutd = assertEqual tutd expected interpreted
5150 where
5251 interpreted = case interpret databaseContext tutd of
5352 (Just err, _) -> Left err
5453 (Nothing, context) -> case M.lookup "x" (relationVariables context) of
5554 Nothing -> Left $ RelVarNotDefinedError "x"
56− Just rel -> Right rel
55+ Just rel -> Right rel