36 lines
No EOL
936 B
Kotlin
36 lines
No EOL
936 B
Kotlin
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'"
|
|
)
|
|
}
|
|
} |