Checkpoint
This commit is contained in:
parent
3724ac72f9
commit
7daae860fc
8 changed files with 119 additions and 9 deletions
|
@ -375,8 +375,16 @@ class UnificationTests {
|
|||
class `equivalent logic` {
|
||||
@Test
|
||||
fun `empty lists are equivalent`() {
|
||||
val eq = equivalent(Empty, Empty, emptyMap())
|
||||
var eq = equivalent(Empty, Empty, emptyMap())
|
||||
assertTrue(eq, "Empty lists should be equivalent")
|
||||
|
||||
val variable = Variable("X")
|
||||
|
||||
eq = equivalent(Empty, variable, mapOf(variable to Empty))
|
||||
assertTrue(eq, "Empty list and variable should be equivalent")
|
||||
|
||||
eq = equivalent(variable, Empty, mapOf(variable to Empty))
|
||||
assertTrue(eq, "Variable and empty list should be equivalent")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -385,9 +393,16 @@ class UnificationTests {
|
|||
val list1 = Cons(atom, Empty)
|
||||
val list2 = Cons(atom, Empty)
|
||||
|
||||
val eq = equivalent(list1, list2, emptyMap())
|
||||
|
||||
var eq = equivalent(list1, list2, emptyMap())
|
||||
assertTrue(eq, "Singleton lists should be equivalent")
|
||||
|
||||
val variable = Variable("X")
|
||||
|
||||
eq = equivalent(list1, variable, mapOf(variable to list2))
|
||||
assertTrue(eq, "Singleton list and variable should be equivalent")
|
||||
|
||||
eq = equivalent(variable, list1, mapOf(variable to list2))
|
||||
assertTrue(eq, "Variable and singleton list should be equivalent")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -401,6 +416,14 @@ class UnificationTests {
|
|||
|
||||
eq = equivalent(list2, list1, emptyMap())
|
||||
assertFalse(eq, "Empty and singleton lists should not be equivalent")
|
||||
|
||||
val variable = Variable("X")
|
||||
|
||||
eq = equivalent(list1, variable, mapOf(variable to list2))
|
||||
assertFalse(eq, "Singleton list and variable should not be equivalent")
|
||||
|
||||
eq = equivalent(variable, list1, mapOf(variable to list2))
|
||||
assertFalse(eq, "Variable and singleton list should not be equivalent")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -413,6 +436,14 @@ class UnificationTests {
|
|||
|
||||
eq = equivalent(list2, list1, emptyMap())
|
||||
assertTrue(eq, "Identical lists should be equivalent")
|
||||
|
||||
val variable = Variable("X")
|
||||
|
||||
eq = equivalent(list1, variable, mapOf(variable to list2))
|
||||
assertTrue(eq, "Identical lists should be equivalent")
|
||||
|
||||
eq = equivalent(variable, list2, mapOf(variable to list1))
|
||||
assertTrue(eq, "Identical lists should be equivalent")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -422,6 +453,17 @@ class UnificationTests {
|
|||
|
||||
var eq = equivalent(list1, list2, emptyMap())
|
||||
assertTrue(eq, "Identical nested lists should be equivalent")
|
||||
|
||||
eq = equivalent(list2, list1, emptyMap())
|
||||
assertTrue(eq, "Identical nested lists should be equivalent")
|
||||
|
||||
val variable = Variable("X")
|
||||
|
||||
eq = equivalent(list1, variable, mapOf(variable to list2))
|
||||
assertTrue(eq, "Identical nested lists should be equivalent")
|
||||
|
||||
eq = equivalent(variable, list2, mapOf(variable to list1))
|
||||
assertTrue(eq, "Identical nested lists should be equivalent")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -431,6 +473,17 @@ class UnificationTests {
|
|||
|
||||
var eq = equivalent(list1, list2, emptyMap())
|
||||
assertFalse(eq, "Lists with different nests should not be equivalent")
|
||||
|
||||
eq = equivalent(list2, list1, emptyMap())
|
||||
assertFalse(eq, "Lists with different nests should not be equivalent")
|
||||
|
||||
val variable = Variable("X")
|
||||
|
||||
eq = equivalent(list1, variable, mapOf(variable to list2))
|
||||
assertFalse(eq, "Lists with different nests should not be equivalent")
|
||||
|
||||
eq = equivalent(variable, list2, mapOf(variable to list1))
|
||||
assertFalse(eq, "Lists with different nests should not be equivalent")
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue