nicer enter key indentation handling after -> and before } in closures
[fedora-idea.git] / plugins / groovy / test / org / jetbrains / plugins / groovy / lang / formatter / EnterActionTest.groovy
blob3999459350abb3f67c47c2a63b60aedeeabd55cd
1 /*
2 * Copyright 2003-2007 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.jetbrains.plugins.groovy.lang.formatter;
19 import org.jetbrains.plugins.groovy.GroovyFileType;
20 import org.jetbrains.plugins.groovy.util.TestUtils;
22 import java.util.List;
24 /**
25 * @author ilyas
27 public class EnterActionTest extends GroovyFormatterTestCase {
29 @Override
30 protected String getBasePath() {
31 return TestUtils.getTestDataPath() + "groovy/enterAction/";
35 private void doTest() throws Throwable {
36 final List<String> data = TestUtils.readInput(getTestDataPath() + getTestName(true) + ".test");
37 myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, data.get(0));
38 doEnter();
39 myFixture.checkResult(data.get(1));
42 private def doEnter() {
43 myFixture.type((char)'\n')
46 public void testClos1() throws Throwable { doTest(); }
47 public void testClos2() throws Throwable { doTest(); }
48 public void testComment1() throws Throwable { doTest(); }
49 public void testComment2() throws Throwable { doTest(); }
50 public void testComment3() throws Throwable { doTest(); }
51 public void testComment4() throws Throwable { doTest(); }
52 public void testDef() throws Throwable { doTest(); }
53 public void testDef2() throws Throwable { doTest(); }
54 public void testGdoc1() throws Throwable { doTest(); }
55 public void testGdoc2() throws Throwable { doTest(); }
56 public void testGdoc3() throws Throwable { doTest(); }
57 public void testGdoc4() throws Throwable { doTest(); }
58 public void testGdoc5() throws Throwable { doTest(); }
59 public void testGdoc6() throws Throwable { doTest(); }
60 public void testGdoc7() throws Throwable { doTest(); }
61 public void testGdoc8() throws Throwable { doTest(); }
62 public void testGdoc9() throws Throwable { doTest(); }
63 public void testGdoc10() throws Throwable { doTest(); }
64 public void testGdoc11() throws Throwable { doTest(); }
65 public void testGRVY_953() throws Throwable { doTest(); }
66 public void testGstring1() throws Throwable { doTest(); }
67 public void testGstring10() throws Throwable { doTest(); }
68 public void testGstring11() throws Throwable { doTest(); }
69 public void testGstring12() throws Throwable { doTest(); }
70 public void testGstring13() throws Throwable { doTest(); }
71 public void testGstring2() throws Throwable { doTest(); }
72 public void testGstring3() throws Throwable { doTest(); }
73 public void testGstring4() throws Throwable { doTest(); }
74 public void testGstring5() throws Throwable { doTest(); }
75 public void testGstring6() throws Throwable { doTest(); }
76 public void testGstring7() throws Throwable { doTest(); }
77 public void testGstring8() throws Throwable { doTest(); }
78 public void testGstring9() throws Throwable { doTest(); }
79 public void testSpaces1() throws Throwable { doTest(); }
80 public void testString1() throws Throwable { doTest(); }
81 public void testString2() throws Throwable { doTest(); }
82 public void testString3() throws Throwable { doTest(); }
83 public void testString4() throws Throwable { doTest(); }
84 public void testString5() throws Throwable { doTest(); }
85 public void testString6() throws Throwable { doTest(); }
87 public void testAfterClosureArrow() throws Throwable {
88 myFixture.configureByText "a.groovy", """
89 def c = { a -><caret> }
90 """
91 doEnter()
92 myFixture.checkResult """
93 def c = { a ->
94 <caret>
96 """
98 public void testAfterClosureArrowWithBody() throws Throwable {
99 myFixture.configureByText "a.groovy", """
100 def c = { a -><caret> zzz }
102 doEnter()
103 myFixture.checkResult """
104 def c = { a ->
105 <caret> zzz }
108 public void testAfterClosureArrowWithBody2() throws Throwable {
109 myFixture.configureByText "a.groovy", """
110 def c = { a -> <caret>zzz }
112 doEnter()
113 myFixture.checkResult """
114 def c = { a ->
115 <caret>zzz }
116 """, true
119 public void testBeforeClosingClosureBrace() throws Throwable {
120 myFixture.configureByText "a.groovy", """
121 def c = { a ->
122 zzz <caret>}
124 doEnter()
125 myFixture.checkResult """
126 def c = { a ->
127 zzz
128 <caret>}
132 public void testAlmostBeforeClosingClosureBrace() throws Throwable {
133 myFixture.configureByText "a.groovy", """
134 def c = { a ->
135 zzz<caret> }
137 doEnter()
138 myFixture.checkResult """
139 def c = { a ->
141 <caret>}