test: Rule met cut
This commit is contained in:
parent
8e6a34a231
commit
0a32797df1
1 changed files with 18 additions and 0 deletions
|
@ -17,6 +17,24 @@ class ControlOperatorsTests {
|
||||||
Program.clear()
|
Program.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `rule with cut as body`() {
|
||||||
|
Program.load(
|
||||||
|
listOf(
|
||||||
|
Rule(Atom("foo"), Cut()),
|
||||||
|
Fact(Atom("foo"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
val goal = Atom("foo")
|
||||||
|
|
||||||
|
val result = Program.query(goal).toList()
|
||||||
|
|
||||||
|
assertEquals(1, result.size, "Expected 1 result")
|
||||||
|
assertTrue(result[0].isSuccess, "Expected success")
|
||||||
|
assertTrue(result[0].getOrNull()!!.isEmpty(), "Expected empty substitutions")
|
||||||
|
}
|
||||||
|
|
||||||
// See also: https://stackoverflow.com/a/23292126
|
// See also: https://stackoverflow.com/a/23292126
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Reference in a new issue