To: vim_dev@googlegroups.com Subject: Patch 8.1.0150 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0150 Problem: Insufficient test coverage for Tcl. Solution: Add more tests. (Dominique Pelle, closes #3140) Files: src/testdir/test_tcl.vim *** ../vim-8.1.0149/src/testdir/test_tcl.vim 2017-01-29 23:18:53.000000000 +0100 --- src/testdir/test_tcl.vim 2018-07-04 22:33:49.173452418 +0200 *************** *** 4,23 **** finish end ! function Test_tcldo() " Check deleting lines does not trigger ml_get error. new call setline(1, ['one', 'two', 'three']) tcldo ::vim::command %d_ bwipe! ! " Check switching to another buffer does not trigger ml_get error. new let wincount = winnr('$') call setline(1, ['one', 'two', 'three']) tcldo ::vim::command new call assert_equal(wincount + 1, winnr('$')) bwipe! bwipe! endfunc --- 4,637 ---- finish end ! " Helper function as there is no builtin tcleval() function similar ! " to perleval, luaevel(), pyeval(), etc. ! func TclEval(tcl_expr) ! let s = split(execute('tcl ' . a:tcl_expr), "\n") ! return (len(s) == 0) ? '' : s[-1] ! endfunc ! ! func Test_tcldo() " Check deleting lines does not trigger ml_get error. new call setline(1, ['one', 'two', 'three']) tcldo ::vim::command %d_ bwipe! ! " Check that switching to another buffer does not trigger ml_get error. new let wincount = winnr('$') call setline(1, ['one', 'two', 'three']) tcldo ::vim::command new call assert_equal(wincount + 1, winnr('$')) + %bwipe! + endfunc + + " Test :tcldo with a range + func Test_tcldo_range() + new + call setline(1, ['line1', 'line2', 'line3', 'line4']) + 2,3tcldo set line [string toupper $line] + call assert_equal(['line1', 'LINE2', 'LINE3', 'line4'], getline(1, '$')) + bwipe! + endfunc + + " Test ::vim::beep + func Test_vim_beep() + call assert_beeps('tcl ::vim::beep') + call assert_fails('tcl ::vim::beep x', 'wrong # args: should be "::vim::beep"') + endfunc + + " Test ::vim::buffer + func Test_vim_buffer() + " Test ::vim::buffer {nr} + e Xfoo1 + call setline(1, ['foobar']) + let bn1 = bufnr('%') + let b1 = TclEval('::vim::buffer ' . bn1) + call assert_equal(b1, TclEval('set ::vim::current(buffer)')) + + new Xfoo2 + call setline(1, ['barfoo']) + let bn2 = bufnr('%') + let b2 = TclEval('::vim::buffer ' . bn2) + call assert_equal(b2, TclEval('set ::vim::current(buffer)')) + + call assert_match('Xfoo1$', TclEval(b1 . ' name')) + call assert_match('Xfoo2$', TclEval(b2 . ' name')) + + " Test ::vim::buffer exists {nr} + call assert_match('^[1-9]\d*$', TclEval('::vim::buffer exists ' . bn1)) + call assert_match('^[1-9]\d*$', TclEval('::vim::buffer exists ' . bn2)) + call assert_equal('0', TclEval('::vim::buffer exists 54321')) + + " Test ::vim::buffer list + call assert_equal('2', TclEval('llength [::vim::buffer list]')) + call assert_equal(b1.' '.b2, TclEval('::vim::buffer list')) + tcl <