@@ -3,7 +3,7 @@ import TutorialD.Interpreter.TestBase
3import TutorialD.Interpreter
3import TutorialD.Interpreter
4import TutorialD.Interpreter.Base
4import TutorialD.Interpreter.Base
5import Test.HUnit
5import Test.HUnit
6−import ProjectM36.Relation
6+import ProjectM36.Relation as R
7import ProjectM36.Tuple
7import ProjectM36.Tuple
8import ProjectM36.TupleSet
8import ProjectM36.TupleSet
9import ProjectM36.Error
9import ProjectM36.Error
@@ -121,7 +121,7 @@ main = do
121 simpleEitherIntTextAttributes = A.attributesFromList [Attribute "a" (eitherAtomType IntegerAtomType TextAtomType)]
121 simpleEitherIntTextAttributes = A.attributesFromList [Attribute "a" (eitherAtomType IntegerAtomType TextAtomType)]
122 simpleProjectionAttributes = A.attributesFromList [Attribute "c" IntegerAtomType]
122 simpleProjectionAttributes = A.attributesFromList [Attribute "c" IntegerAtomType]
123 nestedRelationAttributes = A.attributesFromList [Attribute "a" IntegerAtomType, Attribute "b" (RelationAtomType $ A.attributesFromList [Attribute "a" IntegerAtomType])]
123 nestedRelationAttributes = A.attributesFromList [Attribute "a" IntegerAtomType, Attribute "b" (RelationAtomType $ A.attributesFromList [Attribute "a" IntegerAtomType])]
124− extendTestAttributes = A.attributesFromList [Attribute "a" IntegerAtomType, Attribute "b" $ RelationAtomType (attributes suppliersRel)]
124+ extendTestAttributes = A.attributesFromList [Attribute "a" IntegerAtomType, Attribute "b" $ RelationAtomType (R.attributes suppliersRel)]
125 byteStringAttributes = A.attributesFromList [Attribute "y" ByteStringAtomType]
125 byteStringAttributes = A.attributesFromList [Attribute "y" ByteStringAtomType]
126 groupCountAttrs = A.attributesFromList [Attribute "z" IntegerAtomType]
126 groupCountAttrs = A.attributesFromList [Attribute "z" IntegerAtomType]
127 minMaxAttrs = A.attributesFromList [Attribute "s#" TextAtomType, Attribute "z" IntegerAtomType]
127 minMaxAttrs = A.attributesFromList [Attribute "s#" TextAtomType, Attribute "z" IntegerAtomType]
@@ -133,10 +133,10 @@ main = do
133 else Right tuple) suppliersRel
133 else Right tuple) suppliersRel
134 dateExampleRelTests = [("x:=s where true", Right suppliersRel),
134 dateExampleRelTests = [("x:=s where true", Right suppliersRel),
135 ("x:=s where city = \"London\"", restrict (\tuple -> pure $ atomForAttributeName "city" tuple == (Right $ TextAtom "London")) suppliersRel),
135 ("x:=s where city = \"London\"", restrict (\tuple -> pure $ atomForAttributeName "city" tuple == (Right $ TextAtom "London")) suppliersRel),
136− ("x:=s where false", Right $ Relation (attributes suppliersRel) emptyTupleSet),
136+ ("x:=s where false", Right $ Relation (R.attributes suppliersRel) emptyTupleSet),
137− ("x:=p where color=\"Blue\" and city=\"Paris\"", mkRelationFromList (attributes productsRel) [[TextAtom "P5", TextAtom "Cam", TextAtom "Blue", IntegerAtom 12, TextAtom "Paris"]]),
137+ ("x:=p where color=\"Blue\" and city=\"Paris\"", mkRelationFromList (R.attributes productsRel) [[TextAtom "P5", TextAtom "Cam", TextAtom "Blue", IntegerAtom 12, TextAtom "Paris"]]),
138 ("a:=s; update a (status:=50); x:=a{status}", mkRelation (A.attributesFromList [Attribute "status" IntegerAtomType]) (RelationTupleSet [mkRelationTuple (A.attributesFromList [Attribute "status" IntegerAtomType]) (V.fromList [IntegerAtom 50])])),
138 ("a:=s; update a (status:=50); x:=a{status}", mkRelation (A.attributesFromList [Attribute "status" IntegerAtomType]) (RelationTupleSet [mkRelationTuple (A.attributesFromList [Attribute "status" IntegerAtomType]) (V.fromList [IntegerAtom 50])])),
139− ("x:=s minus (s where status=20)", mkRelationFromList (attributes suppliersRel) [[TextAtom "S2", TextAtom "Jones", IntegerAtom 10, TextAtom "Paris"], [TextAtom "S3", TextAtom "Blake", IntegerAtom 30, TextAtom "Paris"], [TextAtom "S5", TextAtom "Adams", IntegerAtom 30, TextAtom "Athens"]]),
139+ ("x:=s minus (s where status=20)", mkRelationFromList (R.attributes suppliersRel) [[TextAtom "S2", TextAtom "Jones", IntegerAtom 10, TextAtom "Paris"], [TextAtom "S3", TextAtom "Blake", IntegerAtom 30, TextAtom "Paris"], [TextAtom "S5", TextAtom "Adams", IntegerAtom 30, TextAtom "Athens"]]),
140 --atom function tests
140 --atom function tests
141 ("x:=((s : {status2 := add(10,@status)}) where status2=add(10,@status)){city,s#,sname,status}", Right suppliersRel),
141 ("x:=((s : {status2 := add(10,@status)}) where status2=add(10,@status)){city,s#,sname,status}", Right suppliersRel),
142 ("x:=relation{tuple{a 5}} : {b:=s}", mkRelation extendTestAttributes (RelationTupleSet [mkRelationTuple extendTestAttributes (V.fromList [IntegerAtom 5, RelationAtom suppliersRel])])),
142 ("x:=relation{tuple{a 5}} : {b:=s}", mkRelation extendTestAttributes (RelationTupleSet [mkRelationTuple extendTestAttributes (V.fromList [IntegerAtom 5, RelationAtom suppliersRel])])),
@@ -149,11 +149,11 @@ main = do
149 ("x:=((sp{s#,qty}) group ({qty} as x):{z:=min(@x)}){s#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [TextAtom s,IntegerAtom i]) [("S1", 100), ("S2", 300), ("S3", 200), ("S4", 200)])),
149 ("x:=((sp{s#,qty}) group ({qty} as x):{z:=min(@x)}){s#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [TextAtom s,IntegerAtom i]) [("S1", 100), ("S2", 300), ("S3", 200), ("S4", 200)])),
150 ("x:=((sp{s#,qty}) group ({qty} as x):{z:=sum(@x)}){s#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [TextAtom s,IntegerAtom i]) [("S1", 1000), ("S2", 700), ("S3", 200), ("S4", 900)])),
150 ("x:=((sp{s#,qty}) group ({qty} as x):{z:=sum(@x)}){s#,z}", mkRelationFromList minMaxAttrs (map (\(s,i) -> [TextAtom s,IntegerAtom i]) [("S1", 1000), ("S2", 700), ("S3", 200), ("S4", 900)])),
151 --boolean function restriction
151 --boolean function restriction
152− ("x:=s where ^lt(@status,20)", mkRelationFromList (attributes suppliersRel) [[TextAtom "S2", TextAtom "Jones", IntegerAtom 10, TextAtom "Paris"]]),
152+ ("x:=s where ^lt(@status,20)", mkRelationFromList (R.attributes suppliersRel) [[TextAtom "S2", TextAtom "Jones", IntegerAtom 10, TextAtom "Paris"]]),
153− ("x:=s where ^gt(@status,20)", mkRelationFromList (attributes suppliersRel) [[TextAtom "S3", TextAtom "Blake", IntegerAtom 30, TextAtom "Paris"],
153+ ("x:=s where ^gt(@status,20)", mkRelationFromList (R.attributes suppliersRel) [[TextAtom "S3", TextAtom "Blake", IntegerAtom 30, TextAtom "Paris"],
154 [TextAtom "S5", TextAtom "Adams", IntegerAtom 30, TextAtom "Athens"]]),
154 [TextAtom "S5", TextAtom "Adams", IntegerAtom 30, TextAtom "Athens"]]),
155 ("x:=s where ^sum(@status)", Left $ AtomTypeMismatchError IntegerAtomType BoolAtomType),
155 ("x:=s where ^sum(@status)", Left $ AtomTypeMismatchError IntegerAtomType BoolAtomType),
156− ("x:=s where ^not(gte(@status,20))", mkRelationFromList (attributes suppliersRel) [[TextAtom "S2", TextAtom "Jones", IntegerAtom 10, TextAtom "Paris"]]),
156+ ("x:=s where ^not(gte(@status,20))", mkRelationFromList (R.attributes suppliersRel) [[TextAtom "S2", TextAtom "Jones", IntegerAtom 10, TextAtom "Paris"]]),
157 --test "all but" attribute inversion syntax
157 --test "all but" attribute inversion syntax
158 ("x:=s{all but s#} = s{city,sname,status}", Right relationTrue),
158 ("x:=s{all but s#} = s{city,sname,status}", Right relationTrue),
159 --test key syntax
159 --test key syntax
@@ -202,6 +202,7 @@ transactionGraphAddCommitTest = TestCase $ do
202 DisplayResult _ -> assertFailure "display?"
202 DisplayResult _ -> assertFailure "display?"
203 DisplayIOResult _ -> assertFailure "displayIO?"
203 DisplayIOResult _ -> assertFailure "displayIO?"
204 DisplayRelationResult _ -> assertFailure "displayrelation?"
204 DisplayRelationResult _ -> assertFailure "displayrelation?"
205+ DisplayDataFrameResult _ -> assertFailure "displaydataframe?"
205 DisplayParseErrorResult _ _ -> assertFailure "displayparseerror?"
206 DisplayParseErrorResult _ _ -> assertFailure "displayparseerror?"
206 DisplayErrorResult err -> assertFailure (show err)
207 DisplayErrorResult err -> assertFailure (show err)
207 QuietSuccessResult -> do
208 QuietSuccessResult -> do
@@ -522,7 +523,7 @@ testRestrictionPredicateExprs = TestCase $ do
523 executeTutorialD sessionId dbconn "x:=s where status=20 and status=10"
524 executeTutorialD sessionId dbconn "x:=s where status=20 and status=10"
524 eRvAnd <- executeRelationalExpr sessionId dbconn (RelationVariable "x" ())
525 eRvAnd <- executeRelationalExpr sessionId dbconn (RelationVariable "x" ())
525− let expectedRelAnd = Right (emptyRelationWithAttrs (attributes suppliersRel))
526+ let expectedRelAnd = Right (emptyRelationWithAttrs (R.attributes suppliersRel))
526 assertEqual "status 20 and 10" expectedRelAnd eRvAnd
527 assertEqual "status 20 and 10" expectedRelAnd eRvAnd
528testRelationalAttributeNames :: Test
529testRelationalAttributeNames :: Test
@@ -533,7 +534,7 @@ testRelationalAttributeNames = TestCase $ do
533 case eRv of
534 case eRv of
534 Left err -> assertFailure (show err)
535 Left err -> assertFailure (show err)
535 Right rel ->
536 Right rel ->
536− assertEqual "attributes from sp" (attributes supplierProductsRel) (attributes rel)
537+ assertEqual "attributes from sp" (R.attributes supplierProductsRel) (R.attributes rel)
538testSemijoin :: Test
539testSemijoin :: Test
539testSemijoin = TestCase $ do
540testSemijoin = TestCase $ do