diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/eval/executable_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/eval/reltime_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/ex_cmds/menu_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/options/num_options_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/ui/cursor_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/ui/float_spec.lua | 679 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 9 |
8 files changed, 698 insertions, 20 deletions
diff --git a/test/functional/eval/executable_spec.lua b/test/functional/eval/executable_spec.lua index ca82c8c9da..e346b786a6 100644 --- a/test/functional/eval/executable_spec.lua +++ b/test/functional/eval/executable_spec.lua @@ -21,8 +21,6 @@ describe('executable()', function() -- Windows: siblings are in Nvim's "pseudo-$PATH". local expected = iswin() and 1 or 0 if iswin() then - -- $PATH on AppVeyor CI might be oversized, redefine it to a minimal one. - clear({env={PATH=[[C:\Windows\system32;C:\Windows]]}}) eq('arg1=lemon;arg2=sky;arg3=tree;', call('system', sibling_exe..' lemon sky tree')) end diff --git a/test/functional/eval/reltime_spec.lua b/test/functional/eval/reltime_spec.lua index 0181f09024..ef7a3a148f 100644 --- a/test/functional/eval/reltime_spec.lua +++ b/test/functional/eval/reltime_spec.lua @@ -33,4 +33,14 @@ describe('reltimestr(), reltimefloat()', function() ok(reltimefloat(differs) < 1.0) end) + + it('reltime() allows negative result #10452', function() + local older_time = reltime() + command('sleep 1m') + local newer_time = reltime() + -- Should be something like -0.002123. + local rv = tonumber(reltimestr(reltime(newer_time, older_time))) + ok(rv < 0) + ok(rv > -10) + end) end) diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua index 2309e949c0..0cd32df27c 100644 --- a/test/functional/ex_cmds/menu_spec.lua +++ b/test/functional/ex_cmds/menu_spec.lua @@ -83,7 +83,7 @@ describe('menu_get', function() it("path='', modes='a'", function() local m = funcs.menu_get("","a"); -- HINT: To print the expected table and regenerate the tests: - -- print(require('inspect')(m)) + -- print(require('vim.inspect')(m)) local expected = { { shortcut = "T", diff --git a/test/functional/options/num_options_spec.lua b/test/functional/options/num_options_spec.lua index 88e554c86f..deda5c9118 100644 --- a/test/functional/options/num_options_spec.lua +++ b/test/functional/options/num_options_spec.lua @@ -74,7 +74,7 @@ describe(':set validation', function() should_fail('foldlevel', -5, 'E487') should_fail('foldcolumn', 13, 'E474') should_fail('conceallevel', 4, 'E474') - should_fail('numberwidth', 11, 'E474') + should_fail('numberwidth', 21, 'E474') should_fail('numberwidth', 0, 'E487') -- If smaller than 1 this one is set to 'lines'-1 diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 2c731066bd..591e6340cf 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -261,4 +261,14 @@ describe(':terminal (with fake shell)', function() eq('scripts/shadacat.py', eval('bufname("%")')) end) + it('with bufhidden=delete #3958', function() + command('set hidden') + eq(1, eval('&hidden')) + command('autocmd BufNew * setlocal bufhidden=delete') + for _ = 1, 5 do + source([[ + execute 'edit '.reltimestr(reltime()) + terminal]]) + end + end) end) diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 4dc86f1e1f..6475eb2923 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -216,10 +216,10 @@ describe('ui/cursor', function() if m.blinkwait then m.blinkwait = 700 end end if m.hl_id then - m.hl_id = 50 + m.hl_id = 54 m.attr = {background = Screen.colors.DarkGray} end - if m.id_lm then m.id_lm = 51 end + if m.id_lm then m.id_lm = 55 end end -- Assert the new expectation. diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 41ba542899..68a23db0a2 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -35,6 +35,10 @@ describe('floating windows', function() [15] = {background = Screen.colors.Grey20}, [16] = {background = Screen.colors.Grey20, bold = true, foreground = Screen.colors.Blue1}, [17] = {background = Screen.colors.Yellow}, + [18] = {foreground = Screen.colors.Brown, background = Screen.colors.Grey20}, + [19] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, + [20] = {bold = true, foreground = Screen.colors.Brown}, + [21] = {background = Screen.colors.Gray90}, } it('behavior', function() @@ -168,6 +172,121 @@ describe('floating windows', function() end end) + it('draws correctly with redrawdebug=compositor', function() + -- NB: we do not test that it produces the "correct" debug info + -- (as it is intermediate only, and is allowed to change by internal + -- refactors). Only check that it doesn't cause permanent glitches, + -- or something. + command("set redrawdebug=compositor") + command("set wd=1") + local buf = meths.create_buf(false,false) + local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + local expected_pos = { + [3]={{id=1001}, 'NW', 1, 2, 5, true}, + } + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1: }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + ^ | + {0:~ }| + {0:~ }{1: }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + | + ]]) + end + + + meths.win_set_config(win, {relative='editor', row=0, col=10}) + expected_pos[3][4] = 0 + expected_pos[3][5] = 10 + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1: }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + ^ {1: } | + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + + meths.win_close(win, false) + if multigrid then + screen:expect([[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + end) + it('return their configuration', function() local buf = meths.create_buf(false, false) local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5}) @@ -182,7 +301,7 @@ describe('floating windows', function() end end) - it('defaults to nonumber and NormalFloat highlight', function() + it('defaults to NormalFloat highlight and inherited options', function() command('set number') command('hi NormalFloat guibg=#333333') feed('ix<cr>y<cr><esc>gg') @@ -205,18 +324,18 @@ describe('floating windows', function() {0:~ }| {0:~ }| ## grid 3 - {15:x }| - {15:y }| - {15: }| + {18: 1 }{15:x }| + {18: 2 }{15:y }| + {18: 3 }{15: }| {16:~ }| ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}} else screen:expect([[ {14: 1 }^x | {14: 2 }y | - {14: 3 } {15:x } | - {0:~ }{15:y }{0: }| - {0:~ }{15: }{0: }| + {14: 3 } {18: 1 }{15:x } | + {0:~ }{18: 2 }{15:y }{0: }| + {0:~ }{18: 3 }{15: }{0: }| {0:~ }{16:~ }{0: }| | ]]) @@ -242,7 +361,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| ## grid 3 - {15: }| + {18: 1 }{15: }| {16:~ }| {16:~ }| {16:~ }| @@ -251,7 +370,7 @@ describe('floating windows', function() screen:expect([[ {14: 1 }^x | {14: 2 }y | - {14: 3 } {15: } | + {14: 3 } {18: 1 }{15: } | {0:~ }{16:~ }{0: }| {0:~ }{16:~ }{0: }| {0:~ }{16:~ }{0: }| @@ -260,6 +379,126 @@ describe('floating windows', function() end end) + it("can use 'minimal' style", function() + command('set number') + command('set signcolumn=yes') + command('set cursorline') + command('hi NormalFloat guibg=#333333') + feed('ix<cr>y<cr><esc>gg') + local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + {19: }{20: 1 }{21:^x }| + {19: }{14: 2 }y | + {19: }{14: 3 } | + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {15:x }| + {15:y }| + {15: }| + {15: }| + ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}} + else + screen:expect([[ + {19: }{20: 1 }{21:^x }| + {19: }{14: 2 }y | + {19: }{14: 3 } {15:x } | + {0:~ }{15:y }{0: }| + {0:~ }{15: }{0: }| + {0:~ }{15: }{0: }| + | + ]]) + end + + -- signcolumn=yes still works if there actually are signs + command('sign define piet1 text=𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄ texthl=Search') + command('sign place 1 line=1 name=piet1 buffer=1') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{21:^x }| + {19: }{14: 2 }y | + {19: }{14: 3 } | + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }| + {19: }{15:y }| + {19: }{15: }| + {15: }| + ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}} + + else + screen:expect([[ + {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{21:^x }| + {19: }{14: 2 }y | + {19: }{14: 3 } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } | + {0:~ }{19: }{15:y }{0: }| + {0:~ }{19: }{15: }{0: }| + {0:~ }{15: }{0: }| + | + ]]) + end + command('sign unplace 1 buffer=1') + + local buf = meths.create_buf(false, true) + meths.win_set_buf(win, buf) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + {19: }{20: 1 }{21:^x }| + {19: }{14: 2 }y | + {19: }{14: 3 } | + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {15: }| + {15: }| + {15: }| + {15: }| + ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}} + else + screen:expect([[ + {19: }{20: 1 }{21:^x }| + {19: }{14: 2 }y | + {19: }{14: 3 } {15: } | + {0:~ }{15: }{0: }| + {0:~ }{15: }{0: }| + {0:~ }{15: }{0: }| + | + ]]) + end + end) + it('can have minimum size', function() insert("the background text") local buf = meths.create_buf(false, true) @@ -2539,6 +2778,356 @@ describe('floating windows', function() end) + it("vertical resize + - _", function() + feed('<c-w>w') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + | + ]]) + end + + feed('<c-w>+') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + | + ]]) + end + + feed('<c-w>2-') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + + feed('<c-w>4_') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + {2:~ }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }| + | + ]]) + end + + feed('<c-w>_') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x {1:^y } | + {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }| + | + ]]) + end + end) + + it("horizontal resize > < |", function() + feed('<c-w>w') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + | + ]]) + end + + feed('<c-w>>') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + | + ]]) + end + + feed('<c-w>10<lt>') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + | + ]]) + end + + feed('<c-w>15|') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {0:~ }{1:^y }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + | + ]]) + end + + feed('<c-w>|') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + x | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1:^y }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + x | + {0:~ }| + {1:^y }| + {2:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + end) + it("s :split (non-float)", function() feed("<c-w>s") if multigrid then @@ -3999,6 +4588,78 @@ describe('floating windows', function() ]]) end end) + + it('can overlap doublewidth chars', function() + insert([[ + # TODO: 测试字典信息的准确性 + # FIXME: 测试字典信息的准确性]]) + local buf = meths.create_buf(false,false) + local win = meths.open_win(buf, false, {relative='editor', width=5, height=3, row=0, col=11, style='minimal'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + # TODO: 测试字典信息的准确性 | + # FIXME: 测试字典信息的准确^性 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {1: }| + {1: }| + {1: }| + ]], float_pos={ [3] = { { id = 1001 }, "NW", 1, 0, 11, true } }} + else + screen:expect([[ + # TODO: 测 {1: }信息的准确性 | + # FIXME: 测{1: } 信息的准确^性 | + {0:~ }{1: }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + + meths.win_close(win, false) + if multigrid then + screen:expect([[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + # TODO: 测试字典信息的准确性 | + # FIXME: 测试字典信息的准确^性 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + # TODO: 测试字典信息的准确性 | + # FIXME: 测试字典信息的准确^性 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + end) end describe('with ext_multigrid', function() diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index f1254b68f6..31669f5578 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -81,7 +81,7 @@ local dedent = helpers.dedent local get_session = helpers.get_session local create_callindex = helpers.create_callindex -local inspect = require('inspect') +local inspect = require('vim.inspect') local function isempty(v) return type(v) == 'table' and next(v) == nil @@ -492,7 +492,7 @@ function Screen:_wait(check, flags) end elseif success_seen and #args > 0 then failure_after_success = true - --print(require('inspect')(args)) + -- print(inspect(args)) end return true @@ -576,8 +576,7 @@ end function Screen:_redraw(updates) local did_flush = false for k, update in ipairs(updates) do - -- print('--') - -- print(require('inspect')(update)) + -- print('--', inspect(update)) local method = update[1] for i = 2, #update do local handler_name = '_handle_'..method @@ -1339,7 +1338,7 @@ end function Screen:_pprint_hlstate(item) - --print(require('inspect')(item)) + -- print(inspect(item)) local attrdict = "{"..self:_pprint_attrs(item[1]).."}, " local attrdict2, hlinfo if self._hlstate_cterm then |