diff --git a/src/test/java/org/jetbrains/plugins/ideavim/IjSharedTestCaseList.kt b/src/test/java/org/jetbrains/plugins/ideavim/IjSharedTestCaseList.kt new file mode 100644 index 0000000000..450b082c97 --- /dev/null +++ b/src/test/java/org/jetbrains/plugins/ideavim/IjSharedTestCaseList.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2003-2024 The IdeaVim authors + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE.txt file or at + * https://opensource.org/licenses/MIT. + */ + +package org.jetbrains.plugins.ideavim + +import com.maddyhome.idea.vim.model.SharedTestCase +import com.maddyhome.idea.vim.SharedTestCaseList +import org.jetbrains.plugins.ideavim.action.change.delete.DeleteVisualLinesActionTestImpl +import org.jetbrains.plugins.ideavim.action.change.insert.InsertDeleteActionTestImpl + +@Suppress("unused") +class IjSharedTestCaseList : SharedTestCaseList { + override val insertDeleteActionTest: SharedTestCase = InsertDeleteActionTestImpl() + override val deleteVisualLinesActionTest: SharedTestCase = DeleteVisualLinesActionTestImpl() +} \ No newline at end of file diff --git a/src/test/java/org/jetbrains/plugins/ideavim/action/change/delete/DeleteVisualLinesActionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/action/change/delete/DeleteVisualLinesActionTest.kt deleted file mode 100644 index 68ee0a7cf4..0000000000 --- a/src/test/java/org/jetbrains/plugins/ideavim/action/change/delete/DeleteVisualLinesActionTest.kt +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2003-2023 The IdeaVim authors - * - * Use of this source code is governed by an MIT-style - * license that can be found in the LICENSE.txt file or at - * https://opensource.org/licenses/MIT. - */ - -@file:Suppress("RemoveCurlyBracesFromTemplate") - -package org.jetbrains.plugins.ideavim.action.change.delete - -import com.maddyhome.idea.vim.state.mode.Mode -import org.jetbrains.plugins.ideavim.VimTestCaseBase -import org.junit.jupiter.api.Test - -class DeleteVisualLinesActionTest : VimTestCaseBase() { - @Test - fun `test remove line in char visual mode`() { - doTest( - "vlllX", - """ - I found ${c}it in a legendary land - consectetur adipiscing elit - Sed in orci mauris. - Cras id tellus in ex imperdiet egestas. - """.trimIndent(), - """ - ${c}consectetur adipiscing elit - Sed in orci mauris. - Cras id tellus in ex imperdiet egestas. - """.trimIndent(), - Mode.NORMAL(), - ) - } - - @Test - fun `test remove line in char visual mode last line`() { - doTest( - "vlllX", - """ - Lorem ipsum dolor sit amet, - consectetur adipiscing elit - Sed in orci mauris. - hard by ${c}the torrent of a mountain pass. - """.trimIndent(), - """ - Lorem ipsum dolor sit amet, - consectetur adipiscing elit - ${c}Sed in orci mauris. - """.trimIndent(), - Mode.NORMAL(), - ) - } - - @Test - fun `test remove line in line visual mode`() { - doTest( - "VX", - """ - I found ${c}it in a legendary land - consectetur adipiscing elit - Sed in orci mauris. - Cras id tellus in ex imperdiet egestas. - """.trimIndent(), - """ - ${c}consectetur adipiscing elit - Sed in orci mauris. - Cras id tellus in ex imperdiet egestas. - """.trimIndent(), - Mode.NORMAL(), - ) - } - - @Test - fun `test remove line in line visual mode line end`() { - doTest( - "VX", - """ - Lorem ipsum dolor sit amet, - consectetur adipiscing elit - Sed in orci mauris. - hard by ${c}the torrent of a mountain pass. - """.trimIndent(), - """ - Lorem ipsum dolor sit amet, - consectetur adipiscing elit - ${c}Sed in orci mauris. - """.trimIndent(), - Mode.NORMAL(), - ) - } - - @Test - fun `test multiple line delete till the end`() { - val keys = "Vjd" - val before = """ - Lorem Ipsum - - Lorem ipsum dolor sit amet, - consectetur adipiscing elit - - ${c}Sed in orci mauris. - Cras id tellus in ex imperdiet egestas. - """.trimIndent() - val after = """ - Lorem Ipsum - - Lorem ipsum dolor sit amet, - consectetur adipiscing elit - ${c} - """.trimIndent() - doTest(keys, before, after, Mode.NORMAL()) - } - - @Test - fun `test multiple line delete till the end with a new line`() { - val keys = "Vjd" - val before = """ - Lorem Ipsum - - Lorem ipsum dolor sit amet, - consectetur adipiscing elit - - ${c}Sed in orci mauris. - Cras id tellus in ex imperdiet egestas. - - """.trimIndent() - val after = """ - Lorem Ipsum - - Lorem ipsum dolor sit amet, - consectetur adipiscing elit - - ${c} - """.trimIndent() - doTest(keys, before, after, Mode.NORMAL()) - } -} diff --git a/src/test/java/org/jetbrains/plugins/ideavim/action/change/delete/DeleteVisualLinesActionTestImpl.kt b/src/test/java/org/jetbrains/plugins/ideavim/action/change/delete/DeleteVisualLinesActionTestImpl.kt new file mode 100644 index 0000000000..89b2dd2a96 --- /dev/null +++ b/src/test/java/org/jetbrains/plugins/ideavim/action/change/delete/DeleteVisualLinesActionTestImpl.kt @@ -0,0 +1,16 @@ +/* + * Copyright 2003-2023 The IdeaVim authors + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE.txt file or at + * https://opensource.org/licenses/MIT. + */ + +@file:Suppress("RemoveCurlyBracesFromTemplate") + +package org.jetbrains.plugins.ideavim.action.change.delete + +import com.maddyhome.idea.vim.action.change.delete.DeleteVisualLinesActionTest +import org.jetbrains.plugins.ideavim.VimTestCaseBase + +class DeleteVisualLinesActionTestImpl : DeleteVisualLinesActionTest, VimTestCaseBase() diff --git a/src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertDeleteActionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertDeleteActionTestImpl.kt similarity index 55% rename from src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertDeleteActionTest.kt rename to src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertDeleteActionTestImpl.kt index ad0255cc50..a695450650 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertDeleteActionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/action/change/insert/InsertDeleteActionTestImpl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2003-2023 The IdeaVim authors + * Copyright 2003-2024 The IdeaVim authors * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE.txt file or at @@ -8,22 +8,16 @@ package org.jetbrains.plugins.ideavim.action.change.insert -import com.maddyhome.idea.vim.api.injector +import com.maddyhome.idea.vim.action.change.insert.InsertDeleteActionTest import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.VimTestCaseBase import org.junit.jupiter.api.Test -class InsertDeleteActionTest : VimTestCaseBase() { +class InsertDeleteActionTestImpl : InsertDeleteActionTest, VimTestCaseBase() { @TestWithoutNeovim(SkipNeovimReason.DIFFERENT) @Test - fun `test insert delete`() { - val before = "I fo${c}und it in a legendary land" - val after = "I fo${c}nd it in a legendary land" - configureByText(before) - - typeText(injector.parser.parseKeys("i" + "")) - - assertState(after) + override fun `test insert delete`() { + super.`test insert delete`() } -} +} \ No newline at end of file diff --git a/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/model/SharedTestCaseList.kt b/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/SharedTestCaseList.kt similarity index 78% rename from vim-engine/src/test/kotlin/com/maddyhome/idea/vim/model/SharedTestCaseList.kt rename to vim-engine/src/test/kotlin/com/maddyhome/idea/vim/SharedTestCaseList.kt index b7e5abab9a..0839cca2c9 100644 --- a/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/model/SharedTestCaseList.kt +++ b/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/SharedTestCaseList.kt @@ -6,7 +6,9 @@ * https://opensource.org/licenses/MIT. */ -package com.maddyhome.idea.vim.model +package com.maddyhome.idea.vim + +import com.maddyhome.idea.vim.model.SharedTestCase /** * List of all shared test classes. @@ -16,5 +18,7 @@ package com.maddyhome.idea.vim.model * This class doesn't run any tests; it only declares them. * Compilation errors resulting from this class will help IDE developers understand whether they have implemented all the vim-engine tests. */ -abstract class SharedTestCaseList { +interface SharedTestCaseList { + val insertDeleteActionTest: SharedTestCase + val deleteVisualLinesActionTest: SharedTestCase } \ No newline at end of file diff --git a/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/action/change/delete/DeleteVisualLinesActionTest.kt b/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/action/change/delete/DeleteVisualLinesActionTest.kt new file mode 100644 index 0000000000..0fc450160a --- /dev/null +++ b/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/action/change/delete/DeleteVisualLinesActionTest.kt @@ -0,0 +1,155 @@ +/* + * Copyright 2003-2023 The IdeaVim authors + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE.txt file or at + * https://opensource.org/licenses/MIT. + */ + +@file:Suppress("RemoveCurlyBracesFromTemplate") + +package com.maddyhome.idea.vim.action.change.delete + +import com.maddyhome.idea.vim.model.VimTestCase +import com.maddyhome.idea.vim.state.mode.Mode +import org.junit.jupiter.api.Test + +interface DeleteVisualLinesActionTest : VimTestCase { + @Test + fun `test remove line in char visual mode`() { + configureByText( + """ + I found ${c}it in a legendary land + consectetur adipiscing elit + Sed in orci mauris. + Cras id tellus in ex imperdiet egestas. + """.trimIndent(), + ) + typeText("vlllX") + assertState( + """ + ${c}consectetur adipiscing elit + Sed in orci mauris. + Cras id tellus in ex imperdiet egestas. + """.trimIndent(), + Mode.NORMAL() + ) + } + + @Test + fun `test remove line in char visual mode last line`() { + configureByText( + """ + Lorem ipsum dolor sit amet, + consectetur adipiscing elit + Sed in orci mauris. + hard by ${c}the torrent of a mountain pass. + """.trimIndent(), + ) + typeText("vlllX") + assertState( + """ + Lorem ipsum dolor sit amet, + consectetur adipiscing elit + ${c}Sed in orci mauris. + """.trimIndent(), + Mode.NORMAL(), + ) + } + + @Test + fun `test remove line in line visual mode`() { + configureByText( + """ + I found ${c}it in a legendary land + consectetur adipiscing elit + Sed in orci mauris. + Cras id tellus in ex imperdiet egestas. + """.trimIndent(), + ) + typeText("VX") + assertState( + """ + ${c}consectetur adipiscing elit + Sed in orci mauris. + Cras id tellus in ex imperdiet egestas. + """.trimIndent(), + Mode.NORMAL(), + ) + } + + @Test + fun `test remove line in line visual mode line end`() { + configureByText( + """ + Lorem ipsum dolor sit amet, + consectetur adipiscing elit + Sed in orci mauris. + hard by ${c}the torrent of a mountain pass. + """.trimIndent(), + ) + typeText("VX") + assertState( + """ + Lorem ipsum dolor sit amet, + consectetur adipiscing elit + ${c}Sed in orci mauris. + """.trimIndent(), + Mode.NORMAL(), + ) + } + + @Test + fun `test multiple line delete till the end`() { + configureByText( + """ + Lorem Ipsum + + Lorem ipsum dolor sit amet, + consectetur adipiscing elit + + ${c}Sed in orci mauris. + Cras id tellus in ex imperdiet egestas. + """.trimIndent() + ) + typeText("Vjd") + assertState( + """ + Lorem Ipsum + + Lorem ipsum dolor sit amet, + consectetur adipiscing elit + ${c} + """.trimIndent(), + Mode.NORMAL(), + ) + } + + @Test + fun `test multiple line delete till the end with a new line`() { + configureByText( + """ + Lorem Ipsum + + Lorem ipsum dolor sit amet, + consectetur adipiscing elit + + ${c}Sed in orci mauris. + Cras id tellus in ex imperdiet egestas. + + """.trimIndent() + ) + typeText("Vjd") + assertState( + """ + Lorem Ipsum + + Lorem ipsum dolor sit amet, + consectetur adipiscing elit + + ${c} + """.trimIndent(), + Mode.NORMAL(), + ) + } +} diff --git a/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/action/change/insert/InsertDeleteActionTest.kt b/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/action/change/insert/InsertDeleteActionTest.kt new file mode 100644 index 0000000000..3a5182be37 --- /dev/null +++ b/vim-engine/src/test/kotlin/com/maddyhome/idea/vim/action/change/insert/InsertDeleteActionTest.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2003-2024 The IdeaVim authors + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE.txt file or at + * https://opensource.org/licenses/MIT. + */ + +package com.maddyhome.idea.vim.action.change.insert + +import com.maddyhome.idea.vim.model.VimTestCase +import org.junit.jupiter.api.Test + +interface InsertDeleteActionTest : VimTestCase { + @Test + fun `test insert delete`() { + val before = "I fo${c}und it in a legendary land" + val after = "I fo${c}nd it in a legendary land" + configureByText(before) + typeText("i", "") + + assertState(after) + } +}