@@ -55,7 +55,8 @@ main = do
5555 testEmptyCommits,
5656 testIntervalAtom,
5757 testListConstructedAtom,
58− testTypeChecker
58+ testTypeChecker,
59+ testRestrictionPredicateExprs
5960 ]
6061 simpleRelTests = [("x:=true", Right relationTrue),
6162 ("x:=false", Right relationFalse),
@@ -76,6 +77,8 @@ main = do
7677 ("x:=true where true or false", Right relationTrue),
7778 ("x:=true where false or false", Right relationFalse),
7879 ("x:=true where true and false", Right relationFalse),
80+ ("x:=true where false and true", Right relationFalse),
81+ ("x:=true where ^t and ^f", Right relationFalse),
7982 ("x:=true where true and true", Right relationTrue),
8083 ("x:=true=true", Right relationTrue),
8184 ("x:=true=false", Right relationFalse),
@@ -486,4 +489,19 @@ testTypeChecker = TestCase $ do
486489 (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
487490 let err1 = "AtomFunctionTypeError \"max\" 1 (RelationAtomType [Attribute \"_\" IntegerAtomType]) IntegerAtomType"
488491 expectTutorialDErr sessionId dbconn (T.isPrefixOf err1) "x:=relation{tuple{a 0}}:{b:=max(@a)}"
489−
492+
493+--exercise expression parser
494+testRestrictionPredicateExprs :: Test
495+testRestrictionPredicateExprs = TestCase $ do
496+ (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
497+ -- or
498+ executeTutorialD sessionId dbconn "x:=s where status=20 or status=10"
499+ eRvOr <- executeRelationalExpr sessionId dbconn (RelationVariable "x" ())
500+ let expectedRelOr = restrict (\tuple ->
501+ pure (elem (atomForAttributeName "status" tuple) [Right (IntegerAtom 10), Right (IntegerAtom 20)])) suppliersRel
502+ assertEqual "status 20 or 10" expectedRelOr eRvOr
503+ -- and
504+ executeTutorialD sessionId dbconn "x:=s where status=20 and status=10"
505+ eRvAnd <- executeRelationalExpr sessionId dbconn (RelationVariable "x" ())
506+ let expectedRelAnd = Right (emptyRelationWithAttrs (attributes suppliersRel))
507+ assertEqual "status 20 and 10" expectedRelAnd eRvAnd