From: Bram Moolenaar Date: Wed, 4 Jul 2018 20:36:46 +0000 (+0200) Subject: patch 8.1.0150: insufficient test coverage for Tcl X-Git-Tag: v8.1.0150 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd34cebe9a3a179a5639355c43d2d4959182a279;p=vim patch 8.1.0150: insufficient test coverage for Tcl Problem: Insufficient test coverage for Tcl. Solution: Add more tests. (Dominique Pelle, closes #3140) --- diff --git a/src/testdir/test_tcl.vim b/src/testdir/test_tcl.vim index ac772cc4d..6c4695915 100644 --- a/src/testdir/test_tcl.vim +++ b/src/testdir/test_tcl.vim @@ -4,20 +4,634 @@ if !has('tcl') finish end -function Test_tcldo() +" 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 switching to another buffer does not trigger ml_get error. + " 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 <