@@ -34,7 +34,7 @@ main = do
34 tcounts <- runTestTT (TestList tests)
34 tcounts <- runTestTT (TestList tests)
35 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
35 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
37− 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, testFunctionalDependencies, testEmptyCommits]
37+ 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, testFunctionalDependencies, testEmptyCommits,testIntervalAtom]
38 simpleRelTests = [("x:=true", Right relationTrue),
38 simpleRelTests = [("x:=true", Right relationTrue),
39 ("x:=false", Right relationFalse),
39 ("x:=false", Right relationFalse),
40 ("x:=true union false", Right relationTrue),
40 ("x:=true union false", Right relationTrue),
@@ -118,7 +118,7 @@ main = do
118 ("x:=s; key testconstraint {s#,city} x; insert x relation{tuple{city \"London\", s# \"S1\", sname \"gonk\", status 50}}", Left (InclusionDependencyCheckError "testconstraint")),
118 ("x:=s; key testconstraint {s#,city} x; insert x relation{tuple{city \"London\", s# \"S1\", sname \"gonk\", status 50}}", Left (InclusionDependencyCheckError "testconstraint")),
119 ("y:=s; key testconstraint {s#} y; insert y relation{tuple{city \"London\", s# \"S6\", sname \"gonk\", status 50}}; x:=y{s#} = s{s#} union relation{tuple{s# \"S6\"}}", Right relationTrue),
119 ("y:=s; key testconstraint {s#} y; insert y relation{tuple{city \"London\", s# \"S6\", sname \"gonk\", status 50}}; x:=y{s#} = s{s#} union relation{tuple{s# \"S6\"}}", Right relationTrue),
120 --test binary bytestring data type
120 --test binary bytestring data type
121− ("x:=relation{tuple{y makeByteString(\"dGVzdGRhdGE=\")}}", mkRelationFromList byteStringAttributes [[ByteStringAtom (TE.encodeUtf8 "testdata")]]),
121+ ("x:=relation{tuple{y bytestring(\"dGVzdGRhdGE=\")}}", mkRelationFromList byteStringAttributes [[ByteStringAtom (TE.encodeUtf8 "testdata")]]),
122 --test Maybe Text
122 --test Maybe Text
123 ("x:=relation{tuple{a Just \"spam\"}}", mkRelationFromList simpleMaybeTextAttributes [[ConstructedAtom "Just" maybeTextAtomType [TextAtom "spam"]]]),
123 ("x:=relation{tuple{a Just \"spam\"}}", mkRelationFromList simpleMaybeTextAttributes [[ConstructedAtom "Just" maybeTextAtomType [TextAtom "spam"]]]),
124 --test Maybe Int
124 --test Maybe Int
@@ -434,4 +434,18 @@ testEmptyCommits = TestCase $ do
434 dirty''' <- disconnectedTransactionIsDirty sessionId dbconn
434 dirty''' <- disconnectedTransactionIsDirty sessionId dbconn
435 assertEqual "empty delete empty commit" (Right False) dirty'''
435 assertEqual "empty delete empty commit" (Right False) dirty'''
437−
437+testIntervalAtom :: Test
438+testIntervalAtom = TestCase $ do
439+ --test interval creation
440+ (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
441+ executeTutorialD sessionId dbconn "x:=relation{tuple{n 1, a interval(3,4,f,f), b interval(4,5,f,f)}, tuple{n 2,a interval(3,4,t,t), b interval(4,5,t,t)}}"
442+ --test failed interval creation
443+ let err1 = "AtomFunctionUserError InvalidIntervalOrdering"
444+ err2 = "AtomFunctionUserError (AtomTypeDoesNotSupportInterval \"Text\")"
445+ expectTutorialDErr sessionId dbconn (T.isPrefixOf err1) "z:=relation{tuple{a interval(4,3,f,f)}}"
446+ expectTutorialDErr sessionId dbconn (T.isPrefixOf err2) "z:=relation{tuple{a interval(\"s\",\"t\",f,f)}}"
448+ --test interval_overlaps
449+ executeTutorialD sessionId dbconn "y:=x:{c:=interval_overlaps(@a,@b)}"
450+ eRv <- executeRelationalExpr sessionId dbconn (Project (AttributeNames (S.fromList ["n","c"])) (RelationVariable "y" ()))
451+ assertEqual "interval overlap check" (mkRelationFromList (attributesFromList [Attribute "c" BoolAtomType,Attribute "n" IntAtomType]) [[BoolAtom True, IntAtom 1], [BoolAtom False, IntAtom 2]]) eRv