From b853b6e4ea1269ab7ae766bd71d9bafd54dc2b98 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 20 Sep 2019 01:31:01 -0400 Subject: vim-patch:8.0.1109: timer causes error on exit from Ex mode Problem: Timer causes error on exit from Ex mode. (xtal8) Solution: save and restore the ex_pressedreturn flag. (Christian Brabandt, closes vim/vim#2079) https://github.com/vim/vim/commit/f5291f301e9322545f0621b2157e93050d1d4fb3 --- src/nvim/testdir/test_timers.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 24c735865c..ab5d89d675 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -252,4 +252,15 @@ func Test_peek_and_get_char() call timer_stop(intr) endfunc +func Test_ex_mode() + " Function with an empty line. + func Foo(...) + + endfunc + let timer = timer_start(40, function('g:Foo'), {'repeat':-1}) + " This used to throw error E749. + exe "normal Qsleep 100m\rvi\r" + call timer_stop(timer) +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 2a7ffc6567097232f5e12b6d3dc6483748eaad0a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 20 Sep 2019 19:19:46 -0400 Subject: vim-patch:8.0.1776: in tests, when WaitFor() fails it doesn't say why Problem: In tests, when WaitFor() fails it doesn't say why. Solution: Turn a few more WaitFor() into WaitForAssert(). https://github.com/vim/vim/commit/0e9d1ae3216a5940b36bb56d155fb300b2e55b00 --- src/nvim/testdir/test_timers.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index ab5d89d675..bd63d94729 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -141,7 +141,7 @@ endfunc func Test_delete_myself() let g:called = 0 let t = timer_start(10, 'StopMyself', {'repeat': -1}) - call WaitFor('g:called == 2') + call WaitForAssert({-> assert_equal(2, g:called)}) call assert_equal(2, g:called) call assert_equal([], timer_info(t)) endfunc @@ -208,7 +208,7 @@ func Test_timer_errors() let g:call_count = 0 let timer = timer_start(10, 'FuncWithError', {'repeat': -1}) " Timer will be stopped after failing 3 out of 3 times. - call WaitFor('g:call_count == 3') + call WaitForAssert({-> assert_equal(3, g:call_count)}) sleep 50m call assert_equal(3, g:call_count) endfunc @@ -226,7 +226,7 @@ func Test_timer_catch_error() let g:call_count = 0 let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4}) " Timer will not be stopped. - call WaitFor('g:call_count == 4') + call WaitForAssert({-> assert_equal(4, g:call_count)}) sleep 50m call assert_equal(4, g:call_count) endfunc -- cgit From 4c4bcecc4a1b817be742856ac8600c90d24c42f4 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 3 Jan 2020 20:08:13 -0500 Subject: vim-patch:8.0.1817: a timer may change v:count unexpectedly Problem: A timer may change v:count unexpectedly. Solution: Save and restore v:count and similar variables when a timer callback is invoked. (closes vim/vim#2897) https://github.com/vim/vim/commit/b0f42ba60d9e6d101d103421ba0c351811615c15 --- src/nvim/testdir/test_timers.vim | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index bd63d94729..cadec88af9 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -5,6 +5,7 @@ if !has('timers') endif source shared.vim +source screendump.vim source load.vim func MyHandler(timer) @@ -263,4 +264,35 @@ func Test_ex_mode() call timer_stop(timer) endfunc +func Test_restore_count() + if !CanRunVimInTerminal() + return + endif + " Check that v:count is saved and restored, not changed by a timer. + call writefile([ + \ 'nnoremap L v:count ? v:count . "l" : "l"', + \ 'func Doit(id)', + \ ' normal 3j', + \ 'endfunc', + \ 'call timer_start(100, "Doit")', + \ ], 'Xtrcscript') + call writefile([ + \ '1-1234', + \ '2-1234', + \ '3-1234', + \ ], 'Xtrctext') + let buf = RunVimInTerminal('-S Xtrcscript Xtrctext', {}) + + " Wait for the timer to move the cursor to the third line. + call WaitForAssert({-> assert_equal(3, term_getcursor(buf)[0])}) + call assert_equal(1, term_getcursor(buf)[1]) + " Now check that v:count has not been set to 3 + call term_sendkeys(buf, 'L') + call WaitForAssert({-> assert_equal(2, term_getcursor(buf)[1])}) + + call StopVimInTerminal(buf) + call delete('Xtrcscript') + call delete('Xtrctext') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From a2554858df533fcfa0ba6074648e21cda50934d9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 3 Jan 2020 22:43:06 -0500 Subject: vim-patch:8.1.0840: getchar(0) never returns a character in the terminal Problem: getchar(0) never returns a character in the terminal. Solution: Call wait_func() at least once. https://github.com/vim/vim/commit/12dfc9eef14fe74c46145aa9e6cba9666f1bcd40 --- src/nvim/testdir/test_timers.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index cadec88af9..161a89c38c 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -253,6 +253,16 @@ func Test_peek_and_get_char() call timer_stop(intr) endfunc +func Test_getchar_zero() + call timer_start(20, {id -> feedkeys('x', 'L')}) + let c = 0 + while c == 0 + let c = getchar(0) + sleep 10m + endwhile + call assert_equal('x', nr2char(c)) +endfunc + func Test_ex_mode() " Function with an empty line. func Foo(...) -- cgit From 25613fa65bf1c3bbe2b675ff273acb94f47656bc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 3 Jan 2020 22:47:38 -0500 Subject: vim-patch:8.1.0842: getchar_zero test fails on MS-Windows Problem: getchar_zero test fails on MS-Windows. Solution: Disable the test for now. https://github.com/vim/vim/commit/cb908a813cebf7fb4608ff43fc3d258cf2768809 --- src/nvim/testdir/test_timers.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 161a89c38c..e4d9329ac6 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -254,13 +254,20 @@ func Test_peek_and_get_char() endfunc func Test_getchar_zero() - call timer_start(20, {id -> feedkeys('x', 'L')}) + if has('win32') + " Console: no low-level input + " GUI: somehow doesn't work + return + endif + + let id = timer_start(20, {id -> feedkeys('x', 'L')}) let c = 0 while c == 0 let c = getchar(0) sleep 10m endwhile call assert_equal('x', nr2char(c)) + call timer_stop(id) endfunc func Test_ex_mode() @@ -268,7 +275,7 @@ func Test_ex_mode() func Foo(...) endfunc - let timer = timer_start(40, function('g:Foo'), {'repeat':-1}) + let timer = timer_start(40, function('g:Foo'), {'repeat':-1}) " This used to throw error E749. exe "normal Qsleep 100m\rvi\r" call timer_stop(timer) -- cgit From d139fb5cd08a9bdee30e0735e9e795585036ce7b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 3 Jan 2020 22:48:53 -0500 Subject: vim-patch:8.1.0844: when timer fails test will hang forever Problem: When timer fails test will hang forever. Solution: Use reltime() to limit waiting time. (Ozaki Kiichi, closes vim/vim#3878) https://github.com/vim/vim/commit/50948e4ac24314d5a70404bbc592ffc28755ad9f --- src/nvim/testdir/test_timers.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index e4d9329ac6..6c336e6fa6 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -260,9 +260,11 @@ func Test_getchar_zero() return endif + " Measure the elapsed time to avoid a hang when it fails. + let start = reltime() let id = timer_start(20, {id -> feedkeys('x', 'L')}) let c = 0 - while c == 0 + while c == 0 && reltimefloat(reltime(start)) < 0.2 let c = getchar(0) sleep 10m endwhile -- cgit From 3a3fb0860248b42e05de6591d4b7727453efdef2 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 3 Jan 2020 22:58:09 -0500 Subject: vim-patch:8.1.0851: feedkeys() with "L" does not work properly Problem: feedkeys() with "L" does not work properly. Solution: Do not set typebuf_was_filled when using "L". (Ozaki Kiichi, closes vim/vim#3885) https://github.com/vim/vim/commit/8d4ce56a19ed14d13332f94ad592fff2d9a715d5 --- src/nvim/testdir/test_timers.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 6c336e6fa6..c4d74222a4 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -254,15 +254,14 @@ func Test_peek_and_get_char() endfunc func Test_getchar_zero() - if has('win32') + if has('win32') && !has('gui_running') " Console: no low-level input - " GUI: somehow doesn't work return endif " Measure the elapsed time to avoid a hang when it fails. let start = reltime() - let id = timer_start(20, {id -> feedkeys('x', 'L')}) + let id = timer_start(20, {-> feedkeys('x', 'L')}) let c = 0 while c == 0 && reltimefloat(reltime(start)) < 0.2 let c = getchar(0) -- cgit From 1aacab49ea0e5cff94bd89595737b6af677f4490 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 5 Jan 2020 10:40:02 -0500 Subject: vim-patch:8.1.1579: dict and list could be GC'ed while displaying error Problem: Dict and list could be GC'ed while displaying error in a timer. (Yasuhiro Matsumoto) Solution: Block garbage collection when executing a timer. Add test_garbagecollect_soon(). Add "no_wait_return" to test_override(). (closes vim/vim#4571) https://github.com/vim/vim/commit/adc6714aac20f5462a0ecec50ab4806b2f3ab0db --- src/nvim/testdir/test_timers.vim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index c4d74222a4..3043103270 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -313,4 +313,30 @@ func Test_restore_count() call delete('Xtrctext') endfunc +" Test that the garbage collector isn't triggered if a timer callback invokes +" vgetc(). +func Test_nocatch_garbage_collect() + " skipped: Nvim does not support test_garbagecollect_soon(), test_override() + return + " 'uptimetime. must be bigger than the timer timeout + set ut=200 + call test_garbagecollect_soon() + call test_override('no_wait_return', 0) + func CauseAnError(id) + " This will show an error and wait for Enter. + let a = {'foo', 'bar'} + endfunc + func FeedChar(id) + call feedkeys('x', 't') + endfunc + call timer_start(300, 'FeedChar') + call timer_start(100, 'CauseAnError') + let x = getchar() + + set ut& + call test_override('no_wait_return', 1) + delfunc CauseAnError + delfunc FeedChar +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From b00650cfe909313e58aa8181474d7f016d9df94a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 7 Mar 2020 23:15:25 -0500 Subject: vim-patch:8.2.0361: internal error when using "0" for a callback Problem: Internal error when using "0" for a callback. Solution: Give a normal error. (closes vim/vim#5743) https://github.com/vim/vim/commit/14e57909e662a43a42438e2701654af48af49b03 --- src/nvim/testdir/test_timers.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 3043103270..40376a877e 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -339,4 +339,8 @@ func Test_nocatch_garbage_collect() delfunc FeedChar endfunc +func Test_timer_invalid_callback() + call assert_fails('call timer_start(0, "0")', 'E921') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 5058b07122507e5cdd988dc956f0b6b359d18193 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 28 Apr 2020 23:13:23 -0400 Subject: vim-patch:8.1.1581: shared functions for testing are disorganised Problem: Shared functions for testing are disorganised. Solution: Group finctions in script files. (Ozaki Kiichi, closes vim/vim#4573) https://github.com/vim/vim/commit/7a39dd7f00239059ce34660611589b26126a550c --- src/nvim/testdir/test_timers.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_timers.vim') diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 40376a877e..cffd80ff4f 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -5,7 +5,7 @@ if !has('timers') endif source shared.vim -source screendump.vim +source term_util.vim source load.vim func MyHandler(timer) -- cgit