langtools/test/jdk/jshell/ToolBasicTest.java
changeset 43038 7b8b8750a78e
parent 42972 47ca49eee534
child 43856 fcdebb803c62
equal deleted inserted replaced
43037:3e1520a857fa 43038:7b8b8750a78e
    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
    26  * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405
    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
   261         Compiler compiler = new Compiler();
   261         Compiler compiler = new Compiler();
   262         Path outDir = Paths.get("testClasspathDirectory");
   262         Path outDir = Paths.get("testClasspathDirectory");
   263         compiler.compile(outDir, "package pkg; public class A { public String toString() { return \"A\"; } }");
   263         compiler.compile(outDir, "package pkg; public class A { public String toString() { return \"A\"; } }");
   264         Path classpath = compiler.getPath(outDir);
   264         Path classpath = compiler.getPath(outDir);
   265         test(
   265         test(
   266                 (a) -> assertCommand(a, "/classpath " + classpath, String.format("|  Path '%s' added to classpath", classpath)),
   266                 (a) -> assertCommand(a, "/env --class-path " + classpath,
       
   267                         "|  Setting new options and restoring state."),
   267                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   268                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   268         );
   269         );
   269         test(new String[] { "--class-path", classpath.toString() },
   270         test(new String[] { "--class-path", classpath.toString() },
   270                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   271                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   271         );
   272         );
   277         compiler.compile(outDir, "package pkg; public class A { public String toString() { return \"A\"; } }");
   278         compiler.compile(outDir, "package pkg; public class A { public String toString() { return \"A\"; } }");
   278         String jarName = "test.jar";
   279         String jarName = "test.jar";
   279         compiler.jar(outDir, jarName, "pkg/A.class");
   280         compiler.jar(outDir, jarName, "pkg/A.class");
   280         Path jarPath = compiler.getPath(outDir).resolve(jarName);
   281         Path jarPath = compiler.getPath(outDir).resolve(jarName);
   281         test(
   282         test(
   282                 (a) -> assertCommand(a, "/classpath " + jarPath, String.format("|  Path '%s' added to classpath", jarPath)),
   283                 (a) -> assertCommand(a, "/env --class-path " + jarPath,
       
   284                         "|  Setting new options and restoring state."),
   283                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   285                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   284         );
   286         );
   285         test(new String[] { "--class-path", jarPath.toString() },
   287         test(new String[] { "--class-path", jarPath.toString() },
   286                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   288                 (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A")
   287         );
   289         );