diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/extmark_spec.lua | 54 | ||||
-rw-r--r-- | test/functional/legacy/memory_usage_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 25 | ||||
-rw-r--r-- | test/functional/shada/history_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/terminal/buffer_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/diff_spec.lua | 77 | ||||
-rw-r--r-- | test/functional/ui/spell_spec.lua | 31 | ||||
-rw-r--r-- | test/unit/os/env_spec.lua | 2 |
9 files changed, 165 insertions, 57 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 5bf3fa554f..9ea35e50a2 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -204,13 +204,13 @@ describe('API/extmarks', function() eq({marks[2], positions[2][1], positions[2][2]}, rv[2]) -- nextrange with `limit` rv = get_extmarks(ns, marks[1], marks[3], {limit=2}) - eq(2, table.getn(rv)) + eq(2, #rv) -- nextrange with positional when mark exists at position rv = get_extmarks(ns, positions[1], positions[3]) eq({marks[1], positions[1][1], positions[1][2]}, rv[1]) eq({marks[2], positions[2][1], positions[2][2]}, rv[2]) rv = get_extmarks(ns, positions[2], positions[3]) - eq(2, table.getn(rv)) + eq(2, #rv) -- nextrange with positional index (no mark at position) local lower = {positions[1][1], positions[2][2] -1} local upper = {positions[2][1], positions[3][2] - 1} @@ -248,14 +248,14 @@ describe('API/extmarks', function() eq({marks[1], positions[1][1], positions[1][2]}, rv[3]) -- prevrange with limit rv = get_extmarks(ns, marks[3], marks[1], {limit=2}) - eq(2, table.getn(rv)) + eq(2, #rv) -- prevrange with positional when mark exists at position rv = get_extmarks(ns, positions[3], positions[1]) eq({{marks[3], positions[3][1], positions[3][2]}, {marks[2], positions[2][1], positions[2][2]}, {marks[1], positions[1][1], positions[1][2]}}, rv) rv = get_extmarks(ns, positions[2], positions[1]) - eq(2, table.getn(rv)) + eq(2, #rv) -- prevrange with positional index (no mark at position) lower = {positions[2][1], positions[2][2] + 1} upper = {positions[3][1], positions[3][2] + 1} @@ -282,19 +282,19 @@ describe('API/extmarks', function() end local rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=2}) - eq(2, table.getn(rv)) + eq(2, #rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=3}) - eq(3, table.getn(rv)) + eq(3, #rv) -- now in reverse rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=2}) - eq(2, table.getn(rv)) + eq(2, #rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}, {limit=3}) - eq(3, table.getn(rv)) + eq(3, #rv) end) it('get_marks works when mark col > upper col', function() @@ -798,17 +798,17 @@ describe('API/extmarks', function() feed("u") local rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(3, table.getn(rv)) + eq(3, #rv) feed("<c-r>") rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(3, table.getn(rv)) + eq(3, #rv) -- Test updates feed('o<esc>') set_extmark(ns, marks[1], positions[1][1], positions[1][2]) rv = get_extmarks(ns, marks[1], marks[1], {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) feed("u") feed("<c-r>") -- old value is NOT kept in history @@ -820,10 +820,10 @@ describe('API/extmarks', function() feed("u") rv = get_extmarks(ns, {0, 0}, {-1, -1}) -- undo does NOT restore deleted marks - eq(2, table.getn(rv)) + eq(2, #rv) feed("<c-r>") rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(2, table.getn(rv)) + eq(2, #rv) end) it('undo and redo of marks deleted during edits', function() @@ -840,9 +840,9 @@ describe('API/extmarks', function() rv = set_extmark(ns2, marks[1], positions[1][1], positions[1][2]) eq(1, rv) rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns2, {0, 0}, {-1, -1}) - eq(1, table.getn(rv)) + eq(1, #rv) -- Set more marks for testing the ranges set_extmark(ns, marks[2], positions[2][1], positions[2][2]) @@ -852,32 +852,32 @@ describe('API/extmarks', function() -- get_next (limit set) rv = get_extmarks(ns, {0, 0}, positions[2], {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns2, {0, 0}, positions[2], {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) -- get_prev (limit set) rv = get_extmarks(ns, positions[1], {0, 0}, {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) rv = get_extmarks(ns2, positions[1], {0, 0}, {limit=1}) - eq(1, table.getn(rv)) + eq(1, #rv) -- get_next (no limit) rv = get_extmarks(ns, positions[1], positions[2]) - eq(2, table.getn(rv)) + eq(2, #rv) rv = get_extmarks(ns2, positions[1], positions[2]) - eq(2, table.getn(rv)) + eq(2, #rv) -- get_prev (no limit) rv = get_extmarks(ns, positions[2], positions[1]) - eq(2, table.getn(rv)) + eq(2, #rv) rv = get_extmarks(ns2, positions[2], positions[1]) - eq(2, table.getn(rv)) + eq(2, #rv) curbufmeths.del_extmark(ns, marks[1]) rv = get_extmarks(ns, {0, 0}, {-1, -1}) - eq(2, table.getn(rv)) + eq(2, #rv) curbufmeths.del_extmark(ns2, marks[1]) rv = get_extmarks(ns2, {0, 0}, {-1, -1}) - eq(2, table.getn(rv)) + eq(2, #rv) end) it('mark set can create unique identifiers', function() diff --git a/test/functional/legacy/memory_usage_spec.lua b/test/functional/legacy/memory_usage_spec.lua index 28ca749749..251e6a5ea4 100644 --- a/test/functional/legacy/memory_usage_spec.lua +++ b/test/functional/legacy/memory_usage_spec.lua @@ -7,6 +7,9 @@ local iswin = helpers.iswin local retry = helpers.retry local ok = helpers.ok local source = helpers.source +local wait = helpers.wait +local uname = helpers.uname +local load_adjust = helpers.load_adjust local monitor_memory_usage = { memory_usage = function(self) @@ -99,6 +102,7 @@ describe('memory usage', function() call s:f(0) endfor ]]) + wait() local after = monitor_memory_usage(pid) -- Estimate the limit of max usage as 2x initial usage. -- The lower limit can fluctuate a bit, use 97%. @@ -143,16 +147,20 @@ describe('memory usage', function() call s:f() endfor ]]) + wait() local after = monitor_memory_usage(pid) for _ = 1, 3 do feed_command('so '..fname) + wait() end local last = monitor_memory_usage(pid) -- The usage may be a bit less than the last value, use 80%. -- Allow for 20% tolerance at the upper limit. That's very permissive, but - -- otherwise the test fails sometimes. + -- otherwise the test fails sometimes. On Sourcehut CI with FreeBSD we need to + -- be even more permissive. + local upper_multiplier = uname() == 'freebsd' and 15 or 12 local lower = before.last * 8 / 10 - local upper = (after.max + (after.last - before.last)) * 12 / 10 + local upper = load_adjust((after.max + (after.last - before.last)) * upper_multiplier / 10) check_result({before=before, after=after, last=last}, pcall(ok, lower < last.last)) check_result({before=before, after=after, last=last}, diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index aaa28390ea..1002011999 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -815,33 +815,10 @@ describe('LSP', function() 'å å ɧ 汉语 ↥ 🤦 🦄'; }, buf_lines(1)) end) - it('handles edits with the same start position, applying changes in the order in the array', function() - local edits = { - make_edit(0, 6, 0, 10, {""}); - make_edit(0, 6, 0, 6, {"REPLACE"}); - make_edit(1, 0, 1, 3, {""}); - make_edit(1, 0, 1, 0, {"123"}); - make_edit(2, 16, 2, 18, {""}); - make_edit(2, 16, 2, 16, {"XYZ"}); - make_edit(3, 7, 3, 11, {"this"}); - make_edit(3, 7, 3, 11, {"will"}); - make_edit(3, 7, 3, 11, {"not "}); - make_edit(3, 7, 3, 11, {"show"}); - make_edit(3, 7, 3, 11, {"(but this will)"}); - } - exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1) - eq({ - 'First REPLACE of text'; - '123ond line of text'; - 'Third line of teXYZ'; - 'Fourth (but this will) of text'; - 'å å ɧ 汉语 ↥ 🤦 🦄'; - }, buf_lines(1)) - end) it('applies complex edits', function() local edits = { - make_edit(0, 0, 0, 0, {"3", "foo"}); make_edit(0, 0, 0, 0, {"", "12"}); + make_edit(0, 0, 0, 0, {"3", "foo"}); make_edit(0, 1, 0, 1, {"bar", "123"}); make_edit(0, #"First ", 0, #"First line of text", {"guy"}); make_edit(1, 0, 1, #'Second', {"baz"}); diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua index 78b5c77857..9291f5e100 100644 --- a/test/functional/shada/history_spec.lua +++ b/test/functional/shada/history_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local nvim_command, funcs, meths, nvim_feed, eq = helpers.command, helpers.funcs, helpers.meths, helpers.feed, helpers.eq +local eval = helpers.eval local shada_helpers = require('test.functional.shada.helpers') local reset, clear = shada_helpers.reset, shada_helpers.clear @@ -237,4 +238,13 @@ describe('ShaDa support code', function() nvim_command('wshada') end) + it('does not crash when number of history save to zero (#11497)', function() + nvim_command('set shada=\'10') + nvim_feed(':" Test\n') + nvim_command('wshada') + nvim_command('set shada=\'10,:0') + nvim_command('wshada') + eq(2, eval('1+1')) -- check nvim still running + end) + end) diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index f79aceaddf..6372cd935e 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -276,3 +276,12 @@ describe('No heap-buffer-overflow when using', function() feed_command('bdelete!') end) end) + +describe('No heap-buffer-overflow when', function() + it('set nowrap and send long line #11548', function() + feed_command('set nowrap') + feed_command('autocmd TermOpen * startinsert') + feed_command('call feedkeys("4000ai\\<esc>:terminal!\\<cr>")') + eq(2, eval('1+1')) + end) +end) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 5d82037f42..c0578c08e1 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -605,6 +605,8 @@ describe('TUI', function() wait_for_mode('i') -- "bracketed paste" feed_data('\027[200~'..expected..'\027[201~') + -- FIXME: Data race between the two feeds + if uname() == 'freebsd' then screen:sleep(1) end feed_data(' end') expected = expected..' end' screen:expect([[ diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index 252991aca7..69b6ab8cf0 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -6,6 +6,7 @@ local clear = helpers.clear local command = helpers.command local insert = helpers.insert local write_file = helpers.write_file +local source = helpers.source describe('Diff mode screen', function() local fname = 'Xtest-functional-diff-screen-1' @@ -1031,3 +1032,79 @@ it('win_update redraws lines properly', function() | ]]} end) + +it('diff updates line numbers below filler lines', function() + clear() + local screen = Screen.new(40, 14) + screen:attach() + screen:set_default_attr_ids({ + [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, + [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, + [3] = {reverse = true}, + [4] = {background = Screen.colors.LightBlue}, + [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, + [6] = {bold = true, foreground = Screen.colors.Blue1}, + [7] = {bold = true, reverse = true}, + [8] = {bold = true, background = Screen.colors.Red}, + [9] = {background = Screen.colors.LightMagenta}, + [10] = {bold = true, foreground = Screen.colors.Brown}, + [11] = {foreground = Screen.colors.Brown}, + }) + source([[ + call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b']) + vnew + call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b']) + windo diffthis + setlocal number rnu foldcolumn=0 + ]]) + screen:expect([[ + {1: }a {3:│}{10:1 }^a | + {1: }a {3:│}{11: 1 }a | + {1: }a {3:│}{11: 2 }a | + {1: }{8:x}{9: }{3:│}{11: 3 }{8:y}{9: }| + {1: }{4:x }{3:│}{11: }{2:----------------}| + {1: }{4:x }{3:│}{11: }{2:----------------}| + {1: }b {3:│}{11: 4 }b | + {1: }b {3:│}{11: 5 }b | + {1: }b {3:│}{11: 6 }b | + {1: }b {3:│}{11: 7 }b | + {1: }b {3:│}{11: 8 }b | + {6:~ }{3:│}{6:~ }| + {3:[No Name] [+] }{7:[No Name] [+] }| + | + ]]) + feed('j') + screen:expect([[ + {1: }a {3:│}{11: 1 }a | + {1: }a {3:│}{10:2 }^a | + {1: }a {3:│}{11: 1 }a | + {1: }{8:x}{9: }{3:│}{11: 2 }{8:y}{9: }| + {1: }{4:x }{3:│}{11: }{2:----------------}| + {1: }{4:x }{3:│}{11: }{2:----------------}| + {1: }b {3:│}{11: 3 }b | + {1: }b {3:│}{11: 4 }b | + {1: }b {3:│}{11: 5 }b | + {1: }b {3:│}{11: 6 }b | + {1: }b {3:│}{11: 7 }b | + {6:~ }{3:│}{6:~ }| + {3:[No Name] [+] }{7:[No Name] [+] }| + | + ]]) + feed('j') + screen:expect([[ + {1: }a {3:│}{11: 2 }a | + {1: }a {3:│}{11: 1 }a | + {1: }a {3:│}{10:3 }^a | + {1: }{8:x}{9: }{3:│}{11: 1 }{8:y}{9: }| + {1: }{4:x }{3:│}{11: }{2:----------------}| + {1: }{4:x }{3:│}{11: }{2:----------------}| + {1: }b {3:│}{11: 2 }b | + {1: }b {3:│}{11: 3 }b | + {1: }b {3:│}{11: 4 }b | + {1: }b {3:│}{11: 5 }b | + {1: }b {3:│}{11: 6 }b | + {6:~ }{3:│}{6:~ }| + {3:[No Name] [+] }{7:[No Name] [+] }| + | + ]]) +end) diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 243b737583..2c6e586665 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -4,8 +4,9 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local feed = helpers.feed -local feed_command = helpers.feed_command local insert = helpers.insert +local uname = helpers.uname +local command = helpers.command describe("'spell'", function() local screen @@ -16,12 +17,14 @@ describe("'spell'", function() screen:attach() screen:set_default_attr_ids( { [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {special = Screen.colors.Red, undercurl = true} + [1] = {special = Screen.colors.Red, undercurl = true}, + [2] = {special = Screen.colors.Blue1, undercurl = true}, }) end) it('joins long lines #7937', function() - feed_command('set spell') + if uname() == 'openbsd' then pending('FIXME #12104', function() end) return end + command('set spell') insert([[ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, @@ -42,4 +45,26 @@ describe("'spell'", function() | ]]) end) + + it('has correct highlight at start of line', function() + insert([[ + "This is some text without any spell errors. Everything", + "should just be black, nothing wrong here.", + "", + "This line has a sepll error. and missing caps.", + "And and this is the the duplication.", + "with missing caps here.", + ]]) + command('set spell spelllang=en_nz') + screen:expect([[ + "This is some text without any spell errors. Everything", | + "should just be black, nothing wrong here.", | + "", | + "This line has a {1:sepll} error. {2:and} missing caps.", | + "{1:And and} this is {1:the the} duplication.", | + "with missing caps here.", | + ^ | + | + ]]) + end) end) diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua index e24a389d69..ad05b134e0 100644 --- a/test/unit/os/env_spec.lua +++ b/test/unit/os/env_spec.lua @@ -172,7 +172,7 @@ describe('env.c', function() i = i + 1 name = cimp.os_getenvname_at_index(i) end - eq(true, (table.getn(names)) > 0) + eq(true, #names > 0) eq(true, found_name) end) |