simplifying tests
This commit is contained in:
parent
219ff26a90
commit
d8a1e2f9b1
@ -41,6 +41,22 @@ spec = do
|
|||||||
, "parent(\"bob\", \"carol\")." ]
|
, "parent(\"bob\", \"carol\")." ]
|
||||||
[ "ancestor(X,Y) :- parent(X,Y)."
|
[ "ancestor(X,Y) :- parent(X,Y)."
|
||||||
, "ancestor(X,Y) :- parent(X,Z), ancestor(Z,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`
|
constants db `shouldBe`
|
||||||
(Set.fromList $ Sym <$> ["alice", "bob", "carol"])
|
(Set.fromList $ Sym <$> ["alice", "bob", "carol"])
|
||||||
relations db `shouldBe`
|
relations db `shouldBe`
|
||||||
@ -57,26 +73,12 @@ spec = do
|
|||||||
headVariables = [ "X", "Y", "Z" ],
|
headVariables = [ "X", "Y", "Z" ],
|
||||||
body = [
|
body = [
|
||||||
(
|
(
|
||||||
Relation {
|
parentRelation, [
|
||||||
_name = "parent",
|
|
||||||
_arity = 2,
|
|
||||||
_tuples = Set.fromList [
|
|
||||||
[Var "X",Var "Z" ]
|
|
||||||
],
|
|
||||||
_rules = []
|
|
||||||
}, [
|
|
||||||
RuleElementVariable "X",
|
RuleElementVariable "X",
|
||||||
RuleElementVariable "Z"
|
RuleElementVariable "Z"
|
||||||
]
|
]
|
||||||
),(
|
),(
|
||||||
Relation {
|
ancestorRelation,[
|
||||||
_name = "ancestor",
|
|
||||||
_arity = 2,
|
|
||||||
_tuples = Set.fromList [
|
|
||||||
[Var "Z",Var "Y"]
|
|
||||||
],
|
|
||||||
_rules = []
|
|
||||||
},[
|
|
||||||
RuleElementVariable "Z",
|
RuleElementVariable "Z",
|
||||||
RuleElementVariable "Y"
|
RuleElementVariable "Y"
|
||||||
]
|
]
|
||||||
@ -86,16 +88,7 @@ spec = do
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
("parent",
|
("parent", parentRelation )
|
||||||
Relation {
|
|
||||||
_name = "parent",
|
|
||||||
_arity = 2,
|
|
||||||
_tuples = Set.fromList [
|
|
||||||
[Var "X",Var "Z"]
|
|
||||||
],
|
|
||||||
_rules = []
|
|
||||||
}
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
it "can do basic queries" $ do
|
it "can do basic queries" $ do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user