To: vim_dev@googlegroups.com Subject: Patch 8.2.1165 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1165 Problem: Insufficient testing for the Tcl interface. Solution: Add more tests. (Yegappan Lakshmanan, closes #6423) Files: src/testdir/test_tcl.vim *** ../vim-8.2.1164/src/testdir/test_tcl.vim 2020-04-14 20:15:45.288566185 +0200 --- src/testdir/test_tcl.vim 2020-07-09 18:46:37.336363745 +0200 *************** *** 23,28 **** --- 23,35 ---- call setline(1, ['one', 'two', 'three']) tcldo ::vim::command new call assert_equal(wincount + 1, winnr('$')) + + " Try to run a command in a 'nomodifiable' buffer + call setline(1, ['one', 'two', 'three']) + set nomodifiable + call assert_fails('tcldo set line "abc"', 'cannot save undo information') + set modifiable + %bwipe! endfunc *************** *** 91,96 **** --- 98,106 ---- \ 'expected integer but got "x"') call assert_fails('tcl ::vim::buffer list x', \ 'wrong # args: should be "::vim::buffer list "') + " Invalid buffer command + call assert_fails('tcl $::vim::current(buffer) abcd', + \ 'bad option "abcd":') tcl rename eachbuf "" %bwipe! *************** *** 176,181 **** --- 186,193 ---- call assert_fails('tcl ::vim::window x', 'unknown option') call assert_fails('tcl ::vim::window list x', \ 'wrong # args: should be "::vim::window option"') + call assert_fails('tcl $::vim::current(window) abcd', + \ 'bad option "abcd":') %bwipe endfunc *************** *** 248,253 **** --- 260,278 ---- tcl $win cursor $here(row) $here(column) call assert_equal([0, 2, 3, 0], getpos('.')) + " Invalid values for the row and column + tcl array set pos {1 2} + call assert_fails('tcl $win cursor pos', "can't read \"pos(row)\":") + tcl array set pos {row '' abc 2} + call assert_fails('tcl $win cursor pos', "expected integer but got \"''\"") + tcl array set pos {row 1 abc 2} + call assert_fails('tcl $win cursor pos', "can't read \"pos(column)\":") + tcl array set pos {row 1 column ''} + call assert_fails('tcl $win cursor pos', "expected integer but got \"''\"") + + call assert_fails("tcl $win cursor '' 2", "expected integer but got \"''\"") + call assert_fails("tcl $win cursor 1 ''", "expected integer but got \"''\"") + call assert_fails('tcl $win cursor 1 1 1', 'wrong # args:') tcl unset win here *************** *** 351,356 **** --- 376,382 ---- call assert_equal('window deleted', TclEval('set msg')) call assert_fails('tcl $::vim::current(window) delcmd', 'wrong # args') + call assert_fails('tcl $::vim::current(window) delcmd x x', 'wrong # args') tcl unset msg bwipe *************** *** 417,422 **** --- 443,456 ---- call assert_fails('tcl $::vim::current(buffer) delete', 'wrong # args:') call assert_fails('tcl $::vim::current(buffer) delete 1 2 3', 'wrong # args:') + call assert_fails('tcl $::vim::current(buffer) delete 1 abc', + \ 'expected integer but got "abc"') + + " Try to delete lines from an 'nomodifiable' buffer + set nomodifiable + call assert_fails('tcl $::vim::current(buffer) delete 2 1', + \ 'cannot save undo information') + set modifiable bwipe! endfunc *************** *** 458,463 **** --- 492,503 ---- call assert_fails('tcl $buf append', 'wrong # args:') call assert_fails('tcl $buf append 1 x x', 'wrong # args:') + " Try to append lines to a 'nomodifiable' buffer + set nomodifiable + call assert_fails('tcl $buf append 1 "first"', + \ 'cannot save undo information') + set modifiable + tcl unset buf bwipe! endfunc *************** *** 485,490 **** --- 525,542 ---- call assert_fails('tcl $::vim::current(buffer) set 6 "x"', 'line number out of range') call assert_fails('tcl $::vim::current(buffer) set', 'wrong # args:') + call assert_fails('tcl $::vim::current(buffer) set 1 2 {[list "a" "b"]}', + \ 'list element in quotes followed by "]" instead of space') + + " Try to modify a 'nomodifiable' buffer + set nomodifiable + call assert_fails('tcl $::vim::current(buffer) set 1 "x"', + \ 'cannot save undo information') + call assert_fails('tcl $::vim::current(buffer) set 1 {a b}', + \ 'cannot save undo information') + call assert_fails('tcl $::vim::current(buffer) set 1 2 {a b}', + \ 'cannot save undo information') + set modifiable bwipe! endfunc *************** *** 514,519 **** --- 566,572 ---- call assert_fails('tcl $buf get 0 1', 'line number out of range') call assert_fails('tcl $::vim::current(buffer) get x', 'expected integer but got "x"') + call assert_fails('tcl $::vim::current(buffer) get 1 x', 'expected integer but got "x"') call assert_fails('tcl $::vim::current(buffer) get 1 1 1', 'wrong # args:') tcl unset buf *************** *** 592,599 **** q call assert_equal('buffer deleted', TclEval('set msg')) ! call assert_fails('tcl $::vim::current(window) delcmd', 'wrong # args') ! call assert_fails('tcl $::vim::current(window) delcmd x x', 'wrong # args') tcl unset msg %bwipe --- 645,652 ---- q call assert_equal('buffer deleted', TclEval('set msg')) ! call assert_fails('tcl $::vim::current(buffer) delcmd', 'wrong # args') ! call assert_fails('tcl $::vim::current(buffer) delcmd x x', 'wrong # args') tcl unset msg %bwipe *** ../vim-8.2.1164/src/version.c 2020-07-08 23:09:24.599921761 +0200 --- src/version.c 2020-07-09 18:48:57.155684238 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1165, /**/ -- It's totally unfair to suggest - as many have - that engineers are socially inept. Engineers simply have different objectives when it comes to social interaction. (Scott Adams - The Dilbert principle) /// 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 ///