Minor, dump bytecode in REPL test on demand

This commit is contained in:
Alexander Udalov
2015-07-01 12:29:10 +03:00
parent cd847b7cb9
commit cd61f6f96b
@@ -24,11 +24,15 @@ import org.jetbrains.kotlin.test.JetTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
import org.junit.Assert
import java.io.File
import java.io.PrintWriter
import java.util.ArrayDeque
import java.util.ArrayList
import java.util.regex.Pattern
import kotlin.text.Regex
// Switch this flag to render bytecode after each line in the REPL test. Useful for debugging verify errors or other codegen problems
private val DUMP_BYTECODE = false
private val START_PATTERN = Pattern.compile(">>>( *)(.*)$")
private val INCOMPLETE_PATTERN = Pattern.compile("\\.\\.\\.( *)(.*)$")
private val TRAILING_NEWLINE_REGEX = Regex("\n$")
@@ -83,7 +87,12 @@ public abstract class AbstractReplInterpreterTest : UsefulTestCase() {
for ((code, expected) in loadLines(File(path))) {
val lineResult = repl.eval(code)
val actual = when (lineResult.getType()!!) {
if (DUMP_BYTECODE) {
repl.dumpClasses(PrintWriter(System.out))
}
val actual = when (lineResult.getType()) {
ReplInterpreter.LineResultType.SUCCESS -> lineResult.getValue()?.toString() ?: ""
ReplInterpreter.LineResultType.ERROR -> lineResult.getErrorText()
ReplInterpreter.LineResultType.INCOMPLETE -> INCOMPLETE_LINE_MESSAGE