simplifying tests

This commit is contained in:
Felix Dilke 2026-01-26 12:25:44 +00:00
parent 219ff26a90
commit d8a1e2f9b1

View File

@ -41,6 +41,22 @@ spec = do
, "parent(\"bob\", \"carol\")." ]
[ "ancestor(X,Y) :- parent(X,Y)."
, "ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y)." ]
let parentRelation = Relation {
_name = "parent",
_arity = 2,
_tuples = Set.fromList [
[Var "X",Var "Z"]
],
_rules = []
}
let ancestorRelation = Relation {
_name = "ancestor",
_arity = 2,
_tuples = Set.fromList [
[Var "Z",Var "Y"]
],
_rules = []
}
constants db `shouldBe`
(Set.fromList $ Sym <$> ["alice", "bob", "carol"])
relations db `shouldBe`
@ -57,26 +73,12 @@ spec = do
headVariables = [ "X", "Y", "Z" ],
body = [
(
Relation {
_name = "parent",
_arity = 2,
_tuples = Set.fromList [
[Var "X",Var "Z" ]
],
_rules = []
}, [
parentRelation, [
RuleElementVariable "X",
RuleElementVariable "Z"
]
),(
Relation {
_name = "ancestor",
_arity = 2,
_tuples = Set.fromList [
[Var "Z",Var "Y"]
],
_rules = []
},[
ancestorRelation,[
RuleElementVariable "Z",
RuleElementVariable "Y"
]
@ -86,16 +88,7 @@ spec = do
]
}
),
("parent",
Relation {
_name = "parent",
_arity = 2,
_tuples = Set.fromList [
[Var "X",Var "Z"]
],
_rules = []
}
)
("parent", parentRelation )
]
it "can do basic queries" $ do