diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy
index 03ecee6658ae..e50d513f3a27 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy
@@ -25,39 +25,6 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
class GroovyCopyPasteTest extends LightCodeInsightFixtureTestCase {
int myAddImportsOld
- public void testEscapeSlashesInRegex() {
- myFixture.configureByText 'a.groovy', 'a/b'
- myFixture.performEditorAction IdeActions.ACTION_COPY
- myFixture.configureByText 'b.groovy', 'def x = /smth/'
- myFixture.performEditorAction IdeActions.ACTION_PASTE
- myFixture.checkResult 'def x = /smtha\\/b/'
- }
-
- public void testEscapeSlashesInRegexFromRegex() {
- myFixture.configureByText 'a.groovy', 'def x = /a\\/b/'
- myFixture.performEditorAction IdeActions.ACTION_COPY
- myFixture.configureByText 'b.groovy', 'def x = /smth/'
- myFixture.performEditorAction IdeActions.ACTION_PASTE
- myFixture.checkResult 'def x = /smtha\\/b/'
- }
-
- void testDontEscapeSymbolsInRegex(){
- myFixture.configureByText 'a.groovy', '''def x = a/b'''
- myFixture.performEditorAction IdeActions.ACTION_COPY
- myFixture.configureByText 'b.groovy', 'def x = / /'
- myFixture.performEditorAction IdeActions.ACTION_PASTE
- myFixture.checkResult '''def x = /a\\/b /'''
- }
-
- public void testEscapeDollarInGString() {
- myFixture.configureByText 'a.groovy', '''def x = '$ab/'''
- myFixture.performEditorAction IdeActions.ACTION_COPY
- myFixture.configureByText 'b.groovy', 'def x = "smthh"'
- myFixture.performEditorAction IdeActions.ACTION_PASTE
- myFixture.checkResult 'def x = "smth\\$ah"'
-
- }
-
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -73,41 +40,50 @@ class GroovyCopyPasteTest extends LightCodeInsightFixtureTestCase {
settings.ADD_IMPORTS_ON_PASTE = myAddImportsOld;
super.tearDown();
}
+
+ private void doTest(String fromFileName, String fromText, String toText, String expected) {
+ myFixture.configureByText fromFileName, fromText
+ myFixture.performEditorAction IdeActions.ACTION_COPY
+ myFixture.configureByText 'b.groovy', toText
+ myFixture.performEditorAction IdeActions.ACTION_PASTE
+ myFixture.checkResult expected
+ }
+
+ public void testEscapeSlashesInRegex() {
+ doTest 'a.groovy', 'a/b', 'def x = /smth/', 'def x = /smtha\\/b/'
+ }
+
+ public void testEscapeSlashesInRegexFromRegex() {
+ doTest 'a.groovy', 'def x = /a\\/b/', 'def x = /smth/', 'def x = /smtha\\/b/'
+ }
+
+ void testDontEscapeSymbolsInRegex(){
+ doTest 'a.groovy', '''def x = a/b''', 'def x = / /', '''def x = /a\\/b /'''
+ }
+
+ public void testEscapeDollarInGString() {
+ doTest 'a.groovy', '''def x = '$ab/''', 'def x = "smthh"', 'def x = "smth\\$ah"'
+
+ }
public void testRestoreImports() {
myFixture.addClass("package foo; public class Foo {}")
- myFixture.configureByText 'a.groovy', '''import foo.*; Foo f'''
- myFixture.performEditorAction IdeActions.ACTION_COPY
- myFixture.configureByText 'b.groovy', ''
- myFixture.performEditorAction IdeActions.ACTION_PASTE
- myFixture.checkResult '''import foo.Foo
+ doTest 'a.groovy', '''import foo.*; Foo f''', '', '''import foo.Foo
Foo f'''
}
public void testPasteMultilineIntoMultilineGString() throws Exception {
- myFixture.configureByText 'a.txt', 'a/b\nc/d'
- myFixture.performEditorAction IdeActions.ACTION_COPY
- myFixture.configureByText 'b.groovy', 'def x = """smth"""'
- myFixture.performEditorAction IdeActions.ACTION_PASTE
- myFixture.checkResult 'def x = """smtha/b\nc/d"""'
+ doTest 'a.txt', 'a/b\nc/d', 'def x = """smth"""', 'def x = """smtha/b\nc/d"""'
}
public void testPasteMultilineIntoString() throws Exception {
- myFixture.configureByText 'a.txt', 'a\nd'
- myFixture.performEditorAction IdeActions.ACTION_COPY
- myFixture.configureByText 'b.groovy', "def x = 'smth'"
- myFixture.performEditorAction IdeActions.ACTION_PASTE
- myFixture.checkResult "def x = 'smtha\\n' +\n 'd'"
+ doTest 'a.txt', 'a\nd', "def x = 'smth'", "def x = 'smtha\\n' +\n 'd'"
}
public void testPasteMultilineIntoGString() throws Exception {
- myFixture.configureByText 'a.txt', 'a\nd'
- myFixture.performEditorAction IdeActions.ACTION_COPY
- myFixture.configureByText 'b.groovy', 'def x = "smth"'
- myFixture.performEditorAction IdeActions.ACTION_PASTE
- myFixture.checkResult 'def x = "smtha\\n" +\n "d"'
+ doTest 'a.txt', 'a\nd', 'def x = "smth"', 'def x = "smtha\\n" +\n "d"'
}
}