Path: blob/master/test/langtools/jdk/jshell/IndentUITest.java
40930 views
/*1* Copyright (c) 2020, 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 8241950 824793226* @summary Check the UI behavior of indentation27* @library /tools/lib28* @modules29* jdk.compiler/com.sun.tools.javac.api30* jdk.compiler/com.sun.tools.javac.main31* jdk.jshell/jdk.internal.jshell.tool:open32* jdk.jshell/jdk.internal.jshell.tool.resources:open33* jdk.jshell/jdk.jshell:open34* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask35* @build Compiler UITesting36* @compile IndentUITest.java37* @run testng IndentUITest38*/3940import org.testng.annotations.Test;4142@Test43public class IndentUITest extends UITesting {4445public IndentUITest() {46super(true);47}4849public void testIdent() throws Exception {50doRunTest((inputSink, out) -> {51inputSink.write("void test1() {\nSystem.err.println(1);\n}\n");52waitOutput(out, "void test1\\(\\)\u001B\\[2D\u001B\\[2C \\{\n" +53CONTINUATION_PROMPT + " System.err.println\\(1\\)\u001B\\[3D\u001B\\[3C;\n" +54CONTINUATION_PROMPT + " \\}\u001B\\[2A\u001B\\[8C\n\n\u001B\\[K\\}\n" +55"\u001B\\[\\?2004l\\| created method test1\\(\\)\n" +56"\u001B\\[\\?2004h" + PROMPT);57inputSink.write(UP);58waitOutput(out, "^void test1\\(\\) \\{\n" +59CONTINUATION_PROMPT + " System.err.println\\(1\\);\n" +60CONTINUATION_PROMPT + "\\}");61inputSink.write(DOWN);62inputSink.write("/set indent 2\n");63inputSink.write("void test2() {\nSystem.err.println(1);\n}\n");64waitOutput(out, "void test2\\(\\)\u001B\\[2D\u001B\\[2C \\{\n" +65CONTINUATION_PROMPT + " System.err.println\\(1\\)\u001B\\[3D\u001B\\[3C;\n" +66CONTINUATION_PROMPT + " \\}\u001B\\[2A\u001B\\[10C\n\n\u001B\\[K\\}\n" +67"\u001B\\[\\?2004l\\| created method test2\\(\\)\n" +68"\u001B\\[\\?2004h" + PROMPT);69inputSink.write(UP);70waitOutput(out, "^void test2\\(\\) \\{\n" +71CONTINUATION_PROMPT + " System.err.println\\(1\\);\n" +72CONTINUATION_PROMPT + "\\}");73inputSink.write(INTERRUPT);74waitOutput(out, "\u001B\\[\\?2004h" + PROMPT);75inputSink.write("\"\"\"\n");76waitOutput(out, "^\"\"\"\n" +77CONTINUATION_PROMPT);78});79}8081}828384