diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2021-09-17 09:16:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-17 09:16:40 -0700 |
commit | d8de4eb685e35646c7d541e9a75bdc296127b7e2 (patch) | |
tree | 4bb05ec713856715ac9ba57e5d116eed344511b9 /test/functional/eval/match_functions_spec.lua | |
parent | d56002f7b722facd97b0958e141c8ed2d01495f7 (diff) | |
download | rneovim-d8de4eb685e35646c7d541e9a75bdc296127b7e2.tar.gz rneovim-d8de4eb685e35646c7d541e9a75bdc296127b7e2.tar.bz2 rneovim-d8de4eb685e35646c7d541e9a75bdc296127b7e2.zip |
test: reorg #15698
Problem:
Subdirectories like "visual", "insert", "normal" encourage people to
separate *related* tests for no good reason. Typically the _mode_ is
not the relevant topic of a test (and when it is, _then_ create
an appropriate describe() or it()).
Solution:
- Delete the various `test/functional/<mode>/` subdirectories, move
their tests to more meaningful topics.
- Rename `…/normal/` to `…/editor/`.
- Move or merge `…/visual/*` and `…/insert/*` tests into here where
appropriate.
- Rename `…/eval/` to `…/vimscript/`.
- Move `…/viml/*` into here also.
* test(reorg): insert/* => editor/mode_insert_spec.lua
* test(reorg): cmdline/* => editor/mode_cmdline_spec.lua
* test(reorg): eval core tests => eval_spec.lua
Diffstat (limited to 'test/functional/eval/match_functions_spec.lua')
-rw-r--r-- | test/functional/eval/match_functions_spec.lua | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/test/functional/eval/match_functions_spec.lua b/test/functional/eval/match_functions_spec.lua deleted file mode 100644 index 9f168c913a..0000000000 --- a/test/functional/eval/match_functions_spec.lua +++ /dev/null @@ -1,157 +0,0 @@ -local helpers = require('test.functional.helpers')(after_each) -local Screen = require('test.functional.ui.screen') - -local eq = helpers.eq -local clear = helpers.clear -local funcs = helpers.funcs -local command = helpers.command -local exc_exec = helpers.exc_exec - -before_each(clear) - -describe('setmatches()', function() - it('correctly handles case when both group and pattern entries are numbers', - function() - command('hi def link 1 PreProc') - eq(0, funcs.setmatches({{group=1, pattern=2, id=3, priority=4}})) - eq({{ - group='1', - pattern='2', - id=3, - priority=4, - }}, funcs.getmatches()) - eq(0, funcs.setmatches({{group=1, pattern=2, id=3, priority=4, conceal=5}})) - eq({{ - group='1', - pattern='2', - id=3, - priority=4, - conceal='5', - }}, funcs.getmatches()) - eq(0, funcs.setmatches({{group=1, pos1={2}, pos2={6}, id=3, priority=4, conceal=5}})) - eq({{ - group='1', - pos1={2}, - pos2={6}, - id=3, - priority=4, - conceal='5', - }}, funcs.getmatches()) - end) - - it('does not fail if highlight group is not defined', function() - eq(0, funcs.setmatches{{group=1, pattern=2, id=3, priority=4}}) - eq({{group='1', pattern='2', id=3, priority=4}}, - funcs.getmatches()) - eq(0, funcs.setmatches{{group=1, pos1={2}, pos2={6}, id=3, priority=4, conceal=5}}) - eq({{group='1', pos1={2}, pos2={6}, id=3, priority=4, conceal='5'}}, - funcs.getmatches()) - end) -end) - -describe('matchadd()', function() - it('correctly works when first two arguments and conceal are numbers at once', - function() - command('hi def link 1 PreProc') - eq(4, funcs.matchadd(1, 2, 3, 4, {conceal=5})) - eq({{ - group='1', - pattern='2', - priority=3, - id=4, - conceal='5', - }}, funcs.getmatches()) - end) -end) - -describe('matchaddpos()', function() - it('errors out on invalid input', function() - command('hi clear PreProc') - eq('Vim(let):E5030: Empty list at position 0', - exc_exec('let val = matchaddpos("PreProc", [[]])')) - eq('Vim(let):E5030: Empty list at position 1', - exc_exec('let val = matchaddpos("PreProc", [1, v:_null_list])')) - eq('Vim(let):E5031: List or number required at position 1', - exc_exec('let val = matchaddpos("PreProc", [1, v:_null_dict])')) - end) - it('works with 0 lnum', function() - command('hi clear PreProc') - eq(4, funcs.matchaddpos('PreProc', {1}, 3, 4)) - eq({{ - group='PreProc', - pos1 = {1}, - priority=3, - id=4, - }}, funcs.getmatches()) - funcs.matchdelete(4) - eq(4, funcs.matchaddpos('PreProc', {{0}, 1}, 3, 4)) - eq({{ - group='PreProc', - pos1 = {1}, - priority=3, - id=4, - }}, funcs.getmatches()) - funcs.matchdelete(4) - eq(4, funcs.matchaddpos('PreProc', {0, 1}, 3, 4)) - eq({{ - group='PreProc', - pos1 = {1}, - priority=3, - id=4, - }}, funcs.getmatches()) - end) - it('works with negative numbers', function() - command('hi clear PreProc') - eq(4, funcs.matchaddpos('PreProc', {-10, 1}, 3, 4)) - eq({{ - group='PreProc', - pos1 = {1}, - priority=3, - id=4, - }}, funcs.getmatches()) - funcs.matchdelete(4) - eq(4, funcs.matchaddpos('PreProc', {{-10}, 1}, 3, 4)) - eq({{ - group='PreProc', - pos1 = {1}, - priority=3, - id=4, - }}, funcs.getmatches()) - funcs.matchdelete(4) - eq(4, funcs.matchaddpos('PreProc', {{2, -1}, 1}, 3, 4)) - eq({{ - group='PreProc', - pos1 = {1}, - priority=3, - id=4, - }}, funcs.getmatches()) - funcs.matchdelete(4) - eq(4, funcs.matchaddpos('PreProc', {{2, 0, -1}, 1}, 3, 4)) - eq({{ - group='PreProc', - pos1 = {1}, - priority=3, - id=4, - }}, funcs.getmatches()) - end) - it('works with zero length', function() - local screen = Screen.new(40, 5) - screen:attach() - funcs.setline(1, 'abcdef') - command('hi PreProc guifg=Red') - eq(4, funcs.matchaddpos('PreProc', {{1, 2, 0}}, 3, 4)) - eq({{ - group='PreProc', - pos1 = {1, 2, 0}, - priority=3, - id=4, - }}, funcs.getmatches()) - screen:expect([[ - ^a{1:b}cdef | - {2:~ }| - {2:~ }| - {2:~ }| - | - ]], {[1] = {foreground = Screen.colors.Red}, [2] = {bold = true, foreground = Screen.colors.Blue1}}) - end) -end) |