To: vim_dev@googlegroups.com Subject: Patch 8.2.0358 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0358 Problem: Insufficient testing for indent.c. Solution: Add indent tests. (Yegappan Lakshmanan, closes #5736) Files: src/testdir/Make_all.mak, src/testdir/test_ex_mode.vim, src/testdir/test_expand_func.vim, src/testdir/test_indent.vim, src/testdir/test_lispwords.vim, src/testdir/test_smartindent.vim, src/testdir/test_vartabs.vim *** ../vim-8.2.0357/src/testdir/Make_all.mak 2020-03-03 23:06:44.522535263 +0100 --- src/testdir/Make_all.mak 2020-03-06 20:33:26.541350864 +0100 *************** *** 146,151 **** --- 146,152 ---- test_iminsert \ test_increment \ test_increment_dbcs \ + test_indent \ test_ins_complete \ test_interrupt \ test_job_fails \ *************** *** 376,381 **** --- 377,383 ---- test_iminsert.res \ test_increment.res \ test_increment_dbcs.res \ + test_indent.res \ test_ins_complete.res \ test_interrupt.res \ test_job_fails.res \ *** ../vim-8.2.0357/src/testdir/test_ex_mode.vim 2020-03-02 20:54:19.323757498 +0100 --- src/testdir/test_ex_mode.vim 2020-03-06 20:33:26.541350864 +0100 *************** *** 54,59 **** --- 54,60 ---- " default wildchar interferes with this test set wildchar= call assert_equal(["a\tb", "a\tb"], Ex("a\t\t\b"), e) + call assert_equal(["\t mn", "\tm\n"], Ex("\tm\n"), e) set wildchar& endfor *** ../vim-8.2.0357/src/testdir/test_expand_func.vim 2019-08-24 20:06:51.000000000 +0200 --- src/testdir/test_expand_func.vim 2020-03-06 20:33:26.541350864 +0100 *************** *** 73,75 **** --- 73,89 ---- " Don't add any line above this, otherwise will change. quit endfunc + + " Test for 'wildignore' with expand() + func Test_expand_wildignore() + set wildignore=*.vim + call assert_equal('', expand('test_expand_func.vim')) + call assert_equal('', expand('test_expand_func.vim', 0)) + call assert_equal([], expand('test_expand_func.vim', 0, 1)) + call assert_equal('test_expand_func.vim', expand('test_expand_func.vim', 1)) + call assert_equal(['test_expand_func.vim'], + \ expand('test_expand_func.vim', 1, 1)) + set wildignore& + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0357/src/testdir/test_indent.vim 2020-03-06 20:35:36.720714388 +0100 --- src/testdir/test_indent.vim 2020-03-06 20:33:26.541350864 +0100 *************** *** 0 **** --- 1,101 ---- + " Test for various indent options + + func Test_preserveindent() + new + " Test for autoindent copying indent from the previous line + setlocal autoindent + call setline(1, [repeat(' ', 16) .. 'line1']) + call feedkeys("A\nline2", 'xt') + call assert_equal("\t\tline2", getline(2)) + setlocal autoindent& + + " Test for using CTRL-T with and without 'preserveindent' + set shiftwidth=4 + call cursor(1, 1) + call setline(1, " \t ") + call feedkeys("Al\", 'xt') + call assert_equal("\t\tl", getline(1)) + set preserveindent + call setline(1, " \t ") + call feedkeys("Al\", 'xt') + call assert_equal(" \t \tl", getline(1)) + set pi& sw& + + " Test for using CTRL-T with 'expandtab' and 'preserveindent' + call cursor(1, 1) + call setline(1, "\t \t") + set shiftwidth=4 expandtab preserveindent + call feedkeys("Al\", 'xt') + call assert_equal("\t \t l", getline(1)) + set sw& et& pi& + + close! + endfunc + + " Test for indent() + func Test_indent_func() + call assert_equal(-1, indent(-1)) + new + call setline(1, "\tabc") + call assert_equal(8, indent(1)) + call setline(1, " abc") + call assert_equal(4, indent(1)) + call setline(1, " \t abc") + call assert_equal(12, indent(1)) + close! + endfunc + + " Test for reindenting a line using the '=' operator + func Test_reindent() + new + call setline(1, 'abc') + set nomodifiable + call assert_fails('normal ==', 'E21:') + set modifiable + + call setline(1, ['foo', 'bar']) + call feedkeys('ggVG=', 'xt') + call assert_equal(['foo', 'bar'], getline(1, 2)) + close! + endfunc + + " Test for shifting a line with a preprocessor directive ('#') + func Test_preproc_indent() + new + set sw=4 + call setline(1, '#define FOO 1') + normal >> + call assert_equal(' #define FOO 1', getline(1)) + + " with 'smartindent' + call setline(1, '#define FOO 1') + set smartindent + normal >> + call assert_equal('#define FOO 1', getline(1)) + set smartindent& + + " with 'cindent' + set cindent + normal >> + call assert_equal('#define FOO 1', getline(1)) + set cindent& + + close! + endfunc + + " Test for 'copyindent' + func Test_copyindent() + new + set shiftwidth=4 autoindent expandtab copyindent + call setline(1, " \t abc") + call feedkeys("ol", 'xt') + call assert_equal(" \t l", getline(2)) + set noexpandtab + call setline(1, " \t abc") + call feedkeys("ol", 'xt') + call assert_equal(" \t l", getline(2)) + set sw& ai& et& ci& + close! + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0357/src/testdir/test_lispwords.vim 2019-08-31 22:04:56.000000000 +0200 --- src/testdir/test_lispwords.vim 2020-03-06 20:33:26.541350864 +0100 *************** *** 45,50 **** --- 45,51 ---- \ ]) call assert_equal(7, lispindent(2)) call assert_equal(5, 6->lispindent()) + call assert_equal(-1, lispindent(-1)) set lisp set lispwords& *************** *** 83,85 **** --- 84,88 ---- let &cpoptions=save_copt set nolisp endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0357/src/testdir/test_smartindent.vim 2019-01-09 22:46:34.000000000 +0100 --- src/testdir/test_smartindent.vim 2020-03-06 20:33:26.541350864 +0100 *************** *** 38,41 **** --- 38,64 ---- bwipe! endfunc + " Test for inserting '{' and '} with smartindent + func Test_smartindent_braces() + new + set smartindent shiftwidth=4 + call setline(1, [' if (a)', "\tif (b)", "\t return 1"]) + normal 2ggO{ + normal 3ggA { + normal 4ggo} + normal o} + normal 4ggO#define FOO 1 + call assert_equal([ + \ ' if (a)', + \ ' {', + \ "\tif (b) {", + \ '#define FOO 1', + \ "\t return 1", + \ "\t}", + \ ' }' + \ ], getline(1, '$')) + set si& sw& ai& + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0357/src/testdir/test_vartabs.vim 2019-09-06 22:44:14.000000000 +0200 --- src/testdir/test_vartabs.vim 2020-03-06 20:33:26.541350864 +0100 *************** *** 91,96 **** --- 91,108 ---- let expect = "l\ l\l l\ l\ l" call assert_equal(expect, getline(1)) + " Test for 'retab' with vts + set ts=8 sts=0 vts=5,3,6,2 vsts= + exe "norm! S l" + .retab! + call assert_equal("\t\t\t\tl", getline(1)) + + " Test for 'retab' with same vlaues as vts + set ts=8 sts=0 vts=5,3,6,2 vsts= + exe "norm! S l" + .retab! 5,3,6,2 + call assert_equal("\t\t\t\tl", getline(1)) + " Check that global and local values are set. set ts=4 vts=6 sts=8 vsts=10 call assert_equal(&ts, 4) *************** *** 378,380 **** --- 390,422 ---- set all& call assert_equal('', &vts) endfunc + + func s:SaveCol(l) + call add(a:l, [col('.'), virtcol('.')]) + return '' + endfunc + + " Test for 'varsofttabstop' + func Test_varsofttabstop() + new + inoremap s:SaveCol(g:cols) + + set backspace=indent,eol,start + set varsofttabstop=6,2,5,3 + let g:cols = [] + call feedkeys("a\t\\t\\t\\t\ ", 'xt') + call assert_equal("\t\t ", getline(1)) + call assert_equal([[7, 7], [2, 9], [7, 14], [3, 17]], g:cols) + + let g:cols = [] + call feedkeys("a\\\\\\\\\\", 'xt') + call assert_equal('', getline(1)) + call assert_equal([[3, 17], [7, 14], [2, 9], [7, 7], [1, 1]], g:cols) + + set varsofttabstop& + set backspace& + iunmap + close! + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0357/src/version.c 2020-03-05 21:52:51.062454460 +0100 --- src/version.c 2020-03-05 22:19:58.272502087 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 358, /**/ -- Rule #1: Don't give somebody a tool that he's going to hurt himself with. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///