" Tests for the Tcl interface. source check.vim CheckFeature tcl " Helper function as there is no builtin tcleval() function similar " to perleval, luaeval(), 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 <