test/jdk/jshell/ToolBasicTest.java
Print this page
@@ -95,11 +95,11 @@
}
public void testInterrupt() {
ReplTest interrupt = (a) -> assertCommand(a, "\u0003", "");
for (String s : new String[] { "", "\u0003" }) {
- test(false, new String[]{"-nostartup"},
+ test(false, new String[]{"--no-startup"},
(a) -> assertCommand(a, "int a = 2 +" + s, ""),
interrupt,
(a) -> assertCommand(a, "int a\u0003", ""),
(a) -> assertCommand(a, "int a = 2 + 2\u0003", ""),
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
@@ -188,11 +188,11 @@
(a) -> assertStop(a, "while (true) { try { Thread.sleep(100); } catch (InterruptedException ex) { } }", "")
);
}
public void testRerun() {
- test(false, new String[] {"-nostartup"},
+ test(false, new String[] {"--no-startup"},
(a) -> assertCommand(a, "/0", "| No such command or snippet id: /0\n| Type /help for help."),
(a) -> assertCommand(a, "/5", "| No such command or snippet id: /5\n| Type /help for help.")
);
String[] codes = new String[] {
"int a = 0;", // var
@@ -224,11 +224,11 @@
assertTrue(ss.length > 1, s);
};
tests.add((a) -> assertCommandCheckOutput(a, "/-" + (2 * finalI + 1), check));
}
tests.add((a) -> assertCommandCheckOutput(a, "/!", assertStartsWith("int a = 0;")));
- test(false, new String[]{"-nostartup"},
+ test(false, new String[]{"--no-startup"},
tests.toArray(new ReplTest[tests.size()]));
}
public void test8142447() {
Function<String, BiFunction<String, Integer, ReplTest>> assertRerun = cmd -> (code, assertionCount) ->
@@ -241,20 +241,20 @@
Compiler compiler = new Compiler();
Path startup = compiler.getPath("StartupFileOption/startup.txt");
compiler.writeToFile(startup, "int assertionCount = 0;\n" + // id: s1
"void add(int n) { assertionCount += n; }");
- test(new String[]{"-startup", startup.toString()},
+ test(new String[]{"--startup", startup.toString()},
(a) -> assertCommand(a, "add(1)", ""), // id: 1
(a) -> assertCommandCheckOutput(a, "add(ONE)", s -> assertEquals(s.split("\n")[0], "| Error:")), // id: e1
(a) -> assertVariable(a, "int", "ONE", "1", "1"),
assertRerun.apply("/1").apply("add(1)", 2), assertVariables,
assertRerun.apply("/e1").apply("add(ONE)", 3), assertVariables,
assertRerun.apply("/s1").apply("int assertionCount = 0;", 0), assertVariables
);
- test(false, new String[] {"-nostartup"},
+ test(false, new String[] {"--no-startup"},
(a) -> assertCommand(a, "/s1", "| No such command or snippet id: /s1\n| Type /help for help."),
(a) -> assertCommand(a, "/1", "| No such command or snippet id: /1\n| Type /help for help."),
(a) -> assertCommand(a, "/e1", "| No such command or snippet id: /e1\n| Type /help for help.")
);
}
@@ -266,14 +266,11 @@
Path classpath = compiler.getPath(outDir);
test(
(a) -> assertCommand(a, "/classpath " + classpath, String.format("| Path '%s' added to classpath", classpath)),
(a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
- test(new String[] { "-cp", classpath.toString() },
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
- );
- test(new String[] { "-classpath", classpath.toString() },
+ test(new String[] { "--class-path", classpath.toString() },
(a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
}
public void testClasspathJar() {
@@ -285,27 +282,24 @@
Path jarPath = compiler.getPath(outDir).resolve(jarName);
test(
(a) -> assertCommand(a, "/classpath " + jarPath, String.format("| Path '%s' added to classpath", jarPath)),
(a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
- test(new String[] { "-cp", jarPath.toString() },
- (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
- );
- test(new String[] { "-classpath", jarPath.toString() },
+ test(new String[] { "--class-path", jarPath.toString() },
(a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
);
}
public void testStartupFileOption() {
try {
Compiler compiler = new Compiler();
Path startup = compiler.getPath("StartupFileOption/startup.txt");
compiler.writeToFile(startup, "class A { public String toString() { return \"A\"; } }");
- test(new String[]{"-startup", startup.toString()},
+ test(new String[]{"--startup", startup.toString()},
(a) -> evaluateExpression(a, "A", "new A()", "A")
);
- test(new String[]{"-nostartup"},
+ test(new String[]{"--no-startup"},
(a) -> assertCommandCheckOutput(a, "printf(\"\")", assertStartsWith("| Error:\n| cannot find symbol"))
);
test(
(a) -> assertCommand(a, "printf(\"A\")", "", "", null, "A", "")
);
@@ -541,11 +535,11 @@
}
}
}
public void testHistoryReference() {
- test(false, new String[]{"-nostartup"},
+ test(false, new String[]{"--no-startup"},
a -> assertCommand(a, "System.err.println(1)", "", "", null, "", "1\n"),
a -> assertCommand(a, "System.err.println(2)", "", "", null, "", "2\n"),
a -> assertCommand(a, "/-2", "System.err.println(1)", "", null, "", "1\n"),
a -> assertCommand(a, "/history",
"/debug 0\n" +