mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-22 19:34:04 +02:00
Refactor some moved tests
This commit is contained in:
parent
4453862ea0
commit
ffdd6716f5
src
main/resources/dictionaries
test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions
@ -166,11 +166,14 @@ lmapclear
|
|||||||
cmapclear
|
cmapclear
|
||||||
tmapclear
|
tmapclear
|
||||||
|
|
||||||
|
funcref
|
||||||
|
getcmdtype
|
||||||
getreg
|
getreg
|
||||||
getregtype
|
getregtype
|
||||||
tolower
|
tolower
|
||||||
toupper
|
toupper
|
||||||
|
|
||||||
|
delfunction
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
consectetur
|
consectetur
|
||||||
|
@ -9,48 +9,44 @@
|
|||||||
package org.jetbrains.plugins.ideavim.ex.implementation.functions
|
package org.jetbrains.plugins.ideavim.ex.implementation.functions
|
||||||
|
|
||||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||||
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.TestInfo
|
||||||
|
|
||||||
class GetFunctionTest : VimTestCase() {
|
class GetFunctionTest : VimTestCase() {
|
||||||
|
@BeforeEach
|
||||||
|
override fun setUp(testInfo: TestInfo) {
|
||||||
|
super.setUp(testInfo)
|
||||||
|
configureByText("\n")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test get with dictionary`() {
|
fun `test get with dictionary`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo get({1: 'one', 2: 'two', 3: 'three'}, '2')", "two")
|
||||||
typeText(commandToKeys("echo get({1: 'one', 2: 'two', 3: 'three'}, '2')"))
|
|
||||||
assertExOutput("two")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test get by nonexistent key in dictionary`() {
|
fun `test get by nonexistent key in dictionary`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo get({1: 'one', 2: 'two', 3: 'three'}, '10')", "0")
|
||||||
typeText(commandToKeys("echo get({1: 'one', 2: 'two', 3: 'three'}, '10')"))
|
|
||||||
assertExOutput("0")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test get by nonexistent key in dictionary with default value`() {
|
fun `test get by nonexistent key in dictionary with default value`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo get({1: 'one', 2: 'two', 3: 'three'}, '10', 'null')", "null")
|
||||||
typeText(commandToKeys("echo get({1: 'one', 2: 'two', 3: 'three'}, '10', 'null')"))
|
|
||||||
assertExOutput("null")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test get with list`() {
|
fun `test get with list`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo get(['one', 'two', 'three'], 1)", "two")
|
||||||
typeText(commandToKeys("echo get(['one', 'two', 'three'], 1)"))
|
|
||||||
assertExOutput("two")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test get by nonexistent index in list`() {
|
fun `test get by nonexistent index in list`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo get(['one', 'two', 'three'], 10)", "-1")
|
||||||
typeText(commandToKeys("echo get(['one', 'two', 'three'], 10)"))
|
|
||||||
assertExOutput("-1")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test get by nonexistent index in list with default value`() {
|
fun `test get by nonexistent index in list with default value`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo get(['one', 'two', 'three'], 10, 'null')", "null")
|
||||||
typeText(commandToKeys("echo get(['one', 'two', 'three'], 10, 'null')"))
|
|
||||||
assertExOutput("null")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,20 @@ package org.jetbrains.plugins.ideavim.ex.implementation.functions.commandLineFun
|
|||||||
import com.maddyhome.idea.vim.api.injector
|
import com.maddyhome.idea.vim.api.injector
|
||||||
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel
|
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel
|
||||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||||
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.TestInfo
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
class GetCmdTypeFunctionTest : VimTestCase() {
|
class GetCmdTypeFunctionTest : VimTestCase() {
|
||||||
|
@BeforeEach
|
||||||
|
override fun setUp(testInfo: TestInfo) {
|
||||||
|
super.setUp(testInfo)
|
||||||
|
configureByText("\n")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test getcmdtype() for a regular command`() {
|
fun `test getcmdtype() for a regular command`() {
|
||||||
configureByText("\n")
|
|
||||||
enterCommand("cmap <expr> z getcmdtype()")
|
enterCommand("cmap <expr> z getcmdtype()")
|
||||||
typeText(":fooz")
|
typeText(":fooz")
|
||||||
assertEquals("foo:", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
assertEquals("foo:", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
||||||
@ -26,7 +32,6 @@ class GetCmdTypeFunctionTest : VimTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test getcmdtype() for a forward search`() {
|
fun `test getcmdtype() for a forward search`() {
|
||||||
configureByText("\n")
|
|
||||||
enterCommand("cmap <expr> z getcmdtype()")
|
enterCommand("cmap <expr> z getcmdtype()")
|
||||||
typeText("/fooz")
|
typeText("/fooz")
|
||||||
assertEquals("foo/", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
assertEquals("foo/", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
||||||
@ -34,7 +39,6 @@ class GetCmdTypeFunctionTest : VimTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test getcmdtype() for a backward search`() {
|
fun `test getcmdtype() for a backward search`() {
|
||||||
configureByText("\n")
|
|
||||||
enterCommand("cmap <expr> z getcmdtype()")
|
enterCommand("cmap <expr> z getcmdtype()")
|
||||||
typeText("?fooz")
|
typeText("?fooz")
|
||||||
assertEquals("foo?", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
assertEquals("foo?", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
||||||
@ -42,10 +46,8 @@ class GetCmdTypeFunctionTest : VimTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test getcmdtype() for an expression command`() {
|
fun `test getcmdtype() for an expression command`() {
|
||||||
configureByText("\n")
|
|
||||||
enterCommand("cmap <expr> z getcmdtype()")
|
enterCommand("cmap <expr> z getcmdtype()")
|
||||||
typeText("i<C-r>=fooz")
|
typeText("i<C-r>=fooz")
|
||||||
assertEquals("foo=", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
assertEquals("foo=", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,34 +9,34 @@
|
|||||||
package org.jetbrains.plugins.ideavim.ex.implementation.functions.listFunctions
|
package org.jetbrains.plugins.ideavim.ex.implementation.functions.listFunctions
|
||||||
|
|
||||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||||
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.TestInfo
|
||||||
|
|
||||||
class SplitFunctionTest : VimTestCase() {
|
class SplitFunctionTest : VimTestCase() {
|
||||||
|
@BeforeEach
|
||||||
|
override fun setUp(testInfo: TestInfo) {
|
||||||
|
super.setUp(testInfo)
|
||||||
|
configureByText("\n")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test split with default delimiter`() {
|
fun `test split with default delimiter`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo split('Hello world')", "['Hello', 'world']")
|
||||||
typeText(commandToKeys("echo split('Hello world')"))
|
|
||||||
assertExOutput("['Hello', 'world']")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test split comma separated text`() {
|
fun `test split comma separated text`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo split('a,b,c,d', ',')", "['a', 'b', 'c', 'd']")
|
||||||
typeText(commandToKeys("echo split('a,b,c,d', ',')"))
|
|
||||||
assertExOutput("['a', 'b', 'c', 'd']")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test split comma separated text 2`() {
|
fun `test split comma separated text 2`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo split(',a,b,c,d,', ',')", "['a', 'b', 'c', 'd']")
|
||||||
typeText(commandToKeys("echo split(',a,b,c,d,', ',')"))
|
|
||||||
assertExOutput("['a', 'b', 'c', 'd']")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test split comma separated text with keepempty flag`() {
|
fun `test split comma separated text with keepempty flag`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo split(',a,b,c,,d,', ',', 1)", "['', 'a', 'b', 'c', '', 'd', '']")
|
||||||
typeText(commandToKeys("echo split(',a,b,c,,d,', ',', 1)"))
|
|
||||||
assertExOutput("['', 'a', 'b', 'c', '', 'd', '']")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,58 +9,50 @@
|
|||||||
package org.jetbrains.plugins.ideavim.ex.implementation.functions.stringFunctions
|
package org.jetbrains.plugins.ideavim.ex.implementation.functions.stringFunctions
|
||||||
|
|
||||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||||
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.TestInfo
|
||||||
|
|
||||||
class EscapeFunctionTest : VimTestCase() {
|
class EscapeFunctionTest : VimTestCase() {
|
||||||
|
@BeforeEach
|
||||||
|
override fun setUp(testInfo: TestInfo) {
|
||||||
|
super.setUp(testInfo)
|
||||||
|
configureByText("\n")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test escape windows path with spaces`() {
|
fun `test escape windows path with spaces`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("""echo escape('c:\program files\vim', ' \')""", """c:\\program\ files\\vim""")
|
||||||
typeText(commandToKeys("""echo escape('c:\program files\vim', ' \')"""))
|
|
||||||
assertExOutput("""c:\\program\ files\\vim""")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test escape multiple special characters`() {
|
fun `test escape multiple special characters`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("""echo escape('special chars: #$^', '#$^')""", """special chars: \#\$\^""")
|
||||||
typeText(commandToKeys("""echo escape('special chars: #$^', '#$^')"""))
|
|
||||||
assertExOutput("""special chars: \#\$\^""")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test escape when no escaping needed`() {
|
fun `test escape when no escaping needed`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("""echo escape('no escaping needed', 'xyz')""", "no escaping needed")
|
||||||
typeText(commandToKeys("""echo escape('no escaping needed', 'xyz')"""))
|
|
||||||
assertExOutput("no escaping needed")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test escape empty strings`() {
|
fun `test escape empty strings`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("""echo escape('', '')""", "")
|
||||||
typeText(commandToKeys("""echo escape('', '')"""))
|
|
||||||
assertExOutput("")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test escape consecutive special characters`() {
|
fun `test escape consecutive special characters`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("""echo escape('$$$$', '$')""", """\$\$\$\$""")
|
||||||
typeText(commandToKeys("""echo escape('$$$$', '$')"""))
|
|
||||||
assertExOutput("""\$\$\$\$""")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test escape with double backslashes`() {
|
fun `test escape with double backslashes`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("""echo escape('test\\here', '\\')""", """test\\\\here""")
|
||||||
typeText(commandToKeys("""echo escape('test\\here', '\\')"""))
|
|
||||||
assertExOutput("""test\\\\here""")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test escape with unicode characters`() {
|
fun `test escape with unicode characters`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("""echo escape('Hello 👋 #world', '#')""", """Hello 👋 \#world""")
|
||||||
typeText(commandToKeys("""echo escape('Hello 👋 #world', '#')"""))
|
assertCommandOutput("""echo escape('🎉$🎊$', '$')""", """🎉\$🎊\$""")
|
||||||
assertExOutput("""Hello 👋 \#world""")
|
|
||||||
|
|
||||||
typeText(commandToKeys("""echo escape('🎉$🎊$', '$')"""))
|
|
||||||
assertExOutput("""🎉\$🎊\$""")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,36 +11,36 @@ package org.jetbrains.plugins.ideavim.ex.implementation.functions.variousFunctio
|
|||||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||||
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.TestInfo
|
||||||
|
|
||||||
class HasFunctionTest : VimTestCase() {
|
class HasFunctionTest : VimTestCase() {
|
||||||
|
@BeforeEach
|
||||||
|
override fun setUp(testInfo: TestInfo) {
|
||||||
|
super.setUp(testInfo)
|
||||||
|
configureByText("\n")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test has for supported feature`() {
|
fun `test has for supported feature`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo has('ide')", "1")
|
||||||
typeText(commandToKeys("echo has('ide')"))
|
|
||||||
assertExOutput("1")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test has for unsupported feature`() {
|
fun `test has for unsupported feature`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo has('autocmd')", "0")
|
||||||
typeText(commandToKeys("echo has('autocmd')"))
|
|
||||||
assertExOutput("0")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test has for int as an argument`() {
|
fun `test has for int as an argument`() {
|
||||||
configureByText("\n")
|
assertCommandOutput("echo has(42)", "0")
|
||||||
typeText(commandToKeys("echo has(42)"))
|
|
||||||
assertExOutput("0")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.PLUGIN_ERROR)
|
@TestWithoutNeovim(SkipNeovimReason.PLUGIN_ERROR)
|
||||||
@Test
|
@Test
|
||||||
fun `test has for list as an argument`() {
|
fun `test has for list as an argument`() {
|
||||||
configureByText("\n")
|
enterCommand("echo has([])")
|
||||||
typeText(commandToKeys("echo has([])"))
|
|
||||||
assertPluginError(true)
|
assertPluginError(true)
|
||||||
assertPluginErrorMessageContains("E730: Using a List as a String")
|
assertPluginErrorMessageContains("E730: Using a List as a String")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user