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/e2e/Examples.kt
2025-05-01 21:16:48 +02:00

46 lines
No EOL
1,013 B
Kotlin

package e2e
import interpreter.FileLoader
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import prolog.Program
import java.io.ByteArrayOutputStream
import java.io.PrintStream
class Examples {
private val loader = FileLoader()
@BeforeEach
fun setup() {
Program.reset()
}
@Test
fun fraternity() {
val inputFile = "examples/basics/fraternity.pl"
loader.load(inputFile)
}
@Test
fun unification() {
val inputFile = "examples/basics/unification.pl"
loader.load(inputFile)
}
@Test
fun write() {
val expected = "gpl zegt: dag(wereld)\n"
val outStream = ByteArrayOutputStream()
System.setOut(PrintStream(outStream))
val inputFile = "examples/basics/write.pl"
// Compare the stdio output with the expected output
loader.load(inputFile)
assertEquals(expected, outStream.toString())
}
}