From 2e790e9ad10bca3a64b20be75672a3c6a6f3d97c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 19 Jul 2022 20:55:13 +0800 Subject: vim-patch:8.2.0509: various code is not properly tested. Problem: various code is not properly tested. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#5871) https://github.com/vim/vim/commit/cde0ff39da2459b16007fef701ebaa449fb6fe9d Cherry-pick test_clientserver.vim change from patch 8.1.1826. Cherry-pick a comment from patch 8.2.0301. Omit test_viminfo.vim. --- src/nvim/testdir/test_textformat.vim | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/nvim/testdir/test_textformat.vim') diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index 970f5ae0d0..1d1f20d91a 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -1260,6 +1260,41 @@ func Test_comment_nested() %bw! endfunc +" Test for a space character in 'comments' setting +func Test_comment_space() + new + setlocal comments=b:\ > fo+=ro + exe "normal i> B\nD\ggOA\joC" + exe "normal Go > F\nH\kOE\joG" + let expected =<< trim END + A + > B + C + D + > E + > F + > G + > H + END + call assert_equal(expected, getline(1, '$')) + %bw! +endfunc + +" Test for the 'O' flag in 'comments' +func Test_comment_O() + new + setlocal comments=Ob:* fo+=ro + exe "normal i* B\nD\kOA\joC" + let expected =<< trim END + A + * B + * C + * D + END + call assert_equal(expected, getline(1, '$')) + %bw! +endfunc + " Test for 'a' and 'w' flags in 'formatoptions' func Test_fo_a_w() new @@ -1299,6 +1334,25 @@ func Test_fo_a_w() %bw! endfunc +" Test for 'j' flag in 'formatoptions' +func Test_fo_j() + new + setlocal fo+=j comments=:// + call setline(1, ['i++; // comment1', ' // comment2']) + normal J + call assert_equal('i++; // comment1 comment2', getline(1)) + setlocal fo-=j + call setline(1, ['i++; // comment1', ' // comment2']) + normal J + call assert_equal('i++; // comment1 // comment2', getline(1)) + " Test with nested comments + setlocal fo+=j comments=n:>,n:) + call setline(1, ['i++; > ) > ) comment1', ' > ) comment2']) + normal J + call assert_equal('i++; > ) > ) comment1 comment2', getline(1)) + %bw! +endfunc + " Test for formatting lines using gq in visual mode func Test_visual_gq_format() new -- cgit