Skip to content

Commit

Permalink
Move some tests to vim-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
lippfi committed Aug 30, 2024
1 parent 6721b2e commit 2edb1e9
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 153 deletions.
Original file line number Diff line number Diff line change
@@ -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()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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" + "<Del>"))

assertState(after)
override fun `test insert delete`() {
super.`test insert delete`()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Original file line number Diff line number Diff line change
@@ -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(),
)
}
}
Loading

0 comments on commit 2edb1e9

Please sign in to comment.