From 1037ce2e461034a20e35ad59969fd05d5ad68b91 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 9 Dec 2023 20:42:00 +0800 Subject: test: avoid repeated screen lines in expected states This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g --- test/functional/editor/completion_spec.lua | 257 ++++++----------------------- 1 file changed, 51 insertions(+), 206 deletions(-) (limited to 'test/functional/editor/completion_spec.lua') diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index 84af90a298..504943e3cc 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -41,22 +41,14 @@ describe('completion', function() screen:expect([[ foo | foo^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- Keyword Local completion (^N^P) The only match} | ]]) feed('') screen:expect([[ foo | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- INSERT --} | ]]) feed('') @@ -112,10 +104,7 @@ describe('completion', function() foo^ | {2:bar foobaz baz }{0: }| {1:abbr kind menu }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:-- Omni completion (^O^N^P) }{4:match 1 of 2} | ]]) eq({word = 'foo', abbr = 'bar', menu = 'baz', @@ -140,11 +129,7 @@ describe('completion', function() screen:expect([[ foo | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- INSERT --} | ]]) feed('') @@ -152,11 +137,7 @@ describe('completion', function() screen:expect([[ foo | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} | ]]) feed('') @@ -164,10 +145,7 @@ describe('completion', function() foo | foo^ | {2:foo }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:-- Keyword Local completion (^N^P) The only match} | ]]) feed('bar') @@ -178,9 +156,7 @@ describe('completion', function() foobar | foo^ | {2:foo }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- INSERT --} | ]]) eq('foo', eval('getline(3)')) @@ -192,34 +168,24 @@ describe('completion', function() foo | ^ | {2:foo }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:-- Keyword Local completion (^N^P) The only match} | ]]) feed('') screen:expect([[ foo | foo^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- INSERT --} | ]]) feed('') eq('foo', eval('getline(2)')) feed('o=TestComplete()') screen:expect([[ - foo | - foo | + foo |*2 ^ | {2:foo }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- INSERT --} | ]]) feed('') @@ -232,21 +198,14 @@ describe('completion', function() foo | ^ | {1:foo }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:-- Keyword Local completion (^N^P) }{5:Back at original} | ]]) feed('b') screen:expect([[ foo | b^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- Keyword Local completion (^N^P) }{5:Back at original} | ]]) feed('ar') @@ -257,9 +216,7 @@ describe('completion', function() bar | ^ | {1:foo }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- INSERT --} | ]]) feed('bar') @@ -272,21 +229,14 @@ describe('completion', function() foo | ^ | {1:foo }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:-- Keyword Local completion (^N^P) }{5:Back at original} | ]]) feed('') screen:expect([[ foo | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) eq('', eval('getline(2)')) @@ -296,9 +246,7 @@ describe('completion', function() | ^ | {1:foo }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- INSERT --} | ]]) feed('') @@ -306,10 +254,7 @@ describe('completion', function() foo | | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) eq('', eval('getline(3)')) @@ -438,33 +383,20 @@ describe('completion', function() screen:expect([[ ug^ | {1:August }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- User defined completion (^U^N^P) }{5:Back at original} | ]]) feed('') screen:expect([[ ug^ | {2:August }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- User defined completion (^U^N^P) The only match} | ]]) feed('') screen:expect([[ August^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 {3:-- INSERT --} | ]]) expect('August') @@ -476,10 +408,7 @@ describe('completion', function() | Ja^ | {1:January }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:-- User defined completion (^U^N^P) }{5:Back at original} | ]]) feed('') @@ -489,8 +418,7 @@ describe('completion', function() {1:January }{0: }| {1:June }{0: }| {1:July }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- User defined completion (^U^N^P) }{5:Back at original} | ]]) feed('') @@ -500,8 +428,7 @@ describe('completion', function() {2:January }{0: }| {1:June }{0: }| {1:July }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- User defined completion (^U^N^P) }{4:match 1 of 3} | ]]) feed('') @@ -511,19 +438,14 @@ describe('completion', function() {1:January }{0: }| {2:June }{0: }| {1:July }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- User defined completion (^U^N^P) }{4:match 2 of 3} | ]]) feed('') screen:expect([[ | Jun^e | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) feed('.') @@ -531,10 +453,7 @@ describe('completion', function() | June | Jun^e | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) expect([[ @@ -705,12 +624,7 @@ describe('completion', function() feed('') screen:expect([[ 96^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 {3:-- INSERT --} | ]]) end) @@ -748,10 +662,7 @@ describe('completion', function() inc uninc indent unindent | ind^ | {2:indent }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} | ]]) @@ -760,11 +671,7 @@ describe('completion', function() screen:expect([[ inc uninc indent unindent | indent^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- INSERT --} | ]]) -- Indents when completion is exited using ESC. @@ -773,10 +680,7 @@ describe('completion', function() inc uninc indent unindent | indent | in^d | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) -- Works for unindenting too. @@ -789,8 +693,7 @@ describe('completion', function() ind | unind^ | {0:~ }{2: unindent }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} | ]]) -- Works when going back and forth. @@ -801,8 +704,7 @@ describe('completion', function() ind | uninc^ | {0:~ }{2: uninc }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} | ]]) feed("d") @@ -812,8 +714,7 @@ describe('completion', function() ind | unind^ | {0:~ }{2: unindent }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- Keyword Local completion (^N^P) }{4:match 1 of 2} | ]]) feed("") @@ -822,9 +723,7 @@ describe('completion', function() indent | ind | uninden^t | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -835,22 +734,14 @@ describe('completion', function() screen:expect([[ ^foo | bar | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) feed('A') screen:expect([[ foo^ | bar | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- Whole line completion (^L^N^P) }{7:Pattern not found} | ]]) eq(-1, eval('foldclosed(1)')) @@ -865,9 +756,7 @@ describe('completion', function() fooegg^ | {1:foobar }{0: }| {2:fooegg }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- Keyword completion (^N^P) }{4:match 1 of 2} | ]]) @@ -878,9 +767,7 @@ describe('completion', function() fooegg^ | {1:foobar }{0: }| {2:fooegg }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- Keyword completion (^N^P) }{4:match 1 of 2} | ]], unchanged=true} @@ -891,9 +778,7 @@ describe('completion', function() foobar^ | {2:foobar }{0: }| {1:fooegg }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- Keyword completion (^N^P) }{4:match 2 of 2} | ]]) end) @@ -904,12 +789,7 @@ describe('completion', function() feed(':lua CURRENT_TESTING_') screen:expect{grid=[[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 :lua CURRENT_TESTING_VAR^ | ]]} end) @@ -920,11 +800,7 @@ describe('completion', function() feed(':lua CURRENT_TESTING_') screen:expect{ grid = [[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {10:CURRENT_TESTING_BAR}{9: CURRENT_TESTING_FOO }| :lua CURRENT_TESTING_BAR^ | ]], unchanged = true } @@ -958,9 +834,7 @@ describe('completion', function() | {8:[No Name] }| {0::}foo faa fee f^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {9:[Command Line] }| {3:-- INSERT --} | ]] ) @@ -980,9 +854,7 @@ describe('completion', function() | {8:[No Name] }| {0::}foo faa fee foo | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {9:[Command Line] }| :foo faa fee foo^ | ]]) @@ -1015,11 +887,7 @@ describe('completion', function() screen:expect([[ ^ | {1:1 3 2 }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- INSERT --} | ]]) end) @@ -1062,9 +930,7 @@ describe('completion', function() bar | foobar | f^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- Keyword completion (^N^P) }{5:Back at original} | ]], popupmenu = { anchor = { 1, 3, 0 }, @@ -1081,9 +947,7 @@ describe('completion', function() bar | foobar | foob^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- Keyword completion (^N^P) }{5:Back at original} | ]], popupmenu = { anchor = { 1, 3, 0 }, @@ -1175,12 +1039,7 @@ describe('completion', function() {2:hello }{0: }| {1:hullo }{0: }| {1:heeee }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 {3:-- }{4:match 1 of 3} | ]]) command([[call timer_start(100, { -> execute('stopinsert') })]]) @@ -1191,15 +1050,7 @@ describe('completion', function() hullo | heee^e | hello | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) end) @@ -1239,9 +1090,7 @@ describe('completion', function() {1:bar }{0: }| {1:foa }{0: }| {1:.hidden }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- }{4:match 1 of 4} | ]]} feed('ccf') @@ -1249,11 +1098,7 @@ describe('completion', function() foo^ | {2:foo }{0: }| {1:foa }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- }{4:match 1 of 2} | ]]} end) -- cgit