properly handle empty lines in REPL
This commit is contained in:
@@ -82,4 +82,8 @@ public class ScriptGenTest extends CodegenTestCase {
|
||||
blackBoxFile("script/parameterClosure.ktscript");
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
blackBoxFile("script/empty.ktscript");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,5 +92,10 @@ public class ReplInterpreterTest {
|
||||
testFile("twoClosures.repl");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void empty() {
|
||||
testFile("empty.repl");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
@@ -66,10 +68,12 @@ public class ReplSessionTestFile {
|
||||
return new ReplSessionTestFile(list);
|
||||
}
|
||||
|
||||
if (!odd.startsWith(">>> ")) {
|
||||
Pattern pattern = Pattern.compile(">>>( |$)(.*)");
|
||||
Matcher matcher = pattern.matcher(odd);
|
||||
if (!matcher.matches()) {
|
||||
throw new IllegalStateException("odd lines must start with >>>");
|
||||
}
|
||||
String code = odd.substring(4);
|
||||
String code = matcher.group(2);
|
||||
|
||||
String even = reader.readLine();
|
||||
if (even == null) {
|
||||
|
||||
Reference in New Issue
Block a user