Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared tests #981

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move some tests to vim-engine
  • Loading branch information
lippfi committed Aug 30, 2024
commit 2edb1e9c82f9c67f96625213efe0e1f19109dbd1
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
Loading