on master help sign in
fix isomorphic schema test
commit35e7f50563cc61d13d86502a3d4756ef35527a2c authorAgentM <agentm@themactionfaction.com> dateSat 19 Nov 2016, 23:37 (10 years ago) parentc07d85f
1 file changed+8−8
test/IsomorphicSchema.hs+8−8
test/IsomorphicSchema.hs+8−8
@@ -49,7 +49,7 @@ testSchemaValidation = TestCase $ do
4949testIsoRename :: Test
5050testIsoRename = TestCase $ do
5151 -- create a schema with two relvars and rename one while the other remains the same in the isomorphic schema
52− let schemaA = DBC.empty {
52+ let schemaA = mkRelationalExprState DBC.empty {
5353 relationVariables = M.fromList [("employee", relationTrue),
5454 ("department", relationFalse)]
5555 }
@@ -71,10 +71,10 @@ testIsoRestrict = TestCase $ do
7171 [TextAtom "Cindy", TextAtom "Steve"],
7272 [TextAtom "Sam", TextAtom "Steve"]]
7373 let predicate = AttributeEqualityPredicate "boss" (NakedAtomExpr (TextAtom ""))
74− bossRel <- assertEither $ evalState (evalRelationalExpr (Restrict predicate (ExistingRelation emprel))) DBC.empty
75− nonBossRel <- assertEither $ evalState (evalRelationalExpr (Restrict (NotPredicate predicate) (ExistingRelation emprel))) DBC.empty
74+ bossRel <- assertEither $ evalState (evalRelationalExpr (Restrict predicate (ExistingRelation emprel))) (mkRelationalExprState DBC.empty)
75+ nonBossRel <- assertEither $ evalState (evalRelationalExpr (Restrict (NotPredicate predicate) (ExistingRelation emprel))) (mkRelationalExprState DBC.empty)
7676
77− let schemaA = DBC.empty {
77+ let schemaA = mkRelationalExprState DBC.empty {
7878 relationVariables = M.fromList [("nonboss", nonBossRel),
7979 ("boss", bossRel)]
8080 }
@@ -92,11 +92,11 @@ testIsoRestrict = TestCase $ do
9292 bobRel <- assertEither (mkRelationFromList empattrs [[TextAtom "Bob", TextAtom ""]])
9393 let schemaBInsertExpr = Insert "employee" (ExistingRelation bobRel)
9494 schemaBInsertExpr' <- assertEither (processDatabaseContextExprInSchema (Schema isomorphsAtoB) schemaBInsertExpr)
95− let postInsertContext = execState (evalContextExpr schemaBInsertExpr') schemaA
96− expectedRel = evalState (evalRelationalExpr (Union (RelationVariable "boss" ()) (RelationVariable "nonboss" ()))) postInsertContext
95+ let postInsertContext = execState (evalContextExpr schemaBInsertExpr') (stateContext schemaA)
96+ expectedRel = evalState (evalRelationalExpr (Union (RelationVariable "boss" ()) (RelationVariable "nonboss" ()))) (mkRelationalExprState postInsertContext)
9797 --execute the expression against the schema and compare against the base context
9898 processedExpr <- assertEither (processRelationalExprInSchema (Schema isomorphsAtoB) (RelationVariable "employee" ()))
99− let processedRel = evalState (evalRelationalExpr processedExpr) postInsertContext
99+ let processedRel = evalState (evalRelationalExpr processedExpr) (mkRelationalExprState postInsertContext)
100100 assertEqual "insert bob boss" expectedRel processedRel
101101
102102testIsoUnion :: Test
@@ -109,7 +109,7 @@ testIsoUnion = TestCase $ do
109109 [TextAtom "Scooter", IntAtom 49],
110110 [TextAtom "Auto", IntAtom 200],
111111 [TextAtom "Tractor", IntAtom 500]]
112− let baseSchema = DBC.basicDatabaseContext {
112+ let baseSchema = mkRelationalExprState DBC.basicDatabaseContext {
113113 relationVariables = M.singleton "motor" motorsRel
114114 }
115115 splitPredicate = AtomExprPredicate (FunctionAtomExpr "lt" [AttributeAtomExpr "power", NakedAtomExpr (IntAtom 50)] ())