langtools/test/jdk/jshell/ToolSimpleTest.java
author rfield
Mon, 13 Feb 2017 17:04:26 -0800
changeset 43861 825bad9a162a
parent 43856 fcdebb803c62
child 44454 74af976d6798
permissions -rw-r--r--
8174862: JShell tests: new JDK-8174797 testInvalidClassPath fails on Windows Reviewed-by: jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     1
/*
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     4
 *
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     8
 *
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    13
 * accompanied this code).
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    14
 *
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    18
 *
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    21
 * questions.
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    22
 */
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    23
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    24
/*
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    25
 * @test
43856
fcdebb803c62 8174797: jshell tool: invalid module path crashes tool
rfield
parents: 43766
diff changeset
    26
 * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    27
 * @summary Simple jshell tool tests
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    28
 * @modules jdk.compiler/com.sun.tools.javac.api
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    29
 *          jdk.compiler/com.sun.tools.javac.main
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    30
 *          jdk.jdeps/com.sun.tools.javap
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    31
 *          jdk.jshell/jdk.internal.jshell.tool
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    32
 * @build KullaTesting TestingInputStream
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    33
 * @run testng ToolSimpleTest
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    34
 */
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    35
import java.util.Arrays;
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    36
import java.util.ArrayList;
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    37
import java.util.List;
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
    38
