on master help sign in
WIP patch up some tests
commit5b689e2f1651bcb7f4f50cf0c8142c7cdf3fd31f authorAgentM <agentm@themactionfaction.com> dateFri 18 Nov 2016, 22:58 (10 years ago) parent1e42fdf
2 files changed+5−4
test/Relation/Basic.hs+1−1 test/Relation/StaticOptimizer.hs+4−3
test/Relation/Basic.hs+1−1
@@ -89,6 +89,6 @@ testMkRelation1 = TestCase $ assertEqual "key mismatch" (Left $ TupleAttributeTy
8989testMkRelationFromExprsBadAttrs :: Test
9090testMkRelationFromExprsBadAttrs = TestCase $ do
9191 let context = DBC.empty
92− case evalState (evalRelationalExpr (MakeRelationFromExprs (Just [AttributeAndTypeNameExpr "badAttr1" (PrimitiveTypeConstructor "Int" IntAtomType) ()]) [TupleExpr (M.singleton "badAttr2" (NakedAtomExpr (IntAtom 1)))])) context of
92+ case evalState (evalRelationalExpr (MakeRelationFromExprs (Just [AttributeAndTypeNameExpr "badAttr1" (PrimitiveTypeConstructor "Int" IntAtomType) ()]) [TupleExpr (M.singleton "badAttr2" (NakedAtomExpr (IntAtom 1)))])) (mkRelationalExprState context) of
9393 Left err -> assertEqual "tuple type mismatch" (TupleAttributeTypeMismatchError (A.attributesFromList [Attribute "badAttr2" IntAtomType])) err
9494 Right _ -> assertFailure "expected tuple type mismatch"
test/Relation/StaticOptimizer.hs+4−3
@@ -1,5 +1,6 @@
11import ProjectM36.Base
22import ProjectM36.Relation
3+import ProjectM36.RelationalExpression
34import ProjectM36.DateExamples
45import ProjectM36.TupleSet
56import ProjectM36.StaticOptimizer
@@ -13,16 +14,16 @@ main = do
1314 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
1415 where
1516 tests = relationOptTests ++ databaseOptTests
16− optTest optfunc testparams = map (\(name, expr, unopt) -> TestCase $ assertEqual name expr (evalState (optfunc unopt) dateExamples)) $ testparams
17+ optTest optfunc estate testparams = map (\(name, expr, unopt) -> TestCase $ assertEqual name expr (evalState (optfunc unopt) estate)) $ testparams
1718 relvar nam = RelationVariable nam ()
18− relationOptTests = optTest applyStaticRelationalOptimization [
19+ relationOptTests = optTest applyStaticRelationalOptimization (mkRelationalExprState dateExamples) [
1920 ("StaticProject", Right $ relvar "s", Project (AttributeNames (attributeNames suppliersRel)) (relvar "s")),
2021 ("StaticUnion", Right $ relvar "s", Union (relvar "s") (relvar "s")),
2122 ("StaticJoin", Right $ relvar "s", Join (relvar "s") (relvar "s")),
2223 ("StaticRestrictTrue", Right $ relvar "s", Restrict TruePredicate (relvar "s")),
2324 ("StaticRestrictFalse", Right $ MakeStaticRelation (attributes suppliersRel) emptyTupleSet, Restrict (NotPredicate TruePredicate) (relvar "s"))
2425 ]
25− databaseOptTests = optTest applyStaticDatabaseOptimization [
26+ databaseOptTests = optTest applyStaticDatabaseOptimization dateExamples [
2627 ("StaticAssign",
2728 Right $ Assign "z" (relvar "s"),
2829 Assign "z" (Restrict TruePredicate (relvar "s"))