46 lines
No EOL
1,013 B
Kotlin
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())
|
|
}
|
|
} |