Checkpoint
This commit is contained in:
parent
3724ac72f9
commit
7daae860fc
8 changed files with 119 additions and 9 deletions
|
@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test
|
|||
import prolog.ast.lists.List.Cons
|
||||
import prolog.ast.lists.List.Empty
|
||||
import prolog.ast.terms.Atom
|
||||
import prolog.ast.terms.Variable
|
||||
|
||||
class ListOperatorsTests {
|
||||
@Test
|
||||
|
@ -42,11 +43,23 @@ class ListOperatorsTests {
|
|||
assertTrue(result[0].getOrNull()!!.isEmpty(), "Expected empty substitution map")
|
||||
}
|
||||
|
||||
@Disabled("Not required functionality")
|
||||
@Test
|
||||
fun `member should only check shallow`() {
|
||||
val list = Cons(Atom("a"), Cons(Cons(Atom("b"), Empty), Empty))
|
||||
|
||||
var result = Member(Atom("a"), list).satisfy(emptyMap()).toList()
|
||||
assertEquals(1, result.size, "Expected one solution")
|
||||
assertTrue(result[0].isSuccess, "Expected success")
|
||||
assertTrue(result[0].getOrNull()!!.isEmpty(), "Expected empty substitution map")
|
||||
|
||||
result = Member(Atom("b"), list).satisfy(emptyMap()).toList()
|
||||
assertEquals(0, result.size, "Expected no solution")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `member with variable in list`() {
|
||||
val atom = Atom("a")
|
||||
val variable = Atom("X")
|
||||
val variable = Variable("X")
|
||||
val list = Cons(variable, Empty)
|
||||
|
||||
val member = Member(atom, list)
|
||||
|
|
Reference in a new issue