Path: blob/master/test/langtools/jdk/jshell/HistoryUITest.java
40930 views
/*1* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 8178077 823285626* @summary Check the UI behavior of editing history.27* @modules28* jdk.compiler/com.sun.tools.javac.api29* jdk.compiler/com.sun.tools.javac.main30* jdk.jshell/jdk.internal.jshell.tool:open31* jdk.jshell/jdk.internal.jshell.tool.resources:open32* jdk.jshell/jdk.jshell:open33* @library /tools/lib34* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask35* @build Compiler UITesting36* @compile HistoryUITest.java37* @run testng HistoryUITest38*/3940import org.testng.annotations.Test;4142@Test43public class HistoryUITest extends UITesting {4445public HistoryUITest() {46super(true);47}4849public void testPrevNextSnippet() throws Exception {50doRunTest((inputSink, out) -> {51inputSink.write("void test1() {\nSystem.err.println(1);\n}\n");52waitOutput(out, PROMPT);53inputSink.write("void test2() {\nSystem.err.println(2);\n}\n");54waitOutput(out, PROMPT);55inputSink.write(UP);56waitOutput(out, "^void test2\\(\\) \\{\n" +57CONTINUATION_PROMPT + " System.err.println\\(2\\);\n" +58CONTINUATION_PROMPT + "\\}");59inputSink.write(UP);60waitOutput(out, "^\u001b\\[A");61inputSink.write(UP);62waitOutput(out, "^\u001b\\[A");63inputSink.write(UP);64waitOutput(out, "^\u001b\\[8C1\n" +65"\u001b\\[23C1\n\u001b\\[C");66inputSink.write(DOWN);67waitOutput(out, "^\u001B\\[2A\u001b\\[8C2\n" +68"\u001b\\[23C2\n\u001b\\[C");69inputSink.write(UP);70waitOutput(out, "^\u001b\\[A");71for (int i = 0; i < 23; i++) inputSink.write("\033[C");72waitOutput(out, "C");73inputSink.write("\u0008\"Modified!\"\n");74waitOutput(out, PROMPT);75inputSink.write("test2()\n");76waitOutput(out, "\\u001B\\[\\?2004lModified!\n\\u001B\\[\\?2004h" + PROMPT);77});78}7980public void testReRun() throws Exception {81doRunTest((inputSink, out) -> {82inputSink.write("System.err.println(\"RAN\");\n");83waitOutput(out, "RAN.*" + PROMPT);84inputSink.write("/!\n");85waitOutput(out, "RAN.*" + PROMPT);86inputSink.write(UP);87inputSink.write("\n");88waitOutput(out, "RAN.*" + PROMPT);89});90}9192}939495