--- a/langtools/test/jdk/jshell/ToolBasicTest.java Thu Nov 12 08:39:23 2015 +0530
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java Thu Nov 12 08:48:42 2015 +0100
@@ -24,7 +24,6 @@
/*
* @test
* @summary Tests for Basic tests for REPL tool
- * @ignore 8139873
* @library /tools/lib
* @build KullaTesting TestingInputStream ToolBox Compiler
* @run testng ToolBasicTest
@@ -139,7 +138,13 @@
(a) -> assertCommand(a, "class A {}\u0003", ""),
(a) -> assertCommandCheckOutput(a, "/c", assertClasses()),
(a) -> assertClass(a, "interface A {}", "interface", "A"),
- (a) -> assertCommandCheckOutput(a, "/c", assertClasses())
+ (a) -> assertCommandCheckOutput(a, "/c", assertClasses()),
+ (a) -> assertCommand(a, "import java.util.stream." + s, ""),
+ interrupt,
+ (a) -> assertCommand(a, "import java.util.stream.\u0003", ""),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+ (a) -> assertImport(a, "import java.util.stream.Stream", "", "java.util.stream.Stream"),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports())
);
}
}
@@ -364,6 +369,35 @@
);
}
+ public void defineImports() {
+ test(
+ (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+ (a) -> assertImport(a, "import java.util.stream.Stream;", "", "java.util.stream.Stream"),
+ (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+ (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+ (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+ (a) -> assertImport(a, "import static java.lang.Math.PI;", "static", "java.lang.Math.PI"),
+ (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+ (a) -> assertImport(a, "import static java.lang.Math.*;", "static", "java.lang.Math.*"),
+ (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+ (a) -> assertCommandCheckOutput(a, "/imports", assertImports())
+ );
+ }
+
public void testClasspathDirectory() {
Compiler compiler = new Compiler();
Path outDir = Paths.get("testClasspathDirectory");
@@ -443,10 +477,13 @@
(a) -> assertCommandCheckOutput(a, "/m", assertMethods()),
(a) -> assertClass(a, "class A { }", "class", "A"),
(a) -> assertCommandCheckOutput(a, "/c", assertClasses()),
+ (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
(a) -> assertReset(a, "/reset"),
(a) -> assertCommandCheckOutput(a, "/v", assertVariables()),
(a) -> assertCommandCheckOutput(a, "/m", assertMethods()),
- (a) -> assertCommandCheckOutput(a, "/c", assertClasses())
+ (a) -> assertCommandCheckOutput(a, "/c", assertClasses()),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports())
);
}
@@ -455,22 +492,26 @@
Path path = compiler.getPath("testOpen.repl");
compiler.writeToFile(path,
"int a = 10;\ndouble x = 20;\ndouble a = 10;\n" +
- "class A { public String toString() { return \"A\"; } }");
+ "class A { public String toString() { return \"A\"; } }\nimport java.util.stream.*;");
for (String s : new String[]{"/o", "/open"}) {
test(
(a) -> assertCommand(a, s + " " + path.toString(), ""),
(a) -> assertCommand(a, "a", "| Variable a of type double has value 10.0\n"),
(a) -> evaluateExpression(a, "A", "new A();", "\"A\""),
+ (a) -> evaluateExpression(a, "long", "Stream.of(\"A\").count();", "1"),
(a) -> {
loadVariable(a, "double", "x", "20.0", "20.0");
loadVariable(a, "double", "a", "10.0", "10.0");
- loadVariable(a, "A", "$6", "new A();", "A");
+ loadVariable(a, "A", "$7", "new A();", "A");
+ loadVariable(a, "long", "$8", "Stream.of(\"A\").count();", "1");
loadClass(a, "class A { public String toString() { return \"A\"; } }",
"class", "A");
+ loadImport(a, "import java.util.stream.*;", "", "java.util.stream.*");
assertCommandCheckOutput(a, "/c", assertClasses());
},
(a) -> assertCommandCheckOutput(a, "/m", assertMethods()),
- (a) -> assertCommandCheckOutput(a, "/v", assertVariables())
+ (a) -> assertCommandCheckOutput(a, "/v", assertVariables()),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports())
);
Path unknown = compiler.getPath("UNKNOWN.repl");
test(
@@ -536,6 +577,7 @@
(a) -> assertVariable(a, "int", "a"),
(a) -> assertVariable(a, "double", "b", "10", "10.0"),
(a) -> assertMethod(a, "void f() {}", "()V", "f"),
+ (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
(a) -> assertCommand(a, "/s " + startUpFile.toString(), null),
(a) -> assertCommand(a, "/setstart " + startUpFile.toString(), null)
);
@@ -549,10 +591,12 @@
loadVariable(a, "int", "a");
loadVariable(a, "double", "b", "10.0", "10.0");
loadMethod(a, "void f() {}", "()void", "f");
+ loadImport(a, "import java.util.stream.*;", "", "java.util.stream.*");
assertCommandCheckOutput(a, "/c", assertClasses());
},
(a) -> assertCommandCheckOutput(a, "/v", assertVariables()),
- (a) -> assertCommandCheckOutput(a, "/m", assertMethods())
+ (a) -> assertCommandCheckOutput(a, "/m", assertMethods()),
+ (a) -> assertCommandCheckOutput(a, "/i", assertImports())
);
} finally {
removeStartup();
@@ -768,9 +812,12 @@
a -> dropMethod(a, drop + " 2", "b ()I"),
a -> assertClass(a, "class A {}", "class", "A"),
a -> dropClass(a, drop + " 3", "class A"),
+ a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+ a -> dropImport(a, drop + " 4", "import java.util.stream.*"),
a -> assertCommandCheckOutput(a, "/v", assertVariables()),
a -> assertCommandCheckOutput(a, "/m", assertMethods()),
- a -> assertCommandCheckOutput(a, "/c", assertClasses())
+ a -> assertCommandCheckOutput(a, "/c", assertClasses()),
+ a -> assertCommandCheckOutput(a, "/i", assertImports())
);
test(false, new String[]{"-nostartup"},
a -> assertVariable(a, "int", "a"),
@@ -781,7 +828,8 @@
a -> dropClass(a, drop + " A", "class A"),
a -> assertCommandCheckOutput(a, "/v", assertVariables()),
a -> assertCommandCheckOutput(a, "/m", assertMethods()),
- a -> assertCommandCheckOutput(a, "/c", assertClasses())
+ a -> assertCommandCheckOutput(a, "/c", assertClasses()),
+ a -> assertCommandCheckOutput(a, "/i", assertImports())
);
}
}
@@ -814,7 +862,8 @@
a -> assertCommandCheckOutput(a, drop + " a", check),
a -> assertCommandCheckOutput(a, "/v", assertVariables()),
a -> assertCommandCheckOutput(a, "/m", assertMethods()),
- a -> assertCommandCheckOutput(a, "/c", assertClasses())
+ a -> assertCommandCheckOutput(a, "/c", assertClasses()),
+ a -> assertCommandCheckOutput(a, "/i", assertImports())
);
test(
a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),