langtools/test/jdk/jshell/ToolCommandOptionTest.java
changeset 42412 ca6f4f1914b2
parent 41641 a628785b9dd9
child 42972 47ca49eee534
equal deleted inserted replaced
42411:2433ceacb13e 42412:ca6f4f1914b2
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24  /*
    24  /*
    25  * @test
    25  * @test
    26  * @bug 8157395 8157393 8157517 8158738 8167128 8163840 8167637
    26  * @bug 8157395 8157393 8157517 8158738 8167128 8163840 8167637 8170368
    27  * @summary Tests of jshell comand options, and undoing operations
    27  * @summary Tests of jshell comand options, and undoing operations
    28  * @modules jdk.jshell/jdk.internal.jshell.tool
    28  * @modules jdk.jshell/jdk.internal.jshell.tool
       
    29  *          jdk.compiler/com.sun.tools.javac.api
       
    30  *          jdk.compiler/com.sun.tools.javac.main
       
    31  * @library /tools/lib
    29  * @build ToolCommandOptionTest ReplToolTesting
    32  * @build ToolCommandOptionTest ReplToolTesting
    30  * @run testng ToolCommandOptionTest
    33  * @run testng ToolCommandOptionTest
    31  */
    34  */
       
    35 import java.nio.file.Path;
    32 import org.testng.annotations.Test;
    36 import org.testng.annotations.Test;
    33 import static org.testng.Assert.assertFalse;
    37 import static org.testng.Assert.assertFalse;
    34 
    38 
    35 @Test
    39 @Test
    36 public class ToolCommandOptionTest extends ReplToolTesting {
    40 public class ToolCommandOptionTest extends ReplToolTesting {
   238                         "|  Editor set to: best one")
   242                         "|  Editor set to: best one")
   239         );
   243         );
   240     }
   244     }
   241 
   245 
   242     public void setStartTest() {
   246     public void setStartTest() {
       
   247         Compiler compiler = new Compiler();
       
   248         Path startup = compiler.getPath("StartTest/startup.txt");
       
   249         compiler.writeToFile(startup, "int iAmHere = 1234;");
   243         test(
   250         test(
   244                 (a) -> assertCommand(a, "/set start -furball",
   251                 (a) -> assertCommand(a, "/set start -furball",
   245                         "|  Unknown option: -furball -- /set start -furball"),
   252                         "|  Unknown option: -furball -- /set start -furball"),
   246                 (a) -> assertCommand(a, "/set start -furball pyle",
   253                 (a) -> assertCommand(a, "/set start -furball pyle",
   247                         "|  Unknown option: -furball -- /set start -furball pyle"),
   254                         "|  Unknown option: -furball -- /set start -furball pyle"),
   255                         "|  File 'frfg' for '/set start' is not found."),
   262                         "|  File 'frfg' for '/set start' is not found."),
   256                 (a) -> assertCommand(a, "/set start -default",
   263                 (a) -> assertCommand(a, "/set start -default",
   257                         ""),
   264                         ""),
   258                 (a) -> assertCommand(a, "/set start",
   265                 (a) -> assertCommand(a, "/set start",
   259                         "|  /set start -default"),
   266                         "|  /set start -default"),
       
   267                 (a) -> assertCommand(a, "/set start " + startup.toString(),
       
   268                         ""),
       
   269                 (a) -> assertCommand(a, "/set start",
       
   270                         "|  startup.jsh:\n" +
       
   271                         "|  int iAmHere = 1234;\n" +
       
   272                         "|  \n" +
       
   273                         "|  /set start startup.jsh"),
   260                 (a) -> assertCommand(a, "/se sta -no",
   274                 (a) -> assertCommand(a, "/se sta -no",
   261                         ""),
   275                         ""),
   262                 (a) -> assertCommand(a, "/set start",
   276                 (a) -> assertCommand(a, "/set start",
   263                         "|  /set start -none")
   277                         "|  /set start -none")
   264         );
   278         );
   265     }
   279     }
   266 
   280 
   267     public void retainStartTest() {
   281     public void retainStartTest() {
       
   282         Compiler compiler = new Compiler();
       
   283         Path startup = compiler.getPath("StartTest/startup.txt");
       
   284         compiler.writeToFile(startup, "int iAmHere = 1234;");
   268         test(
   285         test(
   269                 (a) -> assertCommand(a, "/set start -retain -furball",
   286                 (a) -> assertCommand(a, "/set start -retain -furball",
   270                         "|  Unknown option: -furball -- /set start -retain -furball"),
   287                         "|  Unknown option: -furball -- /set start -retain -furball"),
   271                 (a) -> assertCommand(a, "/set start -retain -furball pyle",
   288                 (a) -> assertCommand(a, "/set start -retain -furball pyle",
   272                         "|  Unknown option: -furball -- /set start -retain -furball pyle"),
   289                         "|  Unknown option: -furball -- /set start -retain -furball pyle"),
   290                         "|  /set start -retain -default\n" +
   307                         "|  /set start -retain -default\n" +
   291                         "|  /set start -none"),
   308                         "|  /set start -none"),
   292                 (a) -> assertCommand(a, "/se st -ret",
   309                 (a) -> assertCommand(a, "/se st -ret",
   293                         ""),
   310                         ""),
   294                 (a) -> assertCommand(a, "/se sta",
   311                 (a) -> assertCommand(a, "/se sta",
   295                         "|  /set start -retain -none")
   312                         "|  /set start -retain -none"),
       
   313                 (a) -> assertCommand(a, "/set start -retain " + startup.toString(),
       
   314                         ""),
       
   315                 (a) -> assertCommand(a, "/set start",
       
   316                         "|  startup.jsh:\n" +
       
   317                         "|  int iAmHere = 1234;\n" +
       
   318                         "|  \n" +
       
   319                         "|  /set start -retain startup.jsh")
   296         );
   320         );
   297     }
   321     }
   298 
   322 
   299     public void setModeTest() {
   323     public void setModeTest() {
   300         test(
   324         test(