From ad99d0bf7e291564dd858f8206db52311f8878cc Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Mon, 18 Apr 2016 20:58:18 +0200 Subject: vim-patch:5a46a58 Add missing test file. https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f --- src/nvim/testdir/test_cursor_func.vim | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/nvim/testdir/test_cursor_func.vim (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim new file mode 100644 index 0000000000..684391e2a5 --- /dev/null +++ b/src/nvim/testdir/test_cursor_func.vim @@ -0,0 +1,35 @@ +" Tests for cursor(). + +func Test_wrong_arguments() + try + call cursor(1. 3) + " not reached + call assert_false(1) + catch + call assert_exception('E474:') + endtry +endfunc + +func Test_move_cursor() + new + call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) + + call cursor([1, 1, 0, 1]) + call assert_equal([1, 1, 0, 1], getcurpos()[1:]) + call cursor([4, 3, 0, 3]) + call assert_equal([4, 3, 0, 3], getcurpos()[1:]) + + call cursor(2, 2) + call assert_equal([2, 2, 0, 3], getcurpos()[1:]) + " line number zero keeps the line number + call cursor(0, 1) + call assert_equal([2, 1, 0, 3], getcurpos()[1:]) + " col number zero keeps the column + call cursor(3, 0) + call assert_equal([3, 1, 0, 3], getcurpos()[1:]) + " below last line goes to last line + call cursor(9, 1) + call assert_equal([4, 1, 0, 3], getcurpos()[1:]) + + quit! +endfunc -- cgit From 11fd9655542fd2676e13d00791b4bc9e96772300 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Mon, 18 Apr 2016 21:06:04 +0200 Subject: vim-patch:7.4.1300 Problem: Cannot test CursorMovedI because there is typeahead. Solution: Add disable_char_avail_for_testing(). https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63 Most of it manually applied. --- src/nvim/testdir/test_cursor_func.vim | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 684391e2a5..d3236e6e01 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -20,16 +20,35 @@ func Test_move_cursor() call assert_equal([4, 3, 0, 3], getcurpos()[1:]) call cursor(2, 2) - call assert_equal([2, 2, 0, 3], getcurpos()[1:]) + call assert_equal([2, 2, 0, 2], getcurpos()[1:]) " line number zero keeps the line number call cursor(0, 1) - call assert_equal([2, 1, 0, 3], getcurpos()[1:]) + call assert_equal([2, 1, 0, 1], getcurpos()[1:]) " col number zero keeps the column call cursor(3, 0) - call assert_equal([3, 1, 0, 3], getcurpos()[1:]) + call assert_equal([3, 1, 0, 1], getcurpos()[1:]) " below last line goes to last line call cursor(9, 1) - call assert_equal([4, 1, 0, 3], getcurpos()[1:]) + call assert_equal([4, 1, 0, 1], getcurpos()[1:]) quit! endfunc + +" Very short version of what matchparen does. +function s:Highlight_Matching_Pair() + let save_cursor = getcurpos() + call setpos('.', save_cursor) +endfunc + +func Test_curswant_with_autocommand() + new + call setline(1, ['func()', '{', '}', '----']) + autocmd! CursorMovedI * call s:Highlight_Matching_Pair() + call disable_char_avail_for_testing(1) + exe "normal! 3Ga\X\" + call disable_char_avail_for_testing(0) + call assert_equal('-X---', getline(4)) + autocmd! CursorMovedI * + quit! +endfunc + -- cgit From db9c22adb9e1843a8b5aafb1d4976adac65eace6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 25 Apr 2016 05:51:22 -0400 Subject: legacy test: Makefile --- src/nvim/testdir/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 4debdd9acc..82c7cd4de9 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -41,6 +41,7 @@ SCRIPTS := \ # Keep test_alot*.res as the last one, sort the others. NEW_TESTS = \ test_viml.res \ + test_cursor_func.res \ test_alot.res SCRIPTS_GUI := test16.out -- cgit From 0d6fe73d7b4dbba5bcea4559896c92f9c7e3f10a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 26 Apr 2016 22:34:12 -0400 Subject: vim-patch:7.4.1118 Problem: Tests hang in 24 line terminal. Solution: Set the 'more' option off. https://github.com/vim/vim/commit/a99b90437af730dcafd9143c0942c87777a00d52 --- src/nvim/testdir/runtest.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 1c610eab51..6601dcf52f 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -62,6 +62,7 @@ else endif " Locate Test_ functions and execute them. +set nomore redir @q function /^Test_ redir END -- cgit From e4146dd7df0f1ba932a01a79d6dd511914763c72 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 26 Apr 2016 23:29:55 -0400 Subject: remove disable_char_avail_for_testing() test_cursor_func.vim hangs at the call to disable_char_avail_for_testing(). The test does not actually need this function (and it correctly fails if the fix from 7.4.1300 is reverted). Given that disable_char_avail_for_testing is a gigantic hack, if we can avoid it let's do so. --- src/nvim/testdir/test_cursor_func.vim | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index d3236e6e01..d819b7b092 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -44,9 +44,7 @@ func Test_curswant_with_autocommand() new call setline(1, ['func()', '{', '}', '----']) autocmd! CursorMovedI * call s:Highlight_Matching_Pair() - call disable_char_avail_for_testing(1) exe "normal! 3Ga\X\" - call disable_char_avail_for_testing(0) call assert_equal('-X---', getline(4)) autocmd! CursorMovedI * quit! -- cgit