mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
functests: Fix legacy/063_match_and_matchadd_spec
This commit is contained in:
parent
b3b31e1065
commit
cb57644cb4
@ -5,6 +5,7 @@ local Screen = require('test.functional.ui.screen')
|
|||||||
local feed, insert = helpers.feed, helpers.insert
|
local feed, insert = helpers.feed, helpers.insert
|
||||||
local eval, clear, command = helpers.eval, helpers.clear, helpers.command
|
local eval, clear, command = helpers.eval, helpers.clear, helpers.command
|
||||||
local eq, neq = helpers.eq, helpers.neq
|
local eq, neq = helpers.eq, helpers.neq
|
||||||
|
local redir_exec = helpers.redir_exec
|
||||||
|
|
||||||
describe('063: Test for ":match", "matchadd()" and related functions', function()
|
describe('063: Test for ":match", "matchadd()" and related functions', function()
|
||||||
setup(clear)
|
setup(clear)
|
||||||
@ -61,7 +62,8 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
|
|||||||
|
|
||||||
-- matchdelete throws error and returns -1 on failure
|
-- matchdelete throws error and returns -1 on failure
|
||||||
neq(true, pcall(function() eval('matchdelete(42)') end))
|
neq(true, pcall(function() eval('matchdelete(42)') end))
|
||||||
command("let r2 = matchdelete(42)")
|
eq('\nE803: ID not found: 42',
|
||||||
|
redir_exec("let r2 = matchdelete(42)"))
|
||||||
eq(-1, eval('r2'))
|
eq(-1, eval('r2'))
|
||||||
|
|
||||||
-- Check that "clearmatches()" clears all matches defined by ":match" and
|
-- Check that "clearmatches()" clears all matches defined by ":match" and
|
||||||
@ -98,8 +100,8 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
|
|||||||
-- Check that "setmatches()" will not add two matches with the same ID. The
|
-- 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
|
-- expected behaviour (for now) is to add the first match but not the
|
||||||
-- second and to return -1.
|
-- second and to return -1.
|
||||||
command("let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])")
|
eq('\nE801: ID already taken: 1',
|
||||||
feed("<cr>")
|
redir_exec("let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])"))
|
||||||
eq(-1, eval("r1"))
|
eq(-1, eval("r1"))
|
||||||
eq({{group = 'MyGroup1', pattern = 'TODO', priority = 10, id = 1}}, eval('getmatches()'))
|
eq({{group = 'MyGroup1', pattern = 'TODO', priority = 10, id = 1}}, eval('getmatches()'))
|
||||||
|
|
||||||
@ -109,12 +111,11 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
|
|||||||
eq(0,eval("setmatches([])"))
|
eq(0,eval("setmatches([])"))
|
||||||
eq(0,eval("setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])"))
|
eq(0,eval("setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])"))
|
||||||
command("call clearmatches()")
|
command("call clearmatches()")
|
||||||
command("let rf1 = setmatches(0)")
|
eq('\nE714: List required', redir_exec("let rf1 = setmatches(0)"))
|
||||||
eq(-1, eval('rf1'))
|
eq(-1, eval('rf1'))
|
||||||
command("let rf2 = setmatches([0])")
|
eq('\nE474: Invalid argument', redir_exec("let rf2 = setmatches([0])"))
|
||||||
eq(-1, eval('rf2'))
|
eq(-1, eval('rf2'))
|
||||||
command("let rf3 = setmatches([{'wrong key': 'wrong value'}])")
|
eq('\nE474: Invalid argument', redir_exec("let rf3 = setmatches([{'wrong key': 'wrong value'}])"))
|
||||||
feed("<cr>")
|
|
||||||
eq(-1, eval('rf3'))
|
eq(-1, eval('rf3'))
|
||||||
|
|
||||||
-- Check that "matchaddpos()" positions matches correctly
|
-- Check that "matchaddpos()" positions matches correctly
|
||||||
|
Loading…
Reference in New Issue
Block a user