From 3b558e5d7b8c641896a57c5c4e09d9b8f8535fd5 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 4 Apr 2017 17:47:23 +0200 Subject: tests: short form `screen:except(func)` expects condition only. #6440 - Use this to properly test cursor shape events. - tests: update screen_basic_spec to use `screen:expect` short form. Clearer than using `screen:wait` directy. --- test/functional/ui/screen_basic_spec.lua | 50 +++++++++++--------------------- 1 file changed, 17 insertions(+), 33 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index e511234e5e..21953ba294 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -73,33 +73,29 @@ describe('Screen', function() describe(':suspend', function() it('is forwarded to the UI', function() local function check() - if not screen.suspended then - return 'Screen was not suspended' - end + eq(true, screen.suspended) end execute('suspend') - screen:wait(check) + screen:expect(check) screen.suspended = false feed('') - screen:wait(check) + screen:expect(check) end) end) describe('bell/visual bell', function() it('is forwarded to the UI', function() feed('') - screen:wait(function() - if not screen.bell or screen.visual_bell then - return 'Bell was not sent' - end + screen:expect(function() + eq(true, screen.bell) + eq(false, screen.visual_bell) end) screen.bell = false execute('set visualbell') feed('') - screen:wait(function() - if not screen.visual_bell or screen.bell then - return 'Visual bell was not sent' - end + screen:expect(function() + eq(true, screen.visual_bell) + eq(false, screen.bell) end) end) end) @@ -109,22 +105,16 @@ describe('Screen', function() local expected = 'test-title' execute('set titlestring='..expected) execute('set title') - screen:wait(function() - local actual = screen.title - if actual ~= expected then - return 'Expected title to be "'..expected..'" but was "'..actual..'"' - end + screen:expect(function() + eq(expected, screen.title) end) end) it('has correct default title with unnamed file', function() local expected = '[No Name] - NVIM' execute('set title') - screen:wait(function() - local actual = screen.title - if actual ~= expected then - return 'Expected title to be "'..expected..'" but was "'..actual..'"' - end + screen:expect(function() + eq(expected, screen.title) end) end) @@ -132,11 +122,8 @@ describe('Screen', function() local expected = 'myfile (/mydir) - NVIM' execute('set title') execute('file /mydir/myfile') - screen:wait(function() - local actual = screen.title - if actual ~= expected then - return 'Expected title to be "'..expected..'" but was "'..actual..'"' - end + screen:expect(function() + eq(expected, screen.title) end) end) end) @@ -146,11 +133,8 @@ describe('Screen', function() local expected = 'test-icon' execute('set iconstring='..expected) execute('set icon') - screen:wait(function() - local actual = screen.icon - if actual ~= expected then - return 'Expected title to be "'..expected..'" but was "'..actual..'"' - end + screen:expect(function() + eq(expected, screen.icon) end) end) end) -- cgit From 65fb622000af8e3dbb65480e1581758ecf4ba3e2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 9 Apr 2017 00:12:26 +0300 Subject: functests: Replace execute with either command or feed_command Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed. --- test/functional/ui/screen_basic_spec.lua | 46 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 21953ba294..377923eaa4 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear -local feed, execute = helpers.feed, helpers.execute +local feed, command = helpers.feed, helpers.command local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval @@ -75,7 +75,7 @@ describe('Screen', function() local function check() eq(true, screen.suspended) end - execute('suspend') + command('suspend') screen:expect(check) screen.suspended = false feed('') @@ -91,7 +91,7 @@ describe('Screen', function() eq(false, screen.visual_bell) end) screen.bell = false - execute('set visualbell') + command('set visualbell') feed('') screen:expect(function() eq(true, screen.visual_bell) @@ -103,8 +103,8 @@ describe('Screen', function() describe(':set title', function() it('is forwarded to the UI', function() local expected = 'test-title' - execute('set titlestring='..expected) - execute('set title') + command('set titlestring='..expected) + command('set title') screen:expect(function() eq(expected, screen.title) end) @@ -112,7 +112,7 @@ describe('Screen', function() it('has correct default title with unnamed file', function() local expected = '[No Name] - NVIM' - execute('set title') + command('set title') screen:expect(function() eq(expected, screen.title) end) @@ -120,8 +120,8 @@ describe('Screen', function() it('has correct default title with named file', function() local expected = 'myfile (/mydir) - NVIM' - execute('set title') - execute('file /mydir/myfile') + command('set title') + command('file /mydir/myfile') screen:expect(function() eq(expected, screen.title) end) @@ -131,8 +131,8 @@ describe('Screen', function() describe(':set icon', function() it('is forwarded to the UI', function() local expected = 'test-icon' - execute('set iconstring='..expected) - execute('set icon') + command('set iconstring='..expected) + command('set icon') screen:expect(function() eq(expected, screen.icon) end) @@ -142,7 +142,7 @@ describe('Screen', function() describe('window', function() describe('split', function() it('horizontal', function() - execute('sp') + command('sp') screen:expect([[ ^ | {0:~ }| @@ -162,8 +162,8 @@ describe('Screen', function() end) it('horizontal and resize', function() - execute('sp') - execute('resize 8') + command('sp') + command('resize 8') screen:expect([[ ^ | {0:~ }| @@ -183,7 +183,9 @@ describe('Screen', function() end) it('horizontal and vertical', function() - execute('sp', 'vsp', 'vsp') + command('sp') + command('vsp') + command('vsp') screen:expect([[ ^ {3:|} {3:|} | {0:~ }{3:|}{0:~ }{3:|}{0:~ }| @@ -223,7 +225,9 @@ describe('Screen', function() describe('tabnew', function() it('creates a new buffer', function() - execute('sp', 'vsp', 'vsp') + command('sp') + command('vsp') + command('vsp') insert('hello') screen:expect([[ hell^o {3:|}hello {3:|}hello | @@ -241,7 +245,7 @@ describe('Screen', function() {3:[No Name] [+] }| | ]]) - execute('tabnew') + command('tabnew') insert('hello2') feed('h') screen:expect([[ @@ -260,7 +264,7 @@ describe('Screen', function() {0:~ }| | ]]) - execute('tabprevious') + command('tabprevious') screen:expect([[ {2: }{6:4}{2:+ [No Name] }{4: + [No Name] }{3: }{4:X}| hell^o {3:|}hello {3:|}hello | @@ -305,9 +309,9 @@ describe('Screen', function() describe('normal mode', function() -- https://code.google.com/p/vim/issues/detail?id=339 it("setting 'ruler' doesn't reset the preferred column", function() - execute('set virtualedit=') + command('set virtualedit=') feed('i0123456789kllj') - execute('set ruler') + command('set ruler') feed('k') screen:expect([[ 0123^456 | @@ -388,7 +392,9 @@ describe('Screen', function() split windows ]]) - execute('sp', 'vsp', 'vsp') + command('sp') + command('vsp') + command('vsp') screen:expect([[ and {3:|}and {3:|}and | clearing {3:|}clearing {3:|}clearing | -- cgit From 88ea362c7094cf236a3fd05c5df3231360a5b2b4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 9 Apr 2017 03:02:52 +0300 Subject: functests: Fix ui/screen_basic_spec --- test/functional/ui/screen_basic_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 377923eaa4..8182190b5f 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -157,7 +157,7 @@ describe('Screen', function() {0:~ }| {0:~ }| {3:[No Name] }| - :sp | + | ]]) end) @@ -178,7 +178,7 @@ describe('Screen', function() {0:~ }| {0:~ }| {3:[No Name] }| - :resize 8 | + | ]]) end) @@ -327,7 +327,7 @@ describe('Screen', function() {0:~ }| {0:~ }| {0:~ }| - :set ruler 1,5 All | + 1,5 All | ]]) end) end) -- cgit From 2c5751b9b2b22b8519aeda82088fe4525f2bd713 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Mon, 17 Apr 2017 13:32:22 +0200 Subject: ui: add tests for new cursor shape modes --- test/functional/ui/screen_basic_spec.lua | 113 ------------------------------- 1 file changed, 113 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 8182190b5f..d9cb3d7b6f 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -566,119 +566,6 @@ describe('Screen', function() end) end) - describe('mode change', function() - before_each(function() - screen:try_resize(25, 5) - end) - - it('works in normal mode', function() - screen:expect([[ - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - | - ]],nil,nil,function () - eq("normal", screen.mode) - end) - end) - - it('works in insert mode', function() - feed('i') - screen:expect([[ - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {2:-- INSERT --} | - ]],nil,nil,function () - eq("insert", screen.mode) - end) - - feed('word') - screen:expect([[ - wor^d | - {0:~ }| - {0:~ }| - {0:~ }| - | - ]], nil, nil, function () - eq("normal", screen.mode) - end) - end) - - it('works in replace mode', function() - feed('R') - screen:expect([[ - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {2:-- REPLACE --} | - ]], nil, nil, function () - eq("replace", screen.mode) - end) - - feed('word') - screen:expect([[ - wor^d | - {0:~ }| - {0:~ }| - {0:~ }| - | - ]], nil, nil, function () - eq("normal", screen.mode) - end) - end) - - it('works in cmdline mode', function() - feed(':') - screen:expect([[ - | - {0:~ }| - {0:~ }| - {0:~ }| - :^ | - ]],nil,nil,function () - eq("cmdline", screen.mode) - end) - - feed('/') - screen:expect([[ - | - {0:~ }| - {0:~ }| - {0:~ }| - /^ | - ]],nil,nil,function () - eq("cmdline", screen.mode) - end) - - - feed('?') - screen:expect([[ - | - {0:~ }| - {0:~ }| - {0:~ }| - ?^ | - ]],nil,nil,function () - eq("cmdline", screen.mode) - end) - - feed('') - screen:expect([[ - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - | - ]],nil,nil,function () - eq("normal", screen.mode) - end) - end) - end) - it('nvim_ui_attach() handles very large width/height #2180', function() screen:detach() screen = Screen.new(999, 999) -- cgit From 00843902d3472ac4e74106fc06fa60e599914496 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 25 Apr 2017 02:17:15 +0200 Subject: api/ui: externalize tabline - Work with a bool[] array parallel to the UIWidget enum. - Rename some functions. - Documentation. --- test/functional/ui/screen_basic_spec.lua | 38 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index d9cb3d7b6f..d6aa1aa993 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -6,7 +6,7 @@ local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval -describe('Initial screen', function() +describe('screen', function() local screen local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', @@ -27,7 +27,7 @@ describe('Initial screen', function() screen:detach() end) - it('is the default initial screen', function() + it('default initial screen', function() screen:expect([[ ^ | {0:~ }| @@ -565,12 +565,40 @@ describe('Screen', function() ]]) end) end) +end) - it('nvim_ui_attach() handles very large width/height #2180', function() - screen:detach() - screen = Screen.new(999, 999) +describe('nvim_ui_attach()', function() + before_each(function() + clear() + end) + it('handles very large width/height #2180', function() + local screen = Screen.new(999, 999) screen:attach() eq(999, eval('&lines')) eq(999, eval('&columns')) end) + it('"ui_ext" widgets', function() + local screen = Screen.new() + screen:attach({ui_ext={ + 'cmdline', + 'popupmenu', + 'tabline', + 'wildmenu', + }}) + end) + it('invalid "ui_ext" returns error', function() + local screen = Screen.new() + + local status, rv = pcall(function() screen:attach({ui_ext={'foo'}}) end) + eq(false, status) + eq('ui_ext: unknown widget: foo', rv:match("ui_ext:.*")) + + status, rv = pcall(function() screen:attach({ui_ext={'cmdline','foo'}}) end) + eq(false, status) + eq('ui_ext: unknown widget: foo', rv:match("ui_ext:.*")) + + status, rv = pcall(function() screen:attach({ui_ext={'cmdline',1}}) end) + eq(false, status) + eq('ui_ext: item must be a String', rv:match("ui_ext:.*")) + end) end) -- cgit From c8e1af93de90b2e23579f726fd4aa6a65f9387b6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 25 Apr 2017 10:14:29 +0200 Subject: api: nvim_ui_attach(): Flatten ext_* options. --- test/functional/ui/screen_basic_spec.lua | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index d6aa1aa993..5d89416e4a 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -577,28 +577,10 @@ describe('nvim_ui_attach()', function() eq(999, eval('&lines')) eq(999, eval('&columns')) end) - it('"ui_ext" widgets', function() + it('invalid option returns error', function() local screen = Screen.new() - screen:attach({ui_ext={ - 'cmdline', - 'popupmenu', - 'tabline', - 'wildmenu', - }}) - end) - it('invalid "ui_ext" returns error', function() - local screen = Screen.new() - - local status, rv = pcall(function() screen:attach({ui_ext={'foo'}}) end) - eq(false, status) - eq('ui_ext: unknown widget: foo', rv:match("ui_ext:.*")) - - status, rv = pcall(function() screen:attach({ui_ext={'cmdline','foo'}}) end) - eq(false, status) - eq('ui_ext: unknown widget: foo', rv:match("ui_ext:.*")) - - status, rv = pcall(function() screen:attach({ui_ext={'cmdline',1}}) end) + local status, rv = pcall(function() screen:attach({foo={'foo'}}) end) eq(false, status) - eq('ui_ext: item must be a String', rv:match("ui_ext:.*")) + eq('No such ui option', rv:match("No such .*")) end) end) -- cgit From 04e7eb1e29915c87e3a5b03769d60f429ceb791d Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 9 May 2017 14:31:19 +0300 Subject: tests: Add tests for vim_strchr --- test/functional/ui/screen_basic_spec.lua | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 5d89416e4a..bfcdc7f652 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -565,6 +565,46 @@ describe('Screen', function() ]]) end) end) + + describe('press enter', function() + it('does not crash on at “Press ENTER”', function() + command('nnoremap :echo "TEST"') + feed(':ls') + screen:expect([[ + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + :ls | + 1 %a "[No Name]" line 1 | + {7:Press ENTER or type command to continue}^ | + ]]) + feed('') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + TEST | + ]]) + end) + end) end) describe('nvim_ui_attach()', function() -- cgit From 2b133101cf67b523c2503ef715dfb9ebfa732da2 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius Date: Mon, 18 Sep 2017 21:06:55 +0300 Subject: win: vim_FullName(): force backslashes #7287 - Replace obvious cases of '/' literal with PATHSEP. (There are still some remaining cases that need closer inspection.) - Fixup tests: ui/screen_basic closes #7117 ref https://github.com/neovim/neovim/issues/2471#issuecomment-271193714 --- test/functional/ui/screen_basic_spec.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index bfcdc7f652..9032239b31 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -5,6 +5,7 @@ local feed, command = helpers.feed, helpers.command local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval +local iswin = helpers.iswin describe('screen', function() local screen @@ -120,8 +121,15 @@ describe('Screen', function() it('has correct default title with named file', function() local expected = 'myfile (/mydir) - NVIM' + if iswin() then + expected = 'myfile (C:\\mydir) - NVIM' + end command('set title') - command('file /mydir/myfile') + if iswin() then + command('file C:\\mydir\\myfile') + else + command('file /mydir/myfile') + end screen:expect(function() eq(expected, screen.title) end) -- cgit From 6f7754dfa0c6a9ec2a1e7db3685ffd41b207b882 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Oct 2017 00:24:19 +0200 Subject: test: avoid extra clear() calls also: various other cleanup --- test/functional/ui/screen_basic_spec.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'test/functional/ui/screen_basic_spec.lua') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 9032239b31..b31d9cb32f 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -120,16 +120,10 @@ describe('Screen', function() end) it('has correct default title with named file', function() - local expected = 'myfile (/mydir) - NVIM' - if iswin() then - expected = 'myfile (C:\\mydir) - NVIM' - end + local expected = (iswin() and 'myfile (C:\\mydir) - NVIM' + or 'myfile (/mydir) - NVIM') command('set title') - if iswin() then - command('file C:\\mydir\\myfile') - else - command('file /mydir/myfile') - end + command(iswin() and 'file C:\\mydir\\myfile' or 'file /mydir/myfile') screen:expect(function() eq(expected, screen.title) end) -- cgit