import java.util.Locale;
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    39
import java.util.function.Consumer;
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    40
import java.util.stream.Collectors;
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    41
import java.util.stream.Stream;
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    42
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    43
import org.testng.annotations.Test;
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    44
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    45
import static org.testng.Assert.assertEquals;
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    46
import static org.testng.Assert.assertTrue;
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    47
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    48
public class ToolSimpleTest extends ReplToolTesting {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
    49
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
    50
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    51
    public void testRemaining() {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    52
        test(
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    53
                (a) -> assertCommand(a, "int z; z =", "z ==> 0"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    54
                (a) -> assertCommand(a, "5", "z ==> 5"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    55
                (a) -> assertCommand(a, "/*nada*/; int q =", ""),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    56
                (a) -> assertCommand(a, "77", "q ==> 77"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    57
                (a) -> assertCommand(a, "//comment;", ""),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    58
                (a) -> assertCommand(a, "int v;", "v ==> 0"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    59
                (a) -> assertCommand(a, "int v; int c",
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    60
                        "v ==> 0\n" +
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    61
                        "c ==> 0")
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    62
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    63
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    64
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
    65
    @Test
38835
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    66
    public void testOpenComment() {
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    67
        test(
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    68
                (a) -> assertCommand(a, "int z = /* blah", ""),
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    69
                (a) -> assertCommand(a, "baz */ 5", "z ==> 5"),
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    70
                (a) -> assertCommand(a, "/** hoge ", ""),
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    71
                (a) -> assertCommand(a, "baz **/", ""),
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    72
                (a) -> assertCommand(a, "int v", "v ==> 0")
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    73
        );
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    74
    }
37280d52d723 8131024: JShell: multi-line comment not detected as incomplete
rfield
parents: 38539
diff changeset
    75
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
    76
    @Test
43586
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    77
    public void testLessThan() {
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    78
        test(
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    79
                (a) -> assertCommand(a, "45", "$1 ==> 45"),
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    80
                (a) -> assertCommand(a, "72", "$2 ==> 72"),
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    81
                (a) -> assertCommand(a, "$1 < $2", "$3 ==> true"),
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    82
                (a) -> assertCommand(a, "int a, b", "a ==> 0\n" +
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    83
                        "b ==> 0"),
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    84
                (a) -> assertCommand(a, "a < b", "$6 ==> false")
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    85
        );
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    86
    }
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    87
cc7a4eb79b29 8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents: 43274
diff changeset
    88
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    89
    public void oneLineOfError() {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    90
        test(
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    91
                (a) -> assertCommand(a, "12+", null),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    92
                (a) -> assertCommandCheckOutput(a, "  true", (s) ->
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    93
                        assertTrue(s.contains("12+") && !s.contains("true"), "Output: '" + s + "'"))
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    94
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    95
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    96
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
    97
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    98
    public void defineVariables() {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
    99
        test(
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   100
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   101
                (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   102
                (a) -> assertVariable(a, "int", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   103
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   104
                (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   105
                (a) -> assertVariable(a, "double", "a", "1", "1.0"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   106
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   107
                (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   108
                (a) -> evaluateExpression(a, "double", "2 * a", "2.0"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   109
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   110
                (a) -> assertCommandCheckOutput(a, "/vars", assertVariables())
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   111
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   112
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   113
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   114
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   115
    public void defineMethods() {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   116
        test(
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   117
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   118
                (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   119
                (a) -> assertMethod(a, "int f() { return 0; }", "()int", "f"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   120
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   121
                (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   122
                (a) -> assertMethod(a, "void f(int a) { g(); }", "(int)void", "f"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   123
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   124
                (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   125
                (a) -> assertMethod(a, "void g() {}", "()void", "g"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   126
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   127
                (a) -> assertCommandCheckOutput(a, "/methods", assertMethods())
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   128
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   129
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   130
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   131
    @Test
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   132
    public void defineTypes() {
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   133
        test(
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   134
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   135
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   136
                (a) -> assertClass(a, "class A { }", "class", "A"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   137
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   138
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   139
                (a) -> assertClass(a, "interface A { }", "interface", "A"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   140
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   141
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   142
                (a) -> assertClass(a, "enum A { }", "enum", "A"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   143
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   144
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   145
                (a) -> assertClass(a, "@interface A { }", "@interface", "A"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   146
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   147
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses())
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   148
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   149
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   150
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   151
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   152
    public void defineImports() {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   153
        test(
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   154
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   155
                (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   156
                (a) -> assertImport(a, "import java.util.stream.Stream;", "", "java.util.stream.Stream"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   157
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   158
                (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   159
                (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   160
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   161
                (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   162
                (a) -> assertImport(a, "import static java.lang.Math.PI;", "static", "java.lang.Math.PI"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   163
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   164
                (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   165
                (a) -> assertImport(a, "import static java.lang.Math.*;", "static", "java.lang.Math.*"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   166
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   167
                (a) -> assertCommandCheckOutput(a, "/imports", assertImports())
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   168
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   169
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   170
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   171
    @Test
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   172
    public void defineVar() {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   173
        test(
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   174
                (a) -> assertCommand(a, "int x = 72", "x ==> 72"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   175
                (a) -> assertCommand(a, "x", "x ==> 72"),
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   176
                (a) -> assertCommand(a, "/vars", "|    int x = 72")
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   177
        );
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   178
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   179
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   180
    @Test
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   181
    public void defineUnresolvedVar() {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   182
        test(
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   183
                (a) -> assertCommand(a, "undefined x",
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   184
                        "|  created variable x, however, it cannot be referenced until class undefined is declared"),
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   185
                (a) -> assertCommand(a, "/vars", "|    undefined x = (not-active)")
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   186
        );
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   187
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   188
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   189
    @Test
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   190
    public void testUnresolved() {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   191
        test(
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   192
                (a) -> assertCommand(a, "int f() { return g() + x + new A().a; }",
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   193
                        "|  created method f(), however, it cannot be invoked until method g(), variable x, and class A are declared"),
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   194
                (a) -> assertCommand(a, "f()",
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   195
                        "|  attempted to call method f() which cannot be invoked until method g(), variable x, and class A are declared"),
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   196
                (a) -> assertCommandOutputStartsWith(a, "int g() { return x; }",
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   197
                        "|  created method g(), however, it cannot be invoked until variable x is declared"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   198
                (a) -> assertCommand(a, "g()", "|  attempted to call method g() which cannot be invoked until variable x is declared")
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   199
        );
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   200
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   201
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   202
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   203
    public void testUnknownCommand() {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   204
        test((a) -> assertCommand(a, "/unknown",
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   205
                "|  No such command or snippet id: /unknown\n" +
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   206
                "|  Type /help for help."));
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   207
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   208
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   209
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   210
    public void testEmptyClassPath() {
43038
7b8b8750a78e 8165405: jshell tool: /classpath is inconsistent
rfield
parents: 42972
diff changeset
   211
        test(after -> assertCommand(after, "/env --class-path", "|  Argument to class-path missing."));
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   212
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   213
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   214
    @Test
43856
fcdebb803c62 8174797: jshell tool: invalid module path crashes tool
rfield
parents: 43766
diff changeset
   215
    public void testInvalidClassPath() {
fcdebb803c62 8174797: jshell tool: invalid module path crashes tool
rfield
parents: 43766
diff changeset
   216
        test(
43861
825bad9a162a 8174862: JShell tests: new JDK-8174797 testInvalidClassPath fails on Windows
rfield
parents: 43856
diff changeset
   217
                a -> assertCommand(a, "/env --class-path snurgefusal",
825bad9a162a 8174862: JShell tests: new JDK-8174797 testInvalidClassPath fails on Windows
rfield
parents: 43856
diff changeset
   218
                        "|  File 'snurgefusal' for '--class-path' is not found.")
43856
fcdebb803c62 8174797: jshell tool: invalid module path crashes tool
rfield
parents: 43766
diff changeset
   219
        );
fcdebb803c62 8174797: jshell tool: invalid module path crashes tool
rfield
parents: 43766
diff changeset
   220
    }
fcdebb803c62 8174797: jshell tool: invalid module path crashes tool
rfield
parents: 43766
diff changeset
   221
fcdebb803c62 8174797: jshell tool: invalid module path crashes tool
rfield
parents: 43766
diff changeset
   222
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   223
    public void testNoArgument() {
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   224
        test(
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   225
                (a) -> assertCommand(a, "/save",
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   226
                        "|  '/save' requires a filename argument."),
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   227
                (a) -> assertCommand(a, "/open",
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   228
                        "|  '/open' requires a filename argument."),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 41514
diff changeset
   229
                (a) -> assertCommandOutputStartsWith(a, "/drop",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 41514
diff changeset
   230
                        "|  In the /drop argument, please specify an import, variable, method, or class to drop.")
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   231
        );
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   232
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   233
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   234
    @Test
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   235
    public void testDebug() {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   236
        test(
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   237
                (a) -> assertCommand(a, "/deb", "|  Debugging on"),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   238
                (a) -> assertCommand(a, "/debug", "|  Debugging off"),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   239
                (a) -> assertCommand(a, "/debug", "|  Debugging on"),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   240
                (a) -> assertCommand(a, "/deb", "|  Debugging off")
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   241
        );
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   242
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   243
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   244
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   245
    public void testDrop() {
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   246
        test(false, new String[]{"--no-startup"},
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   247
                a -> assertVariable(a, "int", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   248
                a -> dropVariable(a, "/drop 1", "int a = 0", "|  dropped variable a"),
43759
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   249
                a -> assertMethod(a, "int b() { return 0; }", "()int", "b"),
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   250
                a -> dropMethod(a, "/drop 2", "int b()", "|  dropped method b()"),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   251
                a -> assertClass(a, "class A {}", "class", "A"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   252
                a -> dropClass(a, "/drop 3", "class A", "|  dropped class A"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   253
                a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   254
                a -> dropImport(a, "/drop 4", "import java.util.stream.*", ""),
41514
a75c2b869d8d 8167128: JShell: /drop of statement gives confusing output
rfield
parents: 40601
diff changeset
   255
                a -> assertCommand(a, "for (int i = 0; i < 10; ++i) {}", ""),
a75c2b869d8d 8167128: JShell: /drop of statement gives confusing output
rfield
parents: 40601
diff changeset
   256
                a -> assertCommand(a, "/drop 5", ""),
a75c2b869d8d 8167128: JShell: /drop of statement gives confusing output
rfield
parents: 40601
diff changeset
   257
                a -> assertCommand(a, "/list", ""),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   258
                a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   259
                a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   260
                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   261
                a -> assertCommandCheckOutput(a, "/imports", assertImports())
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   262
        );
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   263
        test(false, new String[]{"--no-startup"},
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   264
                a -> assertVariable(a, "int", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   265
                a -> dropVariable(a, "/drop a", "int a = 0", "|  dropped variable a"),
43759
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   266
                a -> assertMethod(a, "int b() { return 0; }", "()int", "b"),
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   267
                a -> dropMethod(a, "/drop b", "int b()", "|  dropped method b()"),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   268
                a -> assertClass(a, "class A {}", "class", "A"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   269
                a -> dropClass(a, "/drop A", "class A", "|  dropped class A"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   270
                a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   271
                a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   272
                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   273
                a -> assertCommandCheckOutput(a, "/imports", assertImports())
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   274
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   275
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   276
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   277
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   278
    public void testDropNegative() {
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   279
        test(false, new String[]{"--no-startup"},
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   280
                a -> assertCommandOutputStartsWith(a, "/drop 0", "|  No such snippet: 0"),
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   281
                a -> assertCommandOutputStartsWith(a, "/drop a", "|  No such snippet: a"),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   282
                a -> assertCommandCheckOutput(a, "/drop",
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   283
                        assertStartsWith("|  In the /drop argument, please specify an import, variable, method, or class to drop.")),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   284
                a -> assertVariable(a, "int", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   285
                a -> assertCommand(a, "a", "a ==> 0"),
41514
a75c2b869d8d 8167128: JShell: /drop of statement gives confusing output
rfield
parents: 40601
diff changeset
   286
                a -> assertCommand(a, "/drop 2", ""),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   287
                a -> assertCommand(a, "/drop 2",
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   288
                        "|  This command does not accept the snippet '2' : a\n" +
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   289
                        "|  See /types, /methods, /vars, or /list")
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   290
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   291
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   292
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   293
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   294
    public void testAmbiguousDrop() {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   295
        Consumer<String> check = s -> {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   296
            assertTrue(s.startsWith("|  The argument references more than one import, variable, method, or class"), s);
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   297
            int lines = s.split("\n").length;
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   298
            assertEquals(lines, 5, "Expected 3 ambiguous keys, but found: " + (lines - 2) + "\n" + s);
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   299
        };
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   300
        test(
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   301
                a -> assertVariable(a, "int", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   302
                a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   303
                a -> assertClass(a, "class a {}", "class", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   304
                a -> assertCommandCheckOutput(a, "/drop a", check),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   305
                a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   306
                a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   307
                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   308
                a -> assertCommandCheckOutput(a, "/imports", assertImports())
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   309
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   310
        test(
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   311
                a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   312
                a -> assertMethod(a, "double a(int a) { return 0; }", "(int)double", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   313
                a -> assertMethod(a, "double a(double a) { return 0; }", "(double)double", "a"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   314
                a -> assertCommandCheckOutput(a, "/drop a", check),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   315
                a -> assertCommandCheckOutput(a, "/methods", assertMethods())
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   316
        );
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   317
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   318
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   319
    @Test
42412
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   320
    public void testApplicationOfPost() {
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   321
        test(
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   322
                (a) -> assertCommand(a, "/set mode t normal -command", "|  Created new feedback mode: t"),
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   323
                (a) -> assertCommand(a, "/set feedback t", "|  Feedback mode: t"),
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   324
                (a) -> assertCommand(a, "/set format t post \"$%n\"", ""),
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   325
                (a) -> assertCommand(a, "/set prompt t \"+\" \"-\"", ""),
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   326
                (a) -> assertCommand(a, "/set prompt t", "|  /set prompt t \"+\" \"-\"$")
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   327
        );
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   328
    }
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   329
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   330
    @Test
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   331
    public void testHelpLength() {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   332
        Consumer<String> testOutput = (s) -> {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   333
            List<String> ss = Stream.of(s.split("\n"))
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   334
                    .filter(l -> !l.isEmpty())
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   335
                    .collect(Collectors.toList());
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   336
            assertTrue(ss.size() >= 10, "Help does not print enough lines:" + s);
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   337
        };
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   338
        test(
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   339
                (a) -> assertCommandCheckOutput(a, "/?", testOutput),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   340
                (a) -> assertCommandCheckOutput(a, "/help", testOutput),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   341
                (a) -> assertCommandCheckOutput(a, "/help /list", testOutput)
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   342
        );
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   343
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   344
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   345
    @Test
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   346
    public void testHelp() {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   347
        test(
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   348
                (a) -> assertHelp(a, "/?", "/list", "/help", "/exit", "intro"),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   349
                (a) -> assertHelp(a, "/help", "/list", "/help", "/exit", "intro"),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   350
                (a) -> assertHelp(a, "/help short", "shortcuts", "<tab>"),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   351
                (a) -> assertHelp(a, "/? /li", "/list -all", "snippets"),
42412
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   352
                (a) -> assertHelp(a, "/help /set prompt", "optionally contain '%s'", "quoted"),
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   353
                (a) -> assertHelp(a, "/help /help", "/help <command>")
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   354
        );
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   355
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   356
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   357
    @Test
42412
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   358
    public void testHelpFormat() {
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   359
        test(
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   360
                (a) -> assertCommandCheckOutput(a, "/help", s -> {
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   361
                    String[] lines = s.split("\\R");
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   362
                    assertTrue(lines.length > 20,
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   363
                            "Too few lines of /help output: " + lines.length
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   364
                          + "\n" + s);
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   365
                    for (int i = 0; i < lines.length; ++i) {
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   366
                        String l = lines[i];
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   367
                        assertTrue(l.startsWith("| "),
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   368
                                "Expected /help line to start with | :\n" + l);
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   369
                        assertTrue(l.length() <= 80,
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   370
                                "/help line too long: " + l.length() + "\n" + l);
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   371
                    }
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   372
                 })
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   373
        );
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   374
    }
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   375
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   376
    private void assertHelp(boolean a, String command, String... find) {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   377
        assertCommandCheckOutput(a, command, s -> {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   378
            for (String f : find) {
42412
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   379
                assertTrue(s.contains(f),
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   380
                        "Expected output of " + command + " to contain: " + f
ca6f4f1914b2 8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents: 41937
diff changeset
   381
                      + "\n" + s);
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   382
            }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   383
        });
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   384
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   385
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   386
    // Check that each line of output contains the corresponding string from the list
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   387
    private void checkLineToList(String in, List<String> match) {
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   388
        String trimmed = in.trim();
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   389
        String[] res = trimmed.isEmpty()
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   390
                ? new String[0]
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   391
                : trimmed.split("\n");
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   392
        assertEquals(res.length, match.size(), "Got: " + Arrays.asList(res));
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   393
        for (int i = 0; i < match.size(); ++i) {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   394
            assertTrue(res[i].contains(match.get(i)));
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   395
        }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   396
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   397
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   398
    @Test
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   399
    public void testListArgs() {
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   400
        String arg = "qqqq";
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   401
        List<String> startVarList = new ArrayList<>(START_UP);
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   402
        startVarList.add("int aardvark");
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   403
        test(
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   404
                a -> assertCommandCheckOutput(a, "/list -all",
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   405
                        s -> checkLineToList(s, START_UP)),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   406
                a -> assertCommandOutputStartsWith(a, "/list " + arg,
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   407
                        "|  No such snippet: " + arg),
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   408
                a -> assertVariable(a, "int", "aardvark"),
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   409
                a -> assertCommandOutputContains(a, "/list aardvark", "aardvark"),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   410
                a -> assertCommandCheckOutput(a, "/list -start",
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   411
                        s -> checkLineToList(s, START_UP)),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   412
                a -> assertCommandCheckOutput(a, "/list -all",
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   413
                        s -> checkLineToList(s, startVarList)),
42972
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   414
                a -> assertCommandOutputStartsWith(a, "/list s3",
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   415
                        "s3 : import"),
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   416
                a -> assertCommandOutputStartsWith(a, "/list " + arg,
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   417
                        "|  No such snippet: " + arg)
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   418
        );
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   419
    }
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   420
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   421
    @Test
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   422
    public void testVarsArgs() {
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   423
        String arg = "qqqq";
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   424
        List<String> startVarList = new ArrayList<>();
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   425
        test(
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   426
                a -> assertCommandCheckOutput(a, "/vars -all",
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   427
                        s -> checkLineToList(s, startVarList)),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   428
                a -> assertCommand(a, "/vars " + arg,
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   429
                        "|  No such snippet: " + arg),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   430
                a -> assertVariable(a, "int", "aardvark"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   431
                a -> assertMethod(a, "int f() { return 0; }", "()int", "f"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   432
                a -> assertVariable(a, "int", "a"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   433
                a -> assertVariable(a, "double", "a", "1", "1.0"),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   434
                a -> assertCommandOutputStartsWith(a, "/vars aardvark",
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   435
                        "|    int aardvark = 0"),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   436
                a -> assertCommandCheckOutput(a, "/vars -start",
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   437
                        s -> checkLineToList(s, startVarList)),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   438
                a -> assertCommandOutputStartsWith(a, "/vars -all",
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   439
                        "|    int aardvark = 0\n|    int a = "),
42972
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   440
                a -> assertCommandOutputStartsWith(a, "/vars f",
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   441
                        "|  This command does not accept the snippet 'f'"),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   442
                a -> assertCommand(a, "/var " + arg,
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   443
                        "|  No such snippet: " + arg)
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   444
        );
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   445
    }
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   446
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   447
    @Test
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   448
    public void testMethodsArgs() {
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   449
        String arg = "qqqq";
42972
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   450
        List<String> printingMethodList = new ArrayList<>(PRINTING_CMD_METHOD);
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   451
        test(new String[]{"--startup", "PRINTING"},
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   452
                a -> assertCommandCheckOutput(a, "/methods -all",
42972
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   453
                        s -> checkLineToList(s, printingMethodList)),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   454
                a -> assertCommandCheckOutput(a, "/methods -start",
42972
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   455
                        s -> checkLineToList(s, printingMethodList)),
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   456
                a -> assertCommandCheckOutput(a, "/methods print println printf",
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   457
                        s -> checkLineToList(s, printingMethodList)),
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   458
                a -> assertCommandCheckOutput(a, "/methods println",
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   459
                        s -> assertEquals(s.trim().split("\n").length, 10)),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   460
                a -> assertCommandCheckOutput(a, "/methods",
42972
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   461
                        s -> checkLineToList(s, printingMethodList)),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   462
                a -> assertCommandOutputStartsWith(a, "/methods " + arg,
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   463
                        "|  No such snippet: " + arg),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   464
                a -> assertMethod(a, "int f() { return 0; }", "()int", "f"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   465
                a -> assertVariable(a, "int", "aardvark"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   466
                a -> assertMethod(a, "void f(int a) { g(); }", "(int)void", "f"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   467
                a -> assertMethod(a, "void g() {}", "()void", "g"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   468
                a -> assertCommandOutputStartsWith(a, "/methods " + arg,
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   469
                        "|  No such snippet: " + arg),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   470
                a -> assertCommandOutputStartsWith(a, "/methods aardvark",
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   471
                        "|  This command does not accept the snippet 'aardvark' : int aardvark"),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   472
                a -> assertCommandCheckOutput(a, "/methods -start",
42972
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   473
                        s -> checkLineToList(s, printingMethodList)),
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   474
                a -> assertCommandCheckOutput(a, "/methods print println printf",
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   475
                        s -> checkLineToList(s, printingMethodList)),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   476
                a -> assertCommandOutputStartsWith(a, "/methods g",
43759
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   477
                        "|    void g()"),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   478
                a -> assertCommandOutputStartsWith(a, "/methods f",
43759
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   479
                        "|    int f()\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   480
                        "|    void f(int)")
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   481
        );
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   482
    }
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   483
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   484
    @Test
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   485
    public void testMethodsWithErrors() {
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   486
        test(new String[]{"--no-startup"},
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   487
                a -> assertCommand(a, "double m(int x) { return x; }",
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   488
                        "|  created method m(int)"),
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   489
                a -> assertCommand(a, "GARBAGE junk() { return TRASH; }",
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   490
                        "|  created method junk(), however, it cannot be referenced until class GARBAGE, and variable TRASH are declared"),
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   491
                a -> assertCommand(a, "int w = 5;",
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   492
                        "w ==> 5"),
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   493
                a -> assertCommand(a, "int tyer() { return w; }",
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   494
                        "|  created method tyer()"),
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   495
                a -> assertCommand(a, "String w = \"hi\";",
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   496
                        "w ==> \"hi\""),
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   497
                a -> assertCommand(a, "/methods",
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   498
                        "|    double m(int)\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   499
                        "|    GARBAGE junk()\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   500
                        "|       which cannot be referenced until class GARBAGE, and variable TRASH are declared\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   501
                        "|    int tyer()\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   502
                        "|       which cannot be invoked until this error is corrected: \n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   503
                        "|          incompatible types: java.lang.String cannot be converted to int\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   504
                        "|          int tyer() { return w; }\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   505
                        "|                              ^\n")
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   506
        );
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   507
    }
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   508
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   509
    @Test
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   510
    public void testTypesWithErrors() {
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   511
        test(new String[]{"--no-startup"},
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   512
                a -> assertCommand(a, "class C extends NONE { int x; }",
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   513
                        "|  created class C, however, it cannot be referenced until class NONE is declared"),
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   514
                a -> assertCommand(a, "class D { void m() { System.out.println(nada); } }",
43766
498b07dcf851 8174262: Error message misspelling: "instanciated"
rfield
parents: 43759
diff changeset
   515
                        "|  created class D, however, it cannot be instantiated or its methods invoked until variable nada is declared"),
43759
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   516
                a -> assertCommand(a, "/types",
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   517
                        "|    class C\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   518
                        "|       which cannot be referenced until class NONE is declared\n" +
61535ac55add 8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents: 43586
diff changeset
   519
                        "|    class D\n" +
43766
498b07dcf851 8174262: Error message misspelling: "instanciated"
rfield
parents: 43759
diff changeset
   520
                        "|       which cannot be instantiated or its methods invoked until variable nada is declared\n")
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   521
        );
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   522
    }
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   523
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   524
    @Test
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   525
    public void testTypesArgs() {
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   526
        String arg = "qqqq";
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   527
        List<String> startTypeList = new ArrayList<>();
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   528
        test(
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   529
                a -> assertCommandCheckOutput(a, "/types -all",
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   530
                        s -> checkLineToList(s, startTypeList)),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   531
                a -> assertCommandCheckOutput(a, "/types -start",
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   532
                        s -> checkLineToList(s, startTypeList)),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   533
                a -> assertCommandOutputStartsWith(a, "/types " + arg,
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   534
                        "|  No such snippet: " + arg),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   535
                a -> assertVariable(a, "int", "aardvark"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   536
                (a) -> assertClass(a, "class A { }", "class", "A"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   537
                (a) -> assertClass(a, "interface A { }", "interface", "A"),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   538
                a -> assertCommandOutputStartsWith(a, "/types -all",
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   539
                        "|    class A\n" +
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   540
                        "|    interface A"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   541
                (a) -> assertClass(a, "enum E { }", "enum", "E"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   542
                (a) -> assertClass(a, "@interface B { }", "@interface", "B"),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   543
                a -> assertCommand(a, "/types aardvark",
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   544
                        "|  This command does not accept the snippet 'aardvark' : int aardvark;"),
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   545
                a -> assertCommandOutputStartsWith(a, "/types A",
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   546
                        "|    interface A"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   547
                a -> assertCommandOutputStartsWith(a, "/types E",
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   548
                        "|    enum E"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   549
                a -> assertCommandOutputStartsWith(a, "/types B",
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   550
                        "|    @interface B"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   551
                a -> assertCommandOutputStartsWith(a, "/types " + arg,
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   552
                        "|  No such snippet: " + arg),
38520
17e72b872ffd 8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents: 38514
diff changeset
   553
                a -> assertCommandCheckOutput(a, "/types -start",
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   554
                        s -> checkLineToList(s, startTypeList))
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   555
        );
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   556
    }
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   557
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   558
    @Test
43274
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   559
    public void testBlankLinesInSnippetContinuation() {
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   560
        test(Locale.ROOT, false, new String[]{"--no-startup"}, "",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   561
                a -> assertCommand(a, "class C {",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   562
                        ""),
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   563
                a -> assertCommand(a, "",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   564
                        ""),
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   565
                a -> assertCommand(a, "",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   566
                        ""),
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   567
                a -> assertCommand(a, "  int x;",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   568
                        ""),
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   569
                a -> assertCommand(a, "",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   570
                        ""),
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   571
                a -> assertCommand(a, "",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   572
                        ""),
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   573
                a -> assertCommand(a, "}",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   574
                        "|  created class C"),
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   575
                a -> assertCommand(a, "/list",
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   576
                        "\n" +
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   577
                        "   1 : class C {\n" +
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   578
                        "       \n" +
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   579
                        "       \n" +
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   580
                        "         int x;\n" +
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   581
                        "       \n" +
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   582
                        "       \n" +
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   583
                        "       }")
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   584
        );
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   585
    }
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   586
6b5ed4f9fb81 8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents: 43038
diff changeset
   587
    @Test
42972
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   588
    public void testCompoundStart() {
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   589
        test(new String[]{"--startup", "DEFAULT", "--startup", "PRINTING"},
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   590
                (a) -> assertCommand(a, "printf(\"%4.2f\", Math.PI)",
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   591
                        "", "", null, "3.14", "")
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   592
        );
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   593
    }
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   594
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   595
    @Test
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   596
    public void testJavaSeStart() {
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   597
        test(new String[]{"--startup", "JAVASE"},
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   598
                (a) -> assertCommand(a, "ZoneOffsetTransitionRule.TimeDefinition.WALL",
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   599
                        "$1 ==> WALL")
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   600
        );
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   601
    }
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   602
47ca49eee534 8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents: 42969
diff changeset
   603
    @Test
38514
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   604
    public void defineClasses() {
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   605
        test(
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   606
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   607
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   608
                (a) -> assertClass(a, "class A { }", "class", "A"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   609
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   610
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   611
                (a) -> assertClass(a, "interface A { }", "interface", "A"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   612
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   613
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   614
                (a) -> assertClass(a, "enum A { }", "enum", "A"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   615
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   616
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   617
                (a) -> assertClass(a, "@interface A { }", "@interface", "A"),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   618
                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   619
                (a) -> assertCommandCheckOutput(a, "/types", assertClasses())
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   620
        );
f7df9ab653b0 8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents: 37745
diff changeset
   621
    }
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   622
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   623
    @Test
37389
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   624
    public void testCommandPrefix() {
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   625
        test(a -> assertCommandCheckOutput(a, "/s",
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   626
                      assertStartsWith("|  Command: '/s' is ambiguous: /save, /set")),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   627
             a -> assertCommand(a, "int var", "var ==> 0"),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   628
             a -> assertCommandCheckOutput(a, "/va",
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   629
                      assertStartsWith("|    int var = 0")),
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   630
             a -> assertCommandCheckOutput(a, "/save",
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   631
                      assertStartsWith("|  '/save' requires a filename argument.")));
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   632
    }
9c137b83a8b8 8143955: JShell tool (UX): Output structure
rfield
parents: 37007
diff changeset
   633
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   634
    @Test
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   635
    public void testOptionQ() {
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   636
        test(Locale.ROOT, false, new String[]{"-q", "--no-startup"}, "",
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   637
                (a) -> assertCommand(a, "1+1", "$1 ==> 2"),
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   638
                (a) -> assertCommand(a, "int x = 5", "")
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   639
        );
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   640
    }
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   641
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   642
    @Test
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   643
    public void testOptionS() {
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   644
        test(Locale.ROOT, false, new String[]{"-s", "--no-startup"}, "",
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   645
                (a) -> assertCommand(a, "1+1", "")
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   646
        );
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   647
    }
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   648
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   649
    @Test
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   650
    public void testOptionV() {
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   651
        test(new String[]{"-v", "--no-startup"},
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   652
                (a) -> assertCommand(a, "1+1",
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   653
                        "$1 ==> 2\n" +
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   654
                        "|  created scratch variable $1 : int")
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   655
        );
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   656
    }
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   657
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   658
    @Test
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   659
    public void testOptionFeedback() {
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   660
        test(Locale.ROOT, false, new String[]{"--feedback", "concise", "--no-startup"}, "",
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   661
                (a) -> assertCommand(a, "1+1", "$1 ==> 2"),
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   662
                (a) -> assertCommand(a, "int x = 5", "")
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   663
        );
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   664
    }
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   665
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   666
    @Test
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   667
    public void testCompoundOptions() {
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   668
        Consumer<String> confirmNoStartup = s -> {
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   669
                    assertEquals(0, Stream.of(s.split("\n"))
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   670
                            .filter(l -> !l.isEmpty())
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   671
                            .count(), "Expected no lines: " + s);
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   672
                };
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   673
        test(Locale.ROOT, false, new String[]{"-nq"}, "",
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   674
                (a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup),
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   675
                (a) -> assertCommand(a, "1+1", "$1 ==> 2"),
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   676
                (a) -> assertCommand(a, "int x = 5", "")
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   677
        );
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   678
        test(Locale.ROOT, false, new String[]{"-qn"}, "",
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   679
                (a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup),
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   680
                (a) -> assertCommand(a, "1+1", "$1 ==> 2"),
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   681
                (a) -> assertCommand(a, "int x = 5", "")
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   682
        );
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   683
        test(Locale.ROOT, false, new String[]{"-ns"}, "",
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   684
                (a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup),
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   685
                (a) -> assertCommand(a, "1+1", "")
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   686
        );
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   687
    }
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   688
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   689
    @Test
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   690
    public void testOptionR() {
40588
b5c32bfa9710 8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents: 38835
diff changeset
   691
        test(new String[]{"-R-Dthe.sound=blorp", "--no-startup"},
37745
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   692
                (a) -> assertCommand(a, "System.getProperty(\"the.sound\")",
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   693
                        "$1 ==> \"blorp\"")
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   694
        );
4b6b59f8e327 8150382: JShell API: Allow setting remote JVM arguments
rfield
parents: 37389
diff changeset
   695
    }
38531
c449daa25b45 8157200: jshell tool: Add /retain command to persist settings
rfield
parents: 38520
diff changeset
   696
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents: 42412
diff changeset
   697
    @Test
43038
7b8b8750a78e 8165405: jshell tool: /classpath is inconsistent
rfield
parents: 42972
diff changeset
   698
    public void testWrapSourceHandlerDiagCrash() {
7b8b8750a78e 8165405: jshell tool: /classpath is inconsistent
rfield
parents: 42972
diff changeset
   699
        test(new String[]{"--add-exports", "jdk.javadoc/ALL-UNNAMED"},
7b8b8750a78e 8165405: jshell tool: /classpath is inconsistent
rfield
parents: 42972
diff changeset
   700
                (a) -> assertCommand(a, "1+1", "$1 ==> 2")
7b8b8750a78e 8165405: jshell tool: /classpath is inconsistent
rfield
parents: 42972
diff changeset
   701
         );
7b8b8750a78e 8165405: jshell tool: /classpath is inconsistent
rfield
parents: 42972
diff changeset
   702
    }
7b8b8750a78e 8165405: jshell tool: /classpath is inconsistent
rfield
parents: 42972
diff changeset
   703
7b8b8750a78e 8165405: jshell tool: /classpath is inconsistent
rfield
parents: 42972
diff changeset
   704
    @Test
38531
c449daa25b45 8157200: jshell tool: Add /retain command to persist settings
rfield
parents: 38520
diff changeset
   705
    public void test8156910() {
c449daa25b45 8157200: jshell tool: Add /retain command to persist settings
rfield
parents: 38520
diff changeset
   706
        test(
c449daa25b45 8157200: jshell tool: Add /retain command to persist settings
rfield
parents: 38520
diff changeset
   707
                (a) -> assertCommandOutputContains(a, "System.out.println(\"%5d\", 10);", "%5d"),
c449daa25b45 8157200: jshell tool: Add /retain command to persist settings
rfield
parents: 38520
diff changeset
   708
                (a) -> assertCommandOutputContains(a, "1234", "==> 1234")
c449daa25b45 8157200: jshell tool: Add /retain command to persist settings
rfield
parents: 38520
diff changeset
   709
        );
c449daa25b45 8157200: jshell tool: Add /retain command to persist settings
rfield
parents: 38520
diff changeset
   710
    }
37007
6023a9a9d58a 8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff changeset
   711
}