test: Cut with disjunction
This commit is contained in:
parent
2fcab52f65
commit
f9950a3fd3
2 changed files with 25 additions and 2 deletions
|
@ -1,2 +1 @@
|
|||
not_equal(X, Y) :- X = Y, !, fail.
|
||||
not_equal(_, _).
|
||||
choice(X) :- X = 1, !; X = 2.
|
||||
|
|
|
@ -177,6 +177,30 @@ class ControlOperatorsTests {
|
|||
assertEquals(1, result.size, "Expected 1 result")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `cut with disjunction`() {
|
||||
Program.load(
|
||||
listOf(
|
||||
Rule(
|
||||
CompoundTerm(Atom("choice"), listOf(Variable("X"))),
|
||||
Conjunction(
|
||||
Unify(Variable("X"), Integer(1)),
|
||||
Disjunction(
|
||||
Cut(),
|
||||
Unify(Variable("X"), Integer(2))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val goal = CompoundTerm(Atom("choice"), listOf(Variable("X")))
|
||||
|
||||
val result = Program.query(goal).toList()
|
||||
|
||||
assertEquals(1, result.size, "Expected 1 result")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun not_atom() {
|
||||
val success = Fact(Atom("a"))
|
||||
|
|
Reference in a new issue