langtools/test/jdk/jshell/ToolBasicTest.java
changeset 44065 d0a8a4c41c85
parent 43856 fcdebb803c62
child 45215 c9477e22877f
equal deleted inserted replaced
44064:ca20a5923619 44065:d0a8a4c41c85
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405 8174796 8174797
    26  * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405 8174796 8174797 8175304
    27  * @summary Tests for Basic tests for REPL tool
    27  * @summary Tests for Basic tests for REPL tool
    28  * @modules jdk.compiler/com.sun.tools.javac.api
    28  * @modules jdk.compiler/com.sun.tools.javac.api
    29  *          jdk.compiler/com.sun.tools.javac.main
    29  *          jdk.compiler/com.sun.tools.javac.main
    30  *          jdk.jdeps/com.sun.tools.javap
    30  *          jdk.jdeps/com.sun.tools.javap
    31  *          jdk.jshell/jdk.internal.jshell.tool
    31  *          jdk.jshell/jdk.internal.jshell.tool
   271         test(new String[] { "--class-path", classpath.toString() },
   271         test(new String[] { "--class-path", classpath.toString() },
   272                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   272                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   273         );
   273         );
   274     }
   274     }
   275 
   275 
       
   276     public void testEnvInStartUp() {
       
   277         Compiler compiler = new Compiler();
       
   278         Path outDir = Paths.get("testClasspathDirectory");
       
   279         compiler.compile(outDir, "package pkg; public class A { public String toString() { return \"A\"; } }");
       
   280         Path classpath = compiler.getPath(outDir);
       
   281         Path sup = compiler.getPath("startup.jsh");
       
   282         compiler.writeToFile(sup,
       
   283                 "int xxx;\n" +
       
   284                 "/env -class-path " + classpath + "\n" +
       
   285                 "int aaa = 735;\n"
       
   286         );
       
   287         test(
       
   288                 (a) -> assertCommand(a, "/set start -retain " + sup, ""),
       
   289                 (a) -> assertCommand(a, "/reset",
       
   290                         "|  Resetting state."),
       
   291                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A"),
       
   292                 (a) -> assertCommand(a, "aaa", "aaa ==> 735")
       
   293         );
       
   294         test(
       
   295                 (a) -> assertCommandOutputContains(a, "/env", "--class-path"),
       
   296                 (a) -> assertCommandOutputContains(a, "xxx", "cannot find symbol", "variable xxx"),
       
   297                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A"),
       
   298                 (a) -> assertCommand(a, "aaa", "aaa ==> 735")
       
   299         );
       
   300     }
       
   301 
   276     private String makeSimpleJar() {
   302     private String makeSimpleJar() {
   277         Compiler compiler = new Compiler();
   303         Compiler compiler = new Compiler();
   278         Path outDir = Paths.get("testClasspathJar");
   304         Path outDir = Paths.get("testClasspathJar");
   279         compiler.compile(outDir, "package pkg; public class A { public String toString() { return \"A\"; } }");
   305         compiler.compile(outDir, "package pkg; public class A { public String toString() { return \"A\"; } }");
   280         String jarName = "test.jar";
   306         String jarName = "test.jar";