This repository has been archived on 2025-09-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2025LogProg-project-GhentPr.../tests/parser/ScriptParserTests.kt

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'"
)
}
}