more tests for digesting queries
This commit is contained in:
parent
42c992428a
commit
6255e7e4f2
@ -17,7 +17,7 @@ import Datalog.DigestedQuery (digestQuery)
|
|||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
describe "DigestedQuery" $ do
|
describe "DigestedQuery" $ do
|
||||||
it "can digest basic queries" $ do
|
it "can digest a basic query" $ do
|
||||||
digestQuery "?- parent(alice,X)." `shouldBe` DigestedQuery {
|
digestQuery "?- parent(alice,X)." `shouldBe` DigestedQuery {
|
||||||
allBoundVariables = ["X"],
|
allBoundVariables = ["X"],
|
||||||
numSoughtVariables = 1,
|
numSoughtVariables = 1,
|
||||||
@ -31,3 +31,46 @@ spec = do
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
it "can digest a query with all variables explicitly sought" $ do
|
||||||
|
digestQuery "?- knows(a,X), friend(X,Y) → X,Y." `shouldBe` DigestedQuery {
|
||||||
|
allBoundVariables = ["X", "Y"],
|
||||||
|
numSoughtVariables = 2,
|
||||||
|
conditions = [
|
||||||
|
DigestedQueryCondition {
|
||||||
|
__relation = "knows",
|
||||||
|
_entries = [
|
||||||
|
DigestedQueryEntryConstant $ Sym "a",
|
||||||
|
DigestedQueryEntryVariable 0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
DigestedQueryCondition {
|
||||||
|
__relation = "friend",
|
||||||
|
_entries = [
|
||||||
|
DigestedQueryEntryVariable 0,
|
||||||
|
DigestedQueryEntryVariable 1
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
it "can digest a query with unsought variables" $ do
|
||||||
|
digestQuery "?- edge(A,B), edge(B,C) → A,C ." `shouldBe` DigestedQuery {
|
||||||
|
allBoundVariables = ["A", "C", "B"],
|
||||||
|
numSoughtVariables = 2,
|
||||||
|
conditions = [
|
||||||
|
DigestedQueryCondition {
|
||||||
|
__relation = "edge",
|
||||||
|
_entries = [
|
||||||
|
DigestedQueryEntryVariable 0,
|
||||||
|
DigestedQueryEntryVariable 2
|
||||||
|
]
|
||||||
|
},
|
||||||
|
DigestedQueryCondition {
|
||||||
|
__relation = "edge",
|
||||||
|
_entries = [
|
||||||
|
DigestedQueryEntryVariable 2,
|
||||||
|
DigestedQueryEntryVariable 1
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user