on master help sign in
add RelationalExprStateTupleElems test
commit3715eaa7674b6b2937c66d7eb126de57078416d7 authorAgentM <agentm@themactionfaction.com> dateSun 20 Nov 2016, 11:58 (10 years ago) parent35e7f50
1 file changed+17−1
test/TutorialD/Interpreter.hs+17−1
test/TutorialD/Interpreter.hs+17−1
@@ -33,7 +33,7 @@ main = do
3333 tcounts <- runTestTT (TestList tests)
3434 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
3535 where
36− tests = map (\(tutd, expected) -> TestCase $ assertTutdEqual basicDatabaseContext expected tutd) simpleRelTests ++ map (\(tutd, expected) -> TestCase $ assertTutdEqual dateExamples expected tutd) dateExampleRelTests ++ [transactionGraphBasicTest, transactionGraphAddCommitTest, transactionRollbackTest, transactionJumpTest, transactionBranchTest, simpleJoinTest, testNotification, testTypeConstructors, testMergeTransactions, testComments, testTransGraphRelationalExpr, failJoinTest, testMultiAttributeRename, testSchemaExpr]
36+ tests = map (\(tutd, expected) -> TestCase $ assertTutdEqual basicDatabaseContext expected tutd) simpleRelTests ++ map (\(tutd, expected) -> TestCase $ assertTutdEqual dateExamples expected tutd) dateExampleRelTests ++ [transactionGraphBasicTest, transactionGraphAddCommitTest, transactionRollbackTest, transactionJumpTest, transactionBranchTest, simpleJoinTest, testNotification, testTypeConstructors, testMergeTransactions, testComments, testTransGraphRelationalExpr, failJoinTest, testMultiAttributeRename, testSchemaExpr, testRelationalExprStateTupleElems]
3737 simpleRelTests = [("x:=true", Right relationTrue),
3838 ("x:=false", Right relationFalse),
3939 ("x:=true union false", Right relationTrue),
@@ -369,3 +369,19 @@ assertEither x = case x of
369369 Left err -> assertFailure (show err) >> undefined
370370 Right val -> pure val
371371
372+-- | Validate that a tuple passed through the context correctly typechecks and propagates to the AttributeAtomExpr.
373+testRelationalExprStateTupleElems :: Test
374+testRelationalExprStateTupleElems = TestCase $ do
375+ (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
376+ executeTutorialD sessionId dbconn "x := (s : { parts := p rename {city as pcity} where pcity=@city}) : {z:=count(@parts)}"
377+
378+ executeTutorialD sessionId dbconn "y:=x{city,z}"
379+ eRv <- executeRelationalExpr sessionId dbconn (RelationVariable "y" ())
380+ let expectedRel = mkRelationFromList (attributesFromList [Attribute "city" TextAtomType,
381+ Attribute "z" IntAtomType])
382+ [[TextAtom "Paris", IntAtom 2],
383+ [TextAtom "London", IntAtom 3],
384+ [TextAtom "Athens", IntAtom 0]]
385+ assertEqual "validate parts count" expectedRel eRv
386+
387+