IO Operators
This commit is contained in:
parent
b9f419a59d
commit
82a8fccf87
22 changed files with 450 additions and 199 deletions
|
@ -1,36 +0,0 @@
|
|||
package parser
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertInstanceOf
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import prolog.ast.logic.Fact
|
||||
import prolog.ast.terms.Atom
|
||||
import prolog.logic.equivalent
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ScriptParserTests {
|
||||
private lateinit var parser: ScriptParser
|
||||
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
parser = ScriptParser()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parse single atom`() {
|
||||
val input = """
|
||||
a.
|
||||
""".trimIndent()
|
||||
|
||||
val result = parser.parse(input)
|
||||
val expected = Fact(Atom("a"))
|
||||
|
||||
assertEquals(1, result.size, "Should return one result")
|
||||
assertInstanceOf(Fact::class.java, result[0], "Result should be a fact")
|
||||
assertTrue(
|
||||
equivalent(expected.head, result[0].head, emptyMap()),
|
||||
"Expected fact 'a'"
|
||||
)
|
||||
}
|
||||
}
|
|
@ -4,9 +4,4 @@ female(mary).
|
|||
parent(john, jimmy).
|
||||
parent(mary, jimmy).
|
||||
father(X, Y) :- parent(X, Y), male(X).
|
||||
mother(X, Y) :- parent(X, Y), female(X).
|
||||
|
||||
:- write(hello),
|
||||
nl.
|
||||
|
||||
:- write(hello2).
|
||||
mother(X, Y) :- parent(X, Y), female(X).
|
Reference in a new issue