diff --git a/src/main/resources/dictionaries/ideavim.dic b/src/main/resources/dictionaries/ideavim.dic index 207be7447..35af1df6f 100644 --- a/src/main/resources/dictionaries/ideavim.dic +++ b/src/main/resources/dictionaries/ideavim.dic @@ -166,11 +166,14 @@ lmapclear cmapclear tmapclear +funcref +getcmdtype getreg getregtype tolower toupper +delfunction endfunction consectetur diff --git a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/GetFunctionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/GetFunctionTest.kt index 996fa5677..798452639 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/GetFunctionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/GetFunctionTest.kt @@ -9,48 +9,44 @@ package org.jetbrains.plugins.ideavim.ex.implementation.functions import org.jetbrains.plugins.ideavim.VimTestCase +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestInfo class GetFunctionTest : VimTestCase() { + @BeforeEach + override fun setUp(testInfo: TestInfo) { + super.setUp(testInfo) + configureByText("\n") + } + @Test fun `test get with dictionary`() { - configureByText("\n") - typeText(commandToKeys("echo get({1: 'one', 2: 'two', 3: 'three'}, '2')")) - assertExOutput("two") + assertCommandOutput("echo get({1: 'one', 2: 'two', 3: 'three'}, '2')", "two") } @Test fun `test get by nonexistent key in dictionary`() { - configureByText("\n") - typeText(commandToKeys("echo get({1: 'one', 2: 'two', 3: 'three'}, '10')")) - assertExOutput("0") + assertCommandOutput("echo get({1: 'one', 2: 'two', 3: 'three'}, '10')", "0") } @Test fun `test get by nonexistent key in dictionary with default value`() { - configureByText("\n") - typeText(commandToKeys("echo get({1: 'one', 2: 'two', 3: 'three'}, '10', 'null')")) - assertExOutput("null") + assertCommandOutput("echo get({1: 'one', 2: 'two', 3: 'three'}, '10', 'null')", "null") } @Test fun `test get with list`() { - configureByText("\n") - typeText(commandToKeys("echo get(['one', 'two', 'three'], 1)")) - assertExOutput("two") + assertCommandOutput("echo get(['one', 'two', 'three'], 1)", "two") } @Test fun `test get by nonexistent index in list`() { - configureByText("\n") - typeText(commandToKeys("echo get(['one', 'two', 'three'], 10)")) - assertExOutput("-1") + assertCommandOutput("echo get(['one', 'two', 'three'], 10)", "-1") } @Test fun `test get by nonexistent index in list with default value`() { - configureByText("\n") - typeText(commandToKeys("echo get(['one', 'two', 'three'], 10, 'null')")) - assertExOutput("null") + assertCommandOutput("echo get(['one', 'two', 'three'], 10, 'null')", "null") } } diff --git a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/commandLineFunctions/GetCmdTypeFunctionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/commandLineFunctions/GetCmdTypeFunctionTest.kt index 6f03414d1..66f6adafe 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/commandLineFunctions/GetCmdTypeFunctionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/commandLineFunctions/GetCmdTypeFunctionTest.kt @@ -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.ui.ex.ExEntryPanel import org.jetbrains.plugins.ideavim.VimTestCase +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestInfo import kotlin.test.assertEquals class GetCmdTypeFunctionTest : VimTestCase() { + @BeforeEach + override fun setUp(testInfo: TestInfo) { + super.setUp(testInfo) + configureByText("\n") + } @Test fun `test getcmdtype() for a regular command`() { - configureByText("\n") enterCommand("cmap <expr> z getcmdtype()") typeText(":fooz") assertEquals("foo:", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText) @@ -26,7 +32,6 @@ class GetCmdTypeFunctionTest : VimTestCase() { @Test fun `test getcmdtype() for a forward search`() { - configureByText("\n") enterCommand("cmap <expr> z getcmdtype()") typeText("/fooz") assertEquals("foo/", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText) @@ -34,7 +39,6 @@ class GetCmdTypeFunctionTest : VimTestCase() { @Test fun `test getcmdtype() for a backward search`() { - configureByText("\n") enterCommand("cmap <expr> z getcmdtype()") typeText("?fooz") assertEquals("foo?", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText) @@ -42,10 +46,8 @@ class GetCmdTypeFunctionTest : VimTestCase() { @Test fun `test getcmdtype() for an expression command`() { - configureByText("\n") enterCommand("cmap <expr> z getcmdtype()") typeText("i<C-r>=fooz") assertEquals("foo=", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText) } - } diff --git a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/listFunctions/SplitFunctionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/listFunctions/SplitFunctionTest.kt index 23ca20e86..7e1777a49 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/listFunctions/SplitFunctionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/listFunctions/SplitFunctionTest.kt @@ -9,34 +9,34 @@ package org.jetbrains.plugins.ideavim.ex.implementation.functions.listFunctions import org.jetbrains.plugins.ideavim.VimTestCase +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestInfo class SplitFunctionTest : VimTestCase() { + @BeforeEach + override fun setUp(testInfo: TestInfo) { + super.setUp(testInfo) + configureByText("\n") + } + @Test fun `test split with default delimiter`() { - configureByText("\n") - typeText(commandToKeys("echo split('Hello world')")) - assertExOutput("['Hello', 'world']") + assertCommandOutput("echo split('Hello world')", "['Hello', 'world']") } @Test fun `test split comma separated text`() { - configureByText("\n") - typeText(commandToKeys("echo split('a,b,c,d', ',')")) - assertExOutput("['a', 'b', 'c', 'd']") + assertCommandOutput("echo split('a,b,c,d', ',')", "['a', 'b', 'c', 'd']") } @Test fun `test split comma separated text 2`() { - configureByText("\n") - typeText(commandToKeys("echo split(',a,b,c,d,', ',')")) - assertExOutput("['a', 'b', 'c', 'd']") + assertCommandOutput("echo split(',a,b,c,d,', ',')", "['a', 'b', 'c', 'd']") } @Test fun `test split comma separated text with keepempty flag`() { - configureByText("\n") - typeText(commandToKeys("echo split(',a,b,c,,d,', ',', 1)")) - assertExOutput("['', 'a', 'b', 'c', '', 'd', '']") + assertCommandOutput("echo split(',a,b,c,,d,', ',', 1)", "['', 'a', 'b', 'c', '', 'd', '']") } } diff --git a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/stringFunctions/EscapeFunctionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/stringFunctions/EscapeFunctionTest.kt index bf083bcef..aada70418 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/stringFunctions/EscapeFunctionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/stringFunctions/EscapeFunctionTest.kt @@ -9,58 +9,50 @@ package org.jetbrains.plugins.ideavim.ex.implementation.functions.stringFunctions import org.jetbrains.plugins.ideavim.VimTestCase +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestInfo class EscapeFunctionTest : VimTestCase() { + @BeforeEach + override fun setUp(testInfo: TestInfo) { + super.setUp(testInfo) + configureByText("\n") + } + @Test fun `test escape windows path with spaces`() { - configureByText("\n") - typeText(commandToKeys("""echo escape('c:\program files\vim', ' \')""")) - assertExOutput("""c:\\program\ files\\vim""") + assertCommandOutput("""echo escape('c:\program files\vim', ' \')""", """c:\\program\ files\\vim""") } @Test fun `test escape multiple special characters`() { - configureByText("\n") - typeText(commandToKeys("""echo escape('special chars: #$^', '#$^')""")) - assertExOutput("""special chars: \#\$\^""") + assertCommandOutput("""echo escape('special chars: #$^', '#$^')""", """special chars: \#\$\^""") } @Test fun `test escape when no escaping needed`() { - configureByText("\n") - typeText(commandToKeys("""echo escape('no escaping needed', 'xyz')""")) - assertExOutput("no escaping needed") + assertCommandOutput("""echo escape('no escaping needed', 'xyz')""", "no escaping needed") } @Test fun `test escape empty strings`() { - configureByText("\n") - typeText(commandToKeys("""echo escape('', '')""")) - assertExOutput("") + assertCommandOutput("""echo escape('', '')""", "") } @Test fun `test escape consecutive special characters`() { - configureByText("\n") - typeText(commandToKeys("""echo escape('$$$$', '$')""")) - assertExOutput("""\$\$\$\$""") + assertCommandOutput("""echo escape('$$$$', '$')""", """\$\$\$\$""") } @Test fun `test escape with double backslashes`() { - configureByText("\n") - typeText(commandToKeys("""echo escape('test\\here', '\\')""")) - assertExOutput("""test\\\\here""") + assertCommandOutput("""echo escape('test\\here', '\\')""", """test\\\\here""") } @Test fun `test escape with unicode characters`() { - configureByText("\n") - typeText(commandToKeys("""echo escape('Hello 👋 #world', '#')""")) - assertExOutput("""Hello 👋 \#world""") - - typeText(commandToKeys("""echo escape('🎉$🎊$', '$')""")) - assertExOutput("""🎉\$🎊\$""") + assertCommandOutput("""echo escape('Hello 👋 #world', '#')""", """Hello 👋 \#world""") + assertCommandOutput("""echo escape('🎉$🎊$', '$')""", """🎉\$🎊\$""") } } diff --git a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/variousFunctions/HasFunctionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/variousFunctions/HasFunctionTest.kt index 29962f3b1..d72d90fd8 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/variousFunctions/HasFunctionTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/variousFunctions/HasFunctionTest.kt @@ -11,36 +11,36 @@ package org.jetbrains.plugins.ideavim.ex.implementation.functions.variousFunctio import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.VimTestCase +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestInfo class HasFunctionTest : VimTestCase() { + @BeforeEach + override fun setUp(testInfo: TestInfo) { + super.setUp(testInfo) + configureByText("\n") + } @Test fun `test has for supported feature`() { - configureByText("\n") - typeText(commandToKeys("echo has('ide')")) - assertExOutput("1") + assertCommandOutput("echo has('ide')", "1") } @Test fun `test has for unsupported feature`() { - configureByText("\n") - typeText(commandToKeys("echo has('autocmd')")) - assertExOutput("0") + assertCommandOutput("echo has('autocmd')", "0") } @Test fun `test has for int as an argument`() { - configureByText("\n") - typeText(commandToKeys("echo has(42)")) - assertExOutput("0") + assertCommandOutput("echo has(42)", "0") } @TestWithoutNeovim(SkipNeovimReason.PLUGIN_ERROR) @Test fun `test has for list as an argument`() { - configureByText("\n") - typeText(commandToKeys("echo has([])")) + enterCommand("echo has([])") assertPluginError(true) assertPluginErrorMessageContains("E730: Using a List as a String") }