diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-25 15:07:25 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-11-25 15:50:34 +0800 |
commit | ba360a26a294e0ed83ff8e401caabaf4a17c7c30 (patch) | |
tree | ed9b268528cbf11ca4445a4e659e94f639f4c9a6 /test | |
parent | 2738f842f6da712ec0648620d846bfacb14bdcef (diff) | |
download | rneovim-ba360a26a294e0ed83ff8e401caabaf4a17c7c30.tar.gz rneovim-ba360a26a294e0ed83ff8e401caabaf4a17c7c30.tar.bz2 rneovim-ba360a26a294e0ed83ff8e401caabaf4a17c7c30.zip |
vim-patch:8.2.2684: not enough folding code is tested
Problem: Not enough folding code is tested.
Solution: Add more test cases. (Yegappan Lakshmanan, closes vim/vim#8046)
https://github.com/vim/vim/commit/5c504f680e63120fea36becfabb8d939d4449e34
Reorder test_fold.vim to match upstream.
Cherry-pick Test_fold_expr_error() from patch 8.2.0633.
Cherry-pick syntax feature check from patch 8.2.1432.
Cherry-pick a delete() call from patch 8.2.2112.
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/fold_spec.lua (renamed from test/functional/legacy/045_folding_spec.lua) | 103 | ||||
-rw-r--r-- | test/functional/legacy/source_spec.lua | 31 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 50 |
3 files changed, 135 insertions, 49 deletions
diff --git a/test/functional/legacy/045_folding_spec.lua b/test/functional/legacy/fold_spec.lua index 7d7856fd37..a1cfa50880 100644 --- a/test/functional/legacy/045_folding_spec.lua +++ b/test/functional/legacy/fold_spec.lua @@ -4,6 +4,8 @@ local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers')(after_each) local feed, insert, feed_command, expect_any = helpers.feed, helpers.insert, helpers.feed_command, helpers.expect_any +local command = helpers.command +local exec = helpers.exec describe('folding', function() local screen @@ -11,7 +13,13 @@ describe('folding', function() before_each(function() helpers.clear() - screen = Screen.new(20, 8) + screen = Screen.new(45, 8) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, -- Folded + [3] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey}, -- FoldColumn + [4] = {foreground = Screen.colors.Brown}, -- LineNr + }) screen:attach() end) @@ -210,5 +218,96 @@ describe('folding', function() Test fdm=indent and :move bug END line2]]) end) -end) + -- oldtest: Test_folds_with_rnu() + it('with relative line numbers', function() + command('set fdm=marker rnu foldcolumn=2') + command('call setline(1, ["{{{1", "nline 1", "{{{1", "line 2"])') + + screen:expect([[ + {3:+ }{4: 0 }{2:^+-- 2 lines: ·························}| + {3:+ }{4: 1 }{2:+-- 2 lines: ·························}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + feed("j") + screen:expect([[ + {3:+ }{4: 1 }{2:+-- 2 lines: ·························}| + {3:+ }{4: 0 }{2:^+-- 2 lines: ·························}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) + + -- oldtest: Test_foldclose_opt() + it('foldclose=all', function() + exec([[ + set foldmethod=manual foldclose=all foldopen=all + call setline(1, ['one', 'two', 'three', 'four']) + 2,3fold + ]]) + + screen:expect([[ + ^one | + {2:+-- 2 lines: two····························}| + four | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + feed('2G') + screen:expect([[ + one | + ^two | + three | + four | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + feed('4G') + screen:expect([[ + one | + {2:+-- 2 lines: two····························}| + ^four | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + feed('3G') + screen:expect([[ + one | + two | + ^three | + four | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + feed('1G') + screen:expect([[ + ^one | + {2:+-- 2 lines: two····························}| + four | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) +end) diff --git a/test/functional/legacy/source_spec.lua b/test/functional/legacy/source_spec.lua new file mode 100644 index 0000000000..02e6385247 --- /dev/null +++ b/test/functional/legacy/source_spec.lua @@ -0,0 +1,31 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local feed = helpers.feed +local write_file = helpers.write_file + +before_each(clear) + +describe(':source!', function() + it('gives E22 when scripts nested too deep', function() + write_file('Xscript.vim', [[ + :source! Xscript.vim + ]]) + local screen = Screen.new(75, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg + }) + screen:attach() + feed(':source! Xscript.vim\n') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:E22: Scripts nested too deep} | + ]]) + os.remove('Xscript.vim') + end) +end) diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 3c143d87ca..bfa7167100 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -7,7 +7,7 @@ local insert = helpers.insert local expect = helpers.expect local funcs = helpers.funcs local meths = helpers.meths -local source = helpers.source +local exec = helpers.exec local assert_alive = helpers.assert_alive @@ -199,50 +199,6 @@ describe("folded lines", function() end end) - it("highlighting with relative line numbers", function() - command("set relativenumber cursorline cursorlineopt=number foldmethod=marker") - feed_command("set foldcolumn=2") - funcs.setline(1, '{{{1') - funcs.setline(2, 'line 1') - funcs.setline(3, '{{{1') - funcs.setline(4, 'line 2') - feed("j") - if multigrid then - screen:expect([[ - ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [3:---------------------------------------------]| - ## grid 2 - {7:+ }{8: 1 }{5:+-- 2 lines: ·························}| - {7:+ }{9: 0 }{5:^+-- 2 lines: ·························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - :set foldcolumn=2 | - ]]) - else - screen:expect([[ - {7:+ }{8: 1 }{5:+-- 2 lines: ·························}| - {7:+ }{9: 0 }{5:^+-- 2 lines: ·························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :set foldcolumn=2 | - ]]) - end - end) - it("work with spell", function() command("set spell") insert(content1) @@ -1714,7 +1670,7 @@ describe("folded lines", function() end) it('does not crash when foldtext is longer than columns #12988', function() - source([[ + exec([[ function! MyFoldText() abort return repeat('-', &columns + 100) endfunction @@ -1761,7 +1717,7 @@ describe("folded lines", function() it('work correctly with :move #18668', function() screen:try_resize(45, 12) - source([[ + exec([[ set foldmethod=expr foldexpr=indent(v:lnum) let content = ['', '', 'Line1', ' Line2', ' Line3', \ 'Line4', ' Line5', ' Line6', |