on master help sign in
finish haskell-database roundtrip atomable test
commitf7fe597cadeb1bf48b233ed5281a8d9a8f591c7f authorAgentM <agentm@themactionfaction.com> dateFri 31 Mar 2017, 16:17 (10 years ago) parent043c90e
1 file changed+16
test/Relation/ConstructedAtom.hs+16
test/Relation/ConstructedAtom.hs+16
@@ -7,8 +7,10 @@ import Control.DeepSeq
77import System.Exit
88import TutorialD.Interpreter.TestBase
99import GHC.Generics
10+import ProjectM36.Relation
1011import ProjectM36.Base
1112import Data.Text
13+import qualified Data.Map as M
1214
1315data Test1T = Test1C Int
1416 deriving (Generic, Show, Eq, Binary, NFData, Atomable)
@@ -45,6 +47,20 @@ testHaskell2DB = TestCase $ do
4547 expectedTest1TExpr = AddTypeConstructor (ADTypeConstructorDef "Test1T" []) [DataConstructorDef "Test1C" [DataConstructorDefTypeConstructorArg (PrimitiveTypeConstructor "Int" IntAtomType)]]
4648 assertEqual "simple ADT1" expectedTest1TExpr test1TExpr
4749 checkExecuteDatabaseContextExpr sessionId dbconn test1TExpr
50+ --execute some expressions involving Atomable data types
51+
52+ let createRelExpr = Assign "x" rel
53+
54+ rel = MakeRelationFromExprs Nothing
55+ [TupleExpr (M.singleton "a1" (NakedAtomExpr atomVal))]
56+ atomVal = toAtom exampleVal
57+ exampleVal = Test1C 10
58+ checkExecuteDatabaseContextExpr sessionId dbconn createRelExpr
59+
60+ let retrieveValExpr = Restrict (AttributeEqualityPredicate "a1" (NakedAtomExpr atomVal)) (RelationVariable "x" ())
61+ ret <- executeRelationalExpr sessionId dbconn retrieveValExpr
62+ let expectedRel = mkRelationFromList (attributesFromList [Attribute "a1" (toAtomType exampleVal)]) [[atomVal]]
63+ assertEqual "retrieve atomable atom" expectedRel ret
4864
4965testADT1 :: Test
5066testADT1 = TestCase $ do