Checkpoint
This commit is contained in:
parent
3724ac72f9
commit
7daae860fc
8 changed files with 119 additions and 9 deletions
|
@ -15,7 +15,10 @@ import prolog.ast.terms.Structure
|
|||
import prolog.ast.terms.Variable
|
||||
import prolog.ast.Database.Program
|
||||
import prolog.ast.arithmetic.Integer
|
||||
import prolog.ast.lists.List.Empty
|
||||
import prolog.ast.lists.List.Cons
|
||||
import prolog.ast.terms.AnonymousVariable
|
||||
import prolog.builtins.Unify
|
||||
|
||||
class EvaluationTests {
|
||||
@BeforeEach
|
||||
|
@ -479,4 +482,20 @@ class EvaluationTests {
|
|||
assertEquals(1, subs3c.size, "Expected 1 substitution")
|
||||
assertEquals(Structure(Atom("s"), listOf(Structure(Atom("s"), listOf(Integer(0))))), subs3c[Variable("X")], "Expected X to be s(s(0))")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `foo(emptyList) = foo(X)`() {
|
||||
val list = Empty
|
||||
val left = Structure(Atom("foo"), listOf(list))
|
||||
val right = Structure(Atom("foo"), listOf(Variable("X")))
|
||||
|
||||
val unific = Unify(left, right)
|
||||
val result = unific.satisfy(emptyMap()).toList()
|
||||
|
||||
assertEquals(1, result.size, "Expected 1 result")
|
||||
assertTrue(result[0].isSuccess, "Expected success")
|
||||
val subs = result[0].getOrNull()!!
|
||||
assertEquals(1, subs.size, "Expected 1 substitution")
|
||||
assertEquals(list, subs[Variable("X")], "Expected X to be list(1, 2)")
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue