test/langtools/jdk/jshell/ToolMultilineSnippetHistoryTest.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 45757 langtools/test/jdk/jshell/ToolMultilineSnippetHistoryTest.java@1017cd5d6506
child 52938 5ff7480c9e28
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45746
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     1
/*
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     4
 *
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     8
 *
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    13
 * accompanied this code).
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    14
 *
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    18
 *
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    21
 * questions.
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    22
 */
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    23
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    24
/**
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    25
 * @test
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    26
 * @bug 8182489
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    27
 * @summary test history with multiline snippets
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    28
 * @modules
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    29
 *     jdk.jshell/jdk.internal.jshell.tool.resources:open
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    30
 *     jdk.jshell/jdk.jshell:open
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    31
 * @build UITesting
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    32
 * @build ToolMultilineSnippetHistoryTest
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    33
 * @run testng ToolMultilineSnippetHistoryTest
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    34
 */
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    35
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    36
import org.testng.annotations.Test;
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    37
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    38
@Test
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    39
public class ToolMultilineSnippetHistoryTest extends UITesting {
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    40
45757
1017cd5d6506 8183021: JShell tests: Fix failing tests on Windows
jlahoda
parents: 45746
diff changeset
    41
    public ToolMultilineSnippetHistoryTest() {
1017cd5d6506 8183021: JShell tests: Fix failing tests on Windows
jlahoda
parents: 45746
diff changeset
    42
        super(true);
1017cd5d6506 8183021: JShell tests: Fix failing tests on Windows
jlahoda
parents: 45746
diff changeset
    43
    }
1017cd5d6506 8183021: JShell tests: Fix failing tests on Windows
jlahoda
parents: 45746
diff changeset
    44
45746
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    45
    public void testUpArrow() throws Exception {
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    46
        doRunTest((inputSink, out) -> {
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    47
            inputSink.write("int x=\n44\n");
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    48
            waitOutput(out, "x ==> 44\n\u0005");
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    49
            inputSink.write("/!\n");
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    50
            waitOutput(out, "int x=\n44;\nx ==> 44\n\u0005");
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    51
            inputSink.write("\020");
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    52
            waitOutput(out,   "44;");
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    53
            inputSink.write("\020");
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    54
            waitOutput(out,  "int x=");
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    55
        });
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    56
    }
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    57
a64c9a565bb7 8182489: jshell tool: rerun multiline snippet from history corrupts history
rfield
parents:
diff changeset
    58
}