aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/063_match_and_matchadd_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/legacy/063_match_and_matchadd_spec.lua')
-rw-r--r--test/functional/legacy/063_match_and_matchadd_spec.lua90
1 files changed, 45 insertions, 45 deletions
diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua
index 5818bb6b3a..34163d5a55 100644
--- a/test/functional/legacy/063_match_and_matchadd_spec.lua
+++ b/test/functional/legacy/063_match_and_matchadd_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local feed, insert = helpers.feed, helpers.insert
-local eval, clear, execute = helpers.eval, helpers.clear, helpers.execute
+local eval, clear, command = helpers.eval, helpers.clear, helpers.command
local eq, neq = helpers.eq, helpers.neq
describe('063: Test for ":match", "matchadd()" and related functions', function()
@@ -15,12 +15,12 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
-- Check that "matcharg()" returns the correct group and pattern if a match
-- is defined.
- execute("highlight MyGroup1 term=bold ctermbg=red guibg=red")
- execute("highlight MyGroup2 term=italic ctermbg=green guibg=green")
- execute("highlight MyGroup3 term=underline ctermbg=blue guibg=blue")
- execute("match MyGroup1 /TODO/")
- execute("2match MyGroup2 /FIXME/")
- execute("3match MyGroup3 /XXX/")
+ command("highlight MyGroup1 term=bold ctermbg=red guibg=red")
+ command("highlight MyGroup2 term=italic ctermbg=green guibg=green")
+ command("highlight MyGroup3 term=underline ctermbg=blue guibg=blue")
+ command("match MyGroup1 /TODO/")
+ command("2match MyGroup2 /FIXME/")
+ command("3match MyGroup3 /XXX/")
eq({'MyGroup1', 'TODO'}, eval('matcharg(1)'))
eq({'MyGroup2', 'FIXME'}, eval('matcharg(2)'))
eq({'MyGroup3', 'XXX'}, eval('matcharg(3)'))
@@ -31,18 +31,18 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
eq({}, eval('matcharg(4)'))
-- Check that "matcharg()" returns ['', ''] if a match is not defined.
- execute("match")
- execute("2match")
- execute("3match")
+ command("match")
+ command("2match")
+ command("3match")
eq({'', ''}, eval('matcharg(1)'))
eq({'', ''}, eval('matcharg(2)'))
eq({'', ''}, eval('matcharg(3)'))
-- Check that "matchadd()" and "getmatches()" agree on added matches and
-- that default values apply.
- execute("let m1 = matchadd('MyGroup1', 'TODO')")
- execute("let m2 = matchadd('MyGroup2', 'FIXME', 42)")
- execute("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)")
+ command("let m1 = matchadd('MyGroup1', 'TODO')")
+ command("let m2 = matchadd('MyGroup2', 'FIXME', 42)")
+ command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)")
eq({{group = 'MyGroup1', pattern = 'TODO', priority = 10, id = 4},
{group = 'MyGroup2', pattern = 'FIXME', priority = 42, id = 5},
{group = 'MyGroup3', pattern = 'XXX', priority = 60, id = 17}},
@@ -50,55 +50,55 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
-- Check that "matchdelete()" deletes the matches defined in the previous
-- test correctly.
- execute("call matchdelete(m1)")
- execute("call matchdelete(m2)")
- execute("call matchdelete(m3)")
+ command("call matchdelete(m1)")
+ command("call matchdelete(m2)")
+ command("call matchdelete(m3)")
eq({}, eval('getmatches()'))
--- Check that "matchdelete()" returns 0 if successful and otherwise -1.
- execute("let m = matchadd('MyGroup1', 'TODO')")
+ command("let m = matchadd('MyGroup1', 'TODO')")
eq(0, eval('matchdelete(m)'))
-- matchdelete throws error and returns -1 on failure
neq(true, pcall(function() eval('matchdelete(42)') end))
- execute("let r2 = matchdelete(42)")
+ command("let r2 = matchdelete(42)")
eq(-1, eval('r2'))
-- Check that "clearmatches()" clears all matches defined by ":match" and
-- "matchadd()".
- execute("let m1 = matchadd('MyGroup1', 'TODO')")
- execute("let m2 = matchadd('MyGroup2', 'FIXME', 42)")
- execute("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)")
- execute("match MyGroup1 /COFFEE/")
- execute("2match MyGroup2 /HUMPPA/")
- execute("3match MyGroup3 /VIM/")
- execute("call clearmatches()")
+ command("let m1 = matchadd('MyGroup1', 'TODO')")
+ command("let m2 = matchadd('MyGroup2', 'FIXME', 42)")
+ command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)")
+ command("match MyGroup1 /COFFEE/")
+ command("2match MyGroup2 /HUMPPA/")
+ command("3match MyGroup3 /VIM/")
+ command("call clearmatches()")
eq({}, eval('getmatches()'))
-- Check that "setmatches()" restores a list of matches saved by
-- "getmatches()" without changes. (Matches with equal priority must also
-- remain in the same order.)
- execute("let m1 = matchadd('MyGroup1', 'TODO')")
- execute("let m2 = matchadd('MyGroup2', 'FIXME', 42)")
- execute("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)")
- execute("match MyGroup1 /COFFEE/")
- execute("2match MyGroup2 /HUMPPA/")
- execute("3match MyGroup3 /VIM/")
- execute("let ml = getmatches()")
+ command("let m1 = matchadd('MyGroup1', 'TODO')")
+ command("let m2 = matchadd('MyGroup2', 'FIXME', 42)")
+ command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)")
+ command("match MyGroup1 /COFFEE/")
+ command("2match MyGroup2 /HUMPPA/")
+ command("3match MyGroup3 /VIM/")
+ command("let ml = getmatches()")
local ml = eval("ml")
- execute("call clearmatches()")
- execute("call setmatches(ml)")
+ command("call clearmatches()")
+ command("call setmatches(ml)")
eq(ml, eval('getmatches()'))
-- Check that "setmatches()" can correctly restore the matches from matchaddpos()
- execute("call clearmatches()")
- execute("call setmatches(ml)")
+ command("call clearmatches()")
+ command("call setmatches(ml)")
eq(ml, eval('getmatches()'))
-- Check that "setmatches()" will not add two matches with the same ID. The
-- expected behaviour (for now) is to add the first match but not the
-- second and to return -1.
- execute("let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])")
+ command("let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])")
feed("<cr>")
eq(-1, eval("r1"))
eq({{group = 'MyGroup1', pattern = 'TODO', priority = 10, id = 1}}, eval('getmatches()'))
@@ -108,18 +108,18 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
-- return values.)
eq(0,eval("setmatches([])"))
eq(0,eval("setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])"))
- execute("call clearmatches()")
- execute("let rf1 = setmatches(0)")
+ command("call clearmatches()")
+ command("let rf1 = setmatches(0)")
eq(-1, eval('rf1'))
- execute("let rf2 = setmatches([0])")
+ command("let rf2 = setmatches([0])")
eq(-1, eval('rf2'))
- execute("let rf3 = setmatches([{'wrong key': 'wrong value'}])")
+ command("let rf3 = setmatches([{'wrong key': 'wrong value'}])")
feed("<cr>")
eq(-1, eval('rf3'))
-- Check that "matchaddpos()" positions matches correctly
insert('abcdefghijklmnopq')
- execute("call matchaddpos('MyGroup1', [[1, 5], [1, 8, 3]], 10, 3)")
+ command("call matchaddpos('MyGroup1', [[1, 5], [1, 8, 3]], 10, 3)")
screen:expect([[
abcd{1:e}fg{1:hij}klmnop^q |
~ |
@@ -128,9 +128,9 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
|
]], {[1] = {background = Screen.colors.Red}}, {{bold = true, foreground = Screen.colors.Blue}})
- execute("call clearmatches()")
- execute("call setline(1, 'abcdΣabcdef')")
- execute("call matchaddpos('MyGroup1', [[1, 4, 2], [1, 9, 2]])")
+ command("call clearmatches()")
+ command("call setline(1, 'abcdΣabcdef')")
+ command("call matchaddpos('MyGroup1', [[1, 4, 2], [1, 9, 2]])")
screen:expect([[
abc{1:dΣ}ab{1:cd}e^f |
~ |