diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/README.md | 53 | ||||
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 18 | ||||
-rw-r--r-- | test/functional/eval/json_functions_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/eval/server_spec.lua | 38 | ||||
-rw-r--r-- | test/functional/ui/inccommand_spec.lua | 868 | ||||
-rw-r--r-- | test/functional/ui/tabline_spec.lua | 57 | ||||
-rw-r--r-- | test/functional/ui/wildmode_spec.lua | 97 | ||||
-rw-r--r-- | test/functional/viml/completion_spec.lua | 2 |
8 files changed, 1014 insertions, 126 deletions
diff --git a/test/README.md b/test/README.md index 15041b74e8..a76cfc5235 100644 --- a/test/README.md +++ b/test/README.md @@ -1,31 +1,48 @@ -# Tests +Tests +===== Tests are run by `/cmake/RunTests.cmake` file, using busted. For some failures, `.nvimlog` (or `$NVIM_LOG_FILE`) may provide insight. -## Directory structure +Lint +---- -Directories with tests: `/test/benchmark` for benchmarks, `/test/functional` for -functional tests, `/test/unit` for unit tests. `/test/config` contains `*.in` -files (currently a single one) which are transformed into `*.lua` files using -`configure_file` CMake command: this is for acessing CMake variables in lua -tests. `/test/includes` contains include files for use by luajit `ffi.cdef` -C definitions parser: normally used to make macros not accessible via this -mechanism accessible the other way. +`make lint` (and `make testlint`) runs [luacheck](https://github.com/mpeterv/luacheck) +on the test code. -Files `/test/*/preload.lua` contain modules which will be preloaded by busted, -via `--helper` option. `/test/**/helpers.lua` contain various “library” -functions, (intended to be) used by a number of tests and not just a single one. +If a luacheck warning must be ignored, specify the warning code. Example: -`/test/*/**/*_spec.lua` are files containing actual tests. Files that do not end -with a `_spec.lua` are libraries like `/test/**/helpers.lua`, except that they -have some common topic. + -- luacheck: ignore 621 -Tests inside `/test/unit` and `/test/functional` are normally divided into -groups by the semantic component they are testing. +http://luacheck.readthedocs.io/en/stable/warnings.html -## Environment variables +Ignore the smallest applicable scope (e.g. inside a function, not at the top of +the file). + +Layout +------ + +- `/test/benchmark` : benchmarks +- `/test/functional` : functional tests +- `/test/unit` : unit tests +- `/test/config` : contains `*.in` files which are transformed into `*.lua` + files using `configure_file` CMake command: this is for acessing CMake + variables in lua tests. +- `/test/includes` : include-files for use by luajit `ffi.cdef` C definitions + parser: normally used to make macros not accessible via this mechanism + accessible the other way. +- `/test/*/preload.lua` : modules preloaded by busted `--helper` option +- `/test/**/helpers.lua` : common utility functions for test code +- `/test/*/**/*_spec.lua` : actual tests. Files that do not end with + `_spec.lua` are libraries like `/test/**/helpers.lua`, except that they have + some common topic. + +Tests in `/test/unit` and `/test/functional` are normally divided into groups +by the semantic component they are testing. + +Environment variables +--------------------- Test behaviour is affected by environment variables. Currently supported (Functional, Unit, Benchmarks) (when Defined; when set to _1_; when defined, diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 4380e52b8b..a2a198ca83 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -304,14 +304,30 @@ describe('server -> client', function() connect_test(server, 'pipe', address) end) - it('via ip address', function() + it('via ipv4 address', function() local server = spawn(nvim_argv) set_session(server) local address = funcs.serverstart("127.0.0.1:") + if #address == 0 then + pending('no ipv4 stack', function() end) + return + end eq('127.0.0.1:', string.sub(address,1,10)) connect_test(server, 'tcp', address) end) + it('via ipv6 address', function() + local server = spawn(nvim_argv) + set_session(server) + local address = funcs.serverstart('::1:') + if #address == 0 then + pending('no ipv6 stack', function() end) + return + end + eq('::1:', string.sub(address,1,4)) + connect_test(server, 'tcp', address) + end) + it('via hostname', function() local server = spawn(nvim_argv) set_session(server) diff --git a/test/functional/eval/json_functions_spec.lua b/test/functional/eval/json_functions_spec.lua index 4d34cde849..8dcaea806e 100644 --- a/test/functional/eval/json_functions_spec.lua +++ b/test/functional/eval/json_functions_spec.lua @@ -776,4 +776,11 @@ describe('json_encode() function', function() it('can dump NULL dictionary', function() eq('{}', eval('json_encode(v:_null_dict)')) end) + + it('fails to parse NULL strings and lists', function() + eq('Vim(call):E474: Attempt to decode a blank string', + exc_exec('call json_decode($XXX_UNEXISTENT_VAR_XXX)')) + eq('Vim(call):E474: Attempt to decode a blank string', + exc_exec('call json_decode(v:_null_list)')) + end) end) diff --git a/test/functional/eval/server_spec.lua b/test/functional/eval/server_spec.lua index 115114c3c3..393616838e 100644 --- a/test/functional/eval/server_spec.lua +++ b/test/functional/eval/server_spec.lua @@ -63,23 +63,33 @@ describe('serverstart(), serverstop()', function() eq({}, funcs.serverlist()) local s = funcs.serverstart('127.0.0.1:0') -- assign random port - assert(string.match(s, '127.0.0.1:%d+')) - eq(s, funcs.serverlist()[1]) - clear_serverlist() + if #s > 0 then + assert(string.match(s, '127.0.0.1:%d+')) + eq(s, funcs.serverlist()[1]) + clear_serverlist() + end s = funcs.serverstart('127.0.0.1:') -- assign random port - assert(string.match(s, '127.0.0.1:%d+')) - eq(s, funcs.serverlist()[1]) - clear_serverlist() + if #s > 0 then + assert(string.match(s, '127.0.0.1:%d+')) + eq(s, funcs.serverlist()[1]) + clear_serverlist() + end - funcs.serverstart('127.0.0.1:12345') - funcs.serverstart('127.0.0.1:12345') -- exists already; ignore - funcs.serverstart('::1:12345') - funcs.serverstart('::1:12345') -- exists already; ignore - local expected = { - '127.0.0.1:12345', - '::1:12345', - } + local expected = {} + local v4 = '127.0.0.1:12345' + s = funcs.serverstart(v4) + if #s > 0 then + table.insert(expected, v4) + funcs.serverstart(v4) -- exists already; ignore + end + + local v6 = '::1:12345' + s = funcs.serverstart(v6) + if #s > 0 then + table.insert(expected, v6) + funcs.serverstart(v6) -- exists already; ignore + end eq(expected, funcs.serverlist()) clear_serverlist() diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index cc023ef10d..53fd17c309 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -21,6 +21,42 @@ local default_text = [[ two lines ]] +local multiline_text = [[ + 1 2 3 + A B C + 4 5 6 + X Y Z + 7 8 9 +]] + +local multimatch_text = [[ + a bdc eae a fgl lzia r + x +]] + +local multibyte_text = [[ + £ ¥ ѫѫ PEPPERS +£ ¥ ѫfѫ + a£ ѫ¥KOL +£ ¥ libm +£ ¥ +]] + +local long_multiline_text = [[ + 1 2 3 + A B C + 4 5 6 + X Y Z + 7 8 9 + K L M + a b c + d e f + q r s + x y z + £ m n + t œ ¥ +]] + local function common_setup(screen, inccommand, text) if screen then command("syntax on") @@ -682,14 +718,14 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw") screen:expect([[ Inc substitution on | - two lines | + {12:tw}o lines | | {15:~ }| {15:~ }| {11:[No Name] }| - |2| two lines | - |4| two lines | - | + |2| {12:tw}o lines | + |4| {12:tw}o lines | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -704,13 +740,13 @@ describe(":substitute, inccommand=split", function() it("shows preview when cmd modifiers are present", function() -- one modifier feed(':keeppatterns %s/tw/to') - screen:expect([[too lines]], nil, nil, nil, true) + screen:expect([[{12:to}o lines]], nil, nil, nil, true) feed('<Esc>') screen:expect([[two lines]], nil, nil, nil, true) -- multiple modifiers feed(':keeppatterns silent %s/tw/to') - screen:expect([[too lines]], nil, nil, nil, true) + screen:expect([[{12:to}o lines]], nil, nil, nil, true) feed('<Esc>') screen:expect([[two lines]], nil, nil, nil, true) @@ -724,14 +760,14 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw") screen:expect([[ Inc substitution on | - two lines | + {12:tw}o lines | | {15:~ }| {15:~ }| {11:[No Name] [+] }| - |2| two lines | - |4| two lines | - | + |2| {12:tw}o lines | + |4| {12:tw}o lines | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -752,7 +788,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| o lines | |4| o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -764,14 +800,14 @@ describe(":substitute, inccommand=split", function() feed("x") screen:expect([[ Inc substitution on | - xo lines | + {12:x}o lines | | {15:~ }| {15:~ }| {11:[No Name] [+] }| |2| {12:x}o lines | |4| {12:x}o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -790,7 +826,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| o lines | |4| o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -805,14 +841,14 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw/XX") screen:expect([[ Inc substitution on | - XXo lines | + {12:XX}o lines | | {15:~ }| {15:~ }| {11:[No Name] [+] }| |2| {12:XX}o lines | |4| {12:XX}o lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -828,7 +864,7 @@ describe(":substitute, inccommand=split", function() screen:sleep(1) screen:expect([[ Inc substitution on | - two lines | + {12:tw}o lines | Inc substitution on | two lines | | @@ -872,14 +908,14 @@ describe(":substitute, inccommand=split", function() -- 'cursorline' is NOT active during preview. screen:expect([[ Inc substitution on | - {9:tw}o lines | + {12:tw}o lines | Inc substitution on | - {9:tw}o lines | + {12:tw}o lines | | {11:[No Name] [+] }| - |2| {9:tw}o lines | - |4| {9:tw}o lines | - | + |2| {12:tw}o lines | + |4| {12:tw}o lines | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -894,14 +930,14 @@ describe(":substitute, inccommand=split", function() feed('M M M<esc>') feed(':%s/M/123/g') screen:expect([[ - 123 123 123 | + {12:123} {12:123} {12:123} | Inc substitution on | two lines | Inc substitution on | two lines | {11:[No Name] [+] }| |1| {12:123} {12:123} {12:123} | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -912,6 +948,28 @@ describe(":substitute, inccommand=split", function() ]]) end) + it("highlights nothing when there's no match", function() + feed('gg') + feed(':%s/Inx') + screen:expect([[ + Inc substitution on | + two lines | + Inc substitution on | + two lines | + | + {11:[No Name] [+] }| + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/Inx^ | + ]]) + end) + it('previews correctly when previewhight is small', function() feed_command('set cwh=3') feed_command('set hls') @@ -919,15 +977,15 @@ describe(":substitute, inccommand=split", function() insert(string.rep('abc abc abc\n', 20)) feed(':%s/abc/MMM/g') screen:expect([[ - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | - MMM MMM MMM | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} | {11:[No Name] [+] }| | 1| {12:MMM} {12:MMM} {12:MMM} | | 2| {12:MMM} {12:MMM} {12:MMM} | @@ -969,9 +1027,9 @@ describe(":substitute, inccommand=split", function() screen:expect([[ BBo lines | Inc substitution on | - Xo lines | + {12:X}o lines | Inc substitution on | - Xo lines | + {12:X}o lines | {11:[No Name] [+] }| |1001| {12:X}o lines | |1003| {12:X}o lines | @@ -1069,15 +1127,15 @@ describe(":substitute, inccommand=split", function() feed(":1,2s/t/X") screen:expect([[ - Inc subsXitution on | - Xwo lines | + Inc subs{12:X}itution on | + {12:X}wo lines | Inc substitution on | two lines | | {11:[No Name] [+] }| |1| Inc subs{12:X}itution on | |2| {12:X}wo lines | - | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1134,7 +1192,7 @@ describe("inccommand=nosplit", function() two lines | Inc substitution on | two lines | - Line *.X | + Line *.{12:X} | {15:~ }| {15:~ }| {15:~ }| @@ -1142,7 +1200,6 @@ describe("inccommand=nosplit", function() :%smagic/3.*/X^ | ]]) - feed([[<C-\><C-N>]]) -- cancel feed(":%snomagic/3.*/X") -- start :snomagic command screen:expect([[ @@ -1150,7 +1207,7 @@ describe("inccommand=nosplit", function() two lines | Inc substitution on | two lines | - Line *.X here | + Line *.{12:X} here | {15:~ }| {15:~ }| {15:~ }| @@ -1162,13 +1219,13 @@ describe("inccommand=nosplit", function() it("shows preview when cmd modifiers are present", function() -- one modifier feed(':keeppatterns %s/tw/to') - screen:expect([[too lines]], nil, nil, nil, true) + screen:expect([[{12:to}o lines]], nil, nil, nil, true) feed('<Esc>') screen:expect([[two lines]], nil, nil, nil, true) -- multiple modifiers feed(':keeppatterns silent %s/tw/to') - screen:expect([[too lines]], nil, nil, nil, true) + screen:expect([[{12:to}o lines]], nil, nil, nil, true) feed('<Esc>') screen:expect([[two lines]], nil, nil, nil, true) @@ -1178,15 +1235,38 @@ describe("inccommand=nosplit", function() feed('<Esc>') end) + it("does not show window after toggling :set inccommand", function() + feed(":%s/tw/OKOK") + feed("<Esc>") + command("set icm=split") + feed(":%s/tw/OKOK") + feed("<Esc>") + command("set icm=nosplit") + feed(":%s/tw/OKOK") + wait() + screen:expect([[ + Inc substitution on | + {12:OKOK}o lines | + Inc substitution on | + {12:OKOK}o lines | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/tw/OKOK^ | + ]]) + end) + it('never shows preview buffer', function() feed_command("set hlsearch") feed(":%s/tw") screen:expect([[ Inc substitution on | - {9:tw}o lines | + {12:tw}o lines | Inc substitution on | - {9:tw}o lines | + {12:tw}o lines | | {15:~ }| {15:~ }| @@ -1198,9 +1278,9 @@ describe("inccommand=nosplit", function() feed("/BM") screen:expect([[ Inc substitution on | - BMo lines | + {12:BM}o lines | Inc substitution on | - BMo lines | + {12:BM}o lines | | {15:~ }| {15:~ }| @@ -1212,9 +1292,9 @@ describe("inccommand=nosplit", function() feed("/") screen:expect([[ Inc substitution on | - BMo lines | + {12:BM}o lines | Inc substitution on | - BMo lines | + {12:BM}o lines | | {15:~ }| {15:~ }| @@ -1245,8 +1325,8 @@ describe("inccommand=nosplit", function() feed(":1,2s/t/X") screen:expect([[ - Inc subsXitution on | - Xwo lines | + Inc subs{12:X}itution on | + {12:X}wo lines | Inc substitution on | two lines | | @@ -1563,7 +1643,7 @@ describe("'inccommand' split windows", function() feed(":%s/tw") screen:expect([[ Inc substitution on {10:|}Inc substitution on| - two lines {10:|}two lines | + {12:tw}o lines {10:|}{12:tw}o lines | {10:|} | {15:~ }{10:|}{15:~ }| {15:~ }{10:|}{15:~ }| @@ -1578,13 +1658,13 @@ describe("'inccommand' split windows", function() {15:~ }{10:|}{15:~ }| {11:[No Name] [+] }{10:|}{15:~ }| Inc substitution on {10:|}{15:~ }| - two lines {10:|}{15:~ }| + {12:tw}o lines {10:|}{15:~ }| {10:|}{15:~ }| {15:~ }{10:|}{15:~ }| {15:~ }{10:|}{15:~ }| {10:[No Name] [+] [No Name] [+] }| - |2| two lines | - | + |2| {12:tw}o lines | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1602,7 +1682,7 @@ describe("'inccommand' split windows", function() feed(":%s/tw") screen:expect([[ Inc substitution on {10:|}Inc substitution on| - two lines {10:|}two lines | + {12:tw}o lines {10:|}{12:tw}o lines | {10:|} | {15:~ }{10:|}{15:~ }| {15:~ }{10:|}{15:~ }| @@ -1617,13 +1697,13 @@ describe("'inccommand' split windows", function() {15:~ }{10:|}{15:~ }| {11:[No Name] [+] }{10:[No Name] [+] }| Inc substitution on | - two lines | + {12:tw}o lines | | {15:~ }| {15:~ }| {10:[No Name] [+] }| - |2| two lines | - | + |2| {12:tw}o lines | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1652,7 +1732,7 @@ describe("'inccommand' split windows", function() screen:expect([[ Inc substitution on | - two lines | + {12:tw}o lines | | {15:~ }| {15:~ }| @@ -1672,8 +1752,8 @@ describe("'inccommand' split windows", function() {15:~ }| {15:~ }| {11:[No Name] [+] }| - |2| two lines | - | + |2| {12:tw}o lines | + {15:~ }| {15:~ }| {15:~ }| {15:~ }| @@ -1711,4 +1791,668 @@ describe("'inccommand' with 'gdefault'", function() expect("A\nA") eq({mode='n', blocking=false}, nvim("get_mode")) end) + + it("does not crash on zero-width matches #7485", function() + common_setup(nil, "split", default_text) + command("set gdefault") + feed("gg") + feed("Vj") + feed(":s/\\%V") + eq({mode='c', blocking=false}, nvim("get_mode")) + feed("<Esc>") + eq({mode='n', blocking=false}, nvim("get_mode")) + end) + + it("removes highlights after abort for a zero-width match", function() + local screen = Screen.new(30,5) + common_setup(screen, "nosplit", default_text) + command("set gdefault") + + feed(":%s/\\%1c/a/") + screen:expect([[ + {12:a}Inc substitution on | + {12:a}two lines | + {12:a} | + {15:~ }| + :%s/\%1c/a/^ | + ]]) + + feed("<Esc>") + screen:expect([[ + Inc substitution on | + two lines | + ^ | + {15:~ }| + | + ]]) + end) + +end) + +describe(":substitute", function() + local screen = Screen.new(30,15) + + before_each(function() + clear() + end) + + it(", inccommand=split, highlights multiline substitutions", function() + common_setup(screen, "split", multiline_text) + feed("gg") + + feed(":%s/2\\_.*X") + screen:expect([[ + 1 {12:2 3} | + {12:A B C} | + {12:4 5 6} | + {12:X} Y Z | + 7 8 9 | + {11:[No Name] [+] }| + |1| 1 {12:2 3} | + |2|{12: A B C} | + |3|{12: 4 5 6} | + |4|{12: X} Y Z | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/2\_.*X^ | + ]]) + + feed("/MMM") + screen:expect([[ + 1 {12:MMM} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| 1 {12:MMM} Y Z | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/2\_.*X/MMM^ | + ]]) + + feed("\\rK\\rLLL") + screen:expect([[ + 1 {12:MMM} | + {12:K} | + {12:LLL} Y Z | + 7 8 9 | + | + {11:[No Name] [+] }| + |1| 1 {12:MMM} | + |2|{12: K} | + |3|{12: LLL} Y Z | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/2\_.*X/MMM\rK\rLLL^ | + ]]) + end) + + it(", inccommand=nosplit, highlights multiline substitutions", function() + common_setup(screen, "nosplit", multiline_text) + feed("gg") + + feed(":%s/2\\_.*X/MMM") + screen:expect([[ + 1 {12:MMM} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/2\_.*X/MMM^ | + ]]) + + feed("\\rK\\rLLL") + screen:expect([[ + 1 {12:MMM} | + {12:K} | + {12:LLL} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/2\_.*X/MMM\rK\rLLL^ | + ]]) + end) + + it(", inccommand=split, highlights multiple matches on a line", function() + common_setup(screen, "split", multimatch_text) + command("set gdefault") + feed("gg") + + feed(":%s/a/XLK") + screen:expect([[ + {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| + x | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:X}| + {12:LK} r | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/a/XLK^ | + ]]) + end) + + it(", inccommand=nosplit, highlights multiple matches on a line", function() + common_setup(screen, "nosplit", multimatch_text) + command("set gdefault") + feed("gg") + + feed(":%s/a/XLK") + screen:expect([[ + {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| + x | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/a/XLK^ | + ]]) + end) + + it(", inccommand=split, with \\zs", function() + common_setup(screen, "split", multiline_text) + feed("gg") + + feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") + screen:expect([[ + 1 2 3 | + {12:OKO} B C | + 4 5 6 | + {12:OKO} Y Z | + 7 8 9 | + {11:[No Name] [+] }| + |1| 1 2 3 | + |2| {12:OKO} B C | + |3| 4 5 6 | + |4| {12:OKO} Y Z | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[0-9]\n\zs[A-Z]/OKO^ | + ]]) + end) + + it(", inccommand=nosplit, with \\zs", function() + common_setup(screen, "nosplit", multiline_text) + feed("gg") + + feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") + screen:expect([[ + 1 2 3 | + {12:OKO} B C | + 4 5 6 | + {12:OKO} Y Z | + 7 8 9 | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/[0-9]\n\zs[A-Z]/OKO^ | + ]]) + end) + + it(", inccommand=split, substitutions of different length", + function() + common_setup(screen, "split", "T T123 T2T TTT T090804\nx") + + feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") + screen:expect([[ + T {12:123123} {12:22}T TTT {12:090804090804} | + x | + {15:~ }| + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| T {12:123123} {12:22}T TTT {12:090804090}| + {12:804} | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/T\([0-9]\+\)/\1\1/g^ | + ]]) + end) + + it(", inccommand=nosplit, substitutions of different length", function() + common_setup(screen, "nosplit", "T T123 T2T TTT T090804\nx") + + feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") + screen:expect([[ + T {12:123123} {12:22}T TTT {12:090804090804} | + x | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/T\([0-9]\+\)/\1\1/g^ | + ]]) + end) + + it(", inccommand=split, contraction of lines", function() + local text = [[ + T T123 T T123 T2T TT T23423424 + x + afa Q + adf la;lkd R + alx + ]] + + common_setup(screen, "split", text) + feed(":%s/[QR]\\n") + screen:expect([[ + afa {12:Q} | + adf la;lkd {12:R} | + alx | + | + {15:~ }| + {11:[No Name] [+] }| + |3| afa {12:Q} | + |4|{12: }adf la;lkd {12:R} | + |5|{12: }alx | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[QR]\n^ | + ]]) + + feed("/KKK") + screen:expect([[ + x | + afa {12:KKK}adf la;lkd {12:KKK}alx | + | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |3| afa {12:KKK}adf la;lkd {12:KKK}alx | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/[QR]\n/KKK^ | + ]]) + end) + + it(", inccommand=nosplit, contraction of lines", function() + local text = [[ + T T123 T T123 T2T TT T23423424 + x + afa Q + adf la;lkd R + alx + ]] + + common_setup(screen, "nosplit", text) + feed(":%s/[QR]\\n/KKK") + screen:expect([[ + T T123 T T123 T2T TT T23423424| + x | + afa {12:KKK}adf la;lkd {12:KKK}alx | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/[QR]\n/KKK^ | + ]]) + end) + + it(", inccommand=split, multibyte text", function() + common_setup(screen, "split", multibyte_text) + feed(":%s/£.*ѫ/X¥¥") + screen:expect([[ + {12:X¥¥} | + a{12:X¥¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {11:[No Name] [+] }| + |1| {12:X¥¥} PEPPERS | + |2| {12:X¥¥} | + |3| a{12:X¥¥}¥KOL | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/£.*ѫ/X¥¥^ | + ]]) + + feed("\\ra££ ¥") + screen:expect([[ + {12:a££ ¥} | + a{12:X¥¥} | + {12:a££ ¥}¥KOL | + £ ¥ libm | + £ ¥ | + {11:[No Name] [+] }| + |1| {12:X¥¥} | + |2|{12: a££ ¥} PEPPERS | + |3| {12:X¥¥} | + |4|{12: a££ ¥} | + |5| a{12:X¥¥} | + |6|{12: a££ ¥}¥KOL | + {15:~ }| + {10:[Preview] }| + :%s/£.*ѫ/X¥¥\ra££ ¥^ | + ]]) + end) + + it(", inccommand=nosplit, multibyte text", function() + common_setup(screen, "nosplit", multibyte_text) + feed(":%s/£.*ѫ/X¥¥") + screen:expect([[ + {12:X¥¥} PEPPERS | + {12:X¥¥} | + a{12:X¥¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/£.*ѫ/X¥¥^ | + ]]) + + feed("\\ra££ ¥") + screen:expect([[ + {12:X¥¥} | + {12:a££ ¥} PEPPERS | + {12:X¥¥} | + {12:a££ ¥} | + a{12:X¥¥} | + {12:a££ ¥}¥KOL | + £ ¥ libm | + £ ¥ | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :%s/£.*ѫ/X¥¥\ra££ ¥^ | + ]]) + end) + + it(", inccommand=split, small cmdwinheight", function() + common_setup(screen, "split", long_multiline_text) + command("set cmdwinheight=2") + + feed(":%s/[a-z]") + screen:expect([[ + X Y Z | + 7 8 9 | + K L M | + {12:a} b c | + {12:d} e f | + {12:q} r s | + {12:x} y z | + £ {12:m} n | + {12:t} œ ¥ | + | + {11:[No Name] [+] }| + | 7| {12:a} b c | + | 8| {12:d} e f | + {10:[Preview] }| + :%s/[a-z]^ | + ]]) + + feed("/JLKR £") + screen:expect([[ + X Y Z | + 7 8 9 | + K L M | + {12:JLKR £} b c | + {12:JLKR £} e f | + {12:JLKR £} r s | + {12:JLKR £} y z | + £ {12:JLKR £} n | + {12:JLKR £} œ ¥ | + | + {11:[No Name] [+] }| + | 7| {12:JLKR £} b c | + | 8| {12:JLKR £} e f | + {10:[Preview] }| + :%s/[a-z]/JLKR £^ | + ]]) + + feed("\\rѫ ab \\rXXXX") + screen:expect([[ + 7 8 9 | + K L M | + {12:JLKR £} | + {12:ѫ ab } | + {12:XXXX} b c | + {12:JLKR £} | + {12:ѫ ab } | + {12:XXXX} e f | + {12:JLKR £} | + {11:[No Name] [+] }| + | 7| {12:JLKR £} | + | 8|{12: ѫ ab } | + {10:[Preview] }| + :%s/[a-z]/JLKR £\rѫ ab \rXXX| + X^ | + ]]) + end) + + it(", inccommand=split, large cmdwinheight", function() + common_setup(screen, "split", long_multiline_text) + command("set cmdwinheight=11") + + feed(":%s/. .$") + screen:expect([[ + t {12:œ ¥} | + {11:[No Name] [+] }| + | 1| 1 {12:2 3} | + | 2| A {12:B C} | + | 3| 4 {12:5 6} | + | 4| X {12:Y Z} | + | 5| 7 {12:8 9} | + | 6| K {12:L M} | + | 7| a {12:b c} | + | 8| d {12:e f} | + | 9| q {12:r s} | + |10| x {12:y z} | + |11| £ {12:m n} | + {10:[Preview] }| + :%s/. .$^ | + ]]) + + feed("/ YYY") + screen:expect([[ + t {12: YYY} | + {11:[No Name] [+] }| + | 1| 1 {12: YYY} | + | 2| A {12: YYY} | + | 3| 4 {12: YYY} | + | 4| X {12: YYY} | + | 5| 7 {12: YYY} | + | 6| K {12: YYY} | + | 7| a {12: YYY} | + | 8| d {12: YYY} | + | 9| q {12: YYY} | + |10| x {12: YYY} | + |11| £ {12: YYY} | + {10:[Preview] }| + :%s/. .$/ YYY^ | + ]]) + + feed("\\r KKK") + screen:expect([[ + a {12: YYY} | + {11:[No Name] [+] }| + | 1| 1 {12: YYY} | + | 2|{12: KKK} | + | 3| A {12: YYY} | + | 4|{12: KKK} | + | 5| 4 {12: YYY} | + | 6|{12: KKK} | + | 7| X {12: YYY} | + | 8|{12: KKK} | + | 9| 7 {12: YYY} | + |10|{12: KKK} | + |11| K {12: YYY} | + {10:[Preview] }| + :%s/. .$/ YYY\r KKK^ | + ]]) + end) + + it(", inccommand=split, lookaround", function() + common_setup(screen, "split", "something\neverything\nsomeone") + feed([[:%s/\(some\)\@<lt>=thing/one/]]) + screen:expect([[ + some{12:one} | + everything | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| some{12:one} | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/\(some\)\@<=thing/one/^ | + ]]) + + feed("<C-c>") + wait() + feed([[:%s/\(some\)\@<lt>!thing/one/]]) + screen:expect([[ + something | + every{12:one} | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |2| every{12:one} | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/\(some\)\@<!thing/one/^ | + ]]) + + feed([[<C-c>]]) + wait() + feed([[:%s/some\(thing\)\@=/every/]]) + screen:expect([[ + {12:every}thing | + everything | + someone | + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |1| {12:every}thing | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/some\(thing\)\@=/every/^ | + ]]) + + feed([[<C-c>]]) + wait() + feed([[:%s/some\(thing\)\@!/every/]]) + screen:expect([[ + everything | + {12:every}one | + {15:~ }| + {15:~ }| + {15:~ }| + {11:[No Name] [+] }| + |3| {12:every}one | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :%s/some\(thing\)\@!/every/^ | + ]]) + end) end) diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua index 56331a33b5..e8271de0bf 100644 --- a/test/functional/ui/tabline_spec.lua +++ b/test/functional/ui/tabline_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, command, eq = helpers.clear, helpers.command, helpers.eq -describe('ui/tabline', function() +describe('ui/ext_tabline', function() local screen local event_tabs, event_curtab @@ -21,37 +21,34 @@ describe('ui/tabline', function() screen:detach() end) - describe('externalized', function() - it('publishes UI events', function() - command("tabedit another-tab") + it('publishes UI events', function() + command("tabedit another-tab") - local expected_tabs = { - {tab = { id = 1 }, name = '[No Name]'}, - {tab = { id = 2 }, name = 'another-tab'}, - } - screen:expect([[ - ^ | - ~ | - ~ | - ~ | - | - ]], nil, nil, function() - eq({ id = 2 }, event_curtab) - eq(expected_tabs, event_tabs) - end) - - command("tabNext") - screen:expect([[ - ^ | - ~ | - ~ | - ~ | - | - ]], nil, nil, function() - eq({ id = 1 }, event_curtab) - eq(expected_tabs, event_tabs) - end) + local expected_tabs = { + {tab = { id = 1 }, name = '[No Name]'}, + {tab = { id = 2 }, name = 'another-tab'}, + } + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + | + ]], nil, nil, function() + eq({ id = 2 }, event_curtab) + eq(expected_tabs, event_tabs) + end) + command("tabNext") + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + | + ]], nil, nil, function() + eq({ id = 1 }, event_curtab) + eq(expected_tabs, event_tabs) end) end) end) diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 41a751c284..042969357e 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -179,3 +179,100 @@ describe('command line completion', function() ]]) end) end) + +describe('ui/ext_wildmenu', function() + local screen + local items, selected = nil, nil + + before_each(function() + clear() + screen = Screen.new(25, 5) + screen:attach({rgb=true, ext_wildmenu=true}) + screen:set_on_event_handler(function(name, data) + if name == "wildmenu_show" then + items = data[1] + elseif name == "wildmenu_select" then + selected = data[1] + elseif name == "wildmenu_hide" then + items, selected = nil, nil + end + end) + end) + + after_each(function() + screen:detach() + end) + + it('works with :sign <tab>', function() + local expected = { + 'define', + 'jump', + 'list', + 'place', + 'undefine', + 'unplace', + } + + command('set wildmode=full') + command('set wildmenu') + feed(':sign <tab>') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign define^ | + ]], nil, nil, function() + eq(expected, items) + eq(0, selected) + end) + + feed('<tab>') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign jump^ | + ]], nil, nil, function() + eq(expected, items) + eq(1, selected) + end) + + feed('<left><left>') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign ^ | + ]], nil, nil, function() + eq(expected, items) + eq(-1, selected) + end) + + feed('<right>') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign define^ | + ]], nil, nil, function() + eq(expected, items) + eq(0, selected) + end) + + feed('a') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign definea^ | + ]], nil, nil, function() + eq(nil, items) + eq(nil, selected) + end) + end) +end) diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua index 0e5278345c..b70ef724b7 100644 --- a/test/functional/viml/completion_spec.lua +++ b/test/functional/viml/completion_spec.lua @@ -868,7 +868,7 @@ describe('completion', function() end) end) -describe('ui/externalized/popupmenu', function() +describe('ui/ext_popupmenu', function() local screen local items, selected, anchor before_each(function() |