To: vim_dev@googlegroups.com Subject: Patch 8.1.0163 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0163 Problem: Insufficient testing for Tcl. Solution: Add a few more tests. (Dominique Pelle, closes #3166) Files: src/testdir/test_tcl.vim *** ../vim-8.1.0162/src/testdir/test_tcl.vim Wed Jul 4 22:36:42 2018 --- src/testdir/test_tcl.vim Sat Jul 7 22:39:36 2018 *************** *** 110,115 **** --- 110,126 ---- call assert_equal('+4', &cc) call assert_equal('+4', TclEval('::vim::option cc')) + " Test boolean option with 'toggle', 'on' and 'off' keywords. + call assert_equal('0', TclEval('::vim::option nu toggle')) + call assert_equal(1, &nu) + call assert_equal('1', TclEval('::vim::option nu toggle')) + call assert_equal(0, &nu) + call assert_equal('0', TclEval('::vim::option nu on')) + call assert_equal(1, &nu) + call assert_equal('1', TclEval('::vim::option nu off')) + call assert_equal(0, &nu) + + call assert_fails('tcl ::vim::option nu x', 'expected integer but got "x"') call assert_fails('tcl ::vim::option xxx', 'unknown vimOption') call assert_fails('tcl ::vim::option', \ 'wrong # args: should be "::vim::option vimOption ?value?"') *************** *** 124,129 **** --- 135,141 ---- call assert_fails('tcl ::vim::expr x y', \ 'wrong # args: should be "::vim::expr vimExpr"') + call assert_fails('tcl ::vim::expr 1-', 'E15: Invalid expression: 1-') endfunc " Test ::vim::command *************** *** 131,136 **** --- 143,153 ---- call assert_equal('hello world', \ TclEval('::vim::command {echo "hello world"}')) + " Check that if ::vim::command created a new Tcl interpreter, it is removed. + tcl set foo 123 + call assert_equal('321', TclEval('::vim::command "tcl set foo 321"')) + call assert_equal('123', TclEval('set foo')) + " With the -quiet option, the error should silently be ignored. call assert_equal('', TclEval('::vim::command -quiet xyz')) *************** *** 142,147 **** --- 159,166 ---- " With the -quiet option, the error should silently be ignored. call assert_equal('', TclEval('::vim::command -quiet xyz')) + + tcl unset foo endfunc " Test ::vim::window list *************** *** 164,175 **** " Test output messages func Test_output() ! call assert_fails('tcl puts vimerr "an error"', 'an error') ! tcl puts vimout "a message" ! tcl puts "another message" let messages = split(execute('message'), "\n") ! call assert_equal('a message', messages[-2]) ! call assert_equal('another message', messages[-1]) call assert_fails('tcl puts', \ 'wrong # args: should be "puts ?-nonewline? ?channelId? string"') --- 183,197 ---- " Test output messages func Test_output() ! call assert_fails('tcl puts vimerr "error #1"', 'error #1') ! call assert_fails('tcl puts stderr "error #2"', 'error #2') ! tcl puts vimout "message #1" ! tcl puts stdout "message #2" ! tcl puts "message #3" let messages = split(execute('message'), "\n") ! call assert_equal('message #3', messages[-1]) ! call assert_equal('message #2', messages[-2]) ! call assert_equal('message #1', messages[-3]) call assert_fails('tcl puts', \ 'wrong # args: should be "puts ?-nonewline? ?channelId? string"') *************** *** 447,459 **** call setline(1, ['line1', 'line2', 'line3', 'line4', 'line5']) tcl $::vim::current(buffer) set 2 a call assert_equal(['line1', 'a', 'line3', 'line4', 'line5'], getline(1, '$')) tcl $::vim::current(buffer) set 3 4 b call assert_equal(['line1', 'a', 'b', 'line5'], getline(1, '$')) tcl $::vim::current(buffer) set 4 3 c call assert_equal(['line1', 'a', 'c'], getline(1, '$')) call assert_fails('tcl $::vim::current(buffer) set 0 "x"', 'line number out of range') ! call assert_fails('tcl $::vim::current(buffer) set 5 "x"', 'line number out of range') call assert_fails('tcl $::vim::current(buffer) set', 'wrong # args:') bwipe! --- 469,489 ---- call setline(1, ['line1', 'line2', 'line3', 'line4', 'line5']) tcl $::vim::current(buffer) set 2 a call assert_equal(['line1', 'a', 'line3', 'line4', 'line5'], getline(1, '$')) + + " Test with fewer replacing lines than replaced lines: lines get deleted. tcl $::vim::current(buffer) set 3 4 b call assert_equal(['line1', 'a', 'b', 'line5'], getline(1, '$')) tcl $::vim::current(buffer) set 4 3 c call assert_equal(['line1', 'a', 'c'], getline(1, '$')) + " Test with more replacing lines than replaced lines: lines get added. + tcl $::vim::current(buffer) set 2 3 {x y z} + call assert_equal(['line1', 'x', 'y', 'z'], getline(1, '$')) + tcl $::vim::current(buffer) set 3 2 {X Y Z} + call assert_equal(['line1', 'X', 'Y', 'Z', 'z'], getline(1, '$')) + call assert_fails('tcl $::vim::current(buffer) set 0 "x"', 'line number out of range') ! 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:') bwipe! *************** *** 622,628 **** call delete('Xtcl_file') endfunc ! " Test exiting current Tcl interprepter and re-creating one. func Test_tcl_exit() tcl set foo "foo" call assert_fails('tcl exit 3', 'E572: exit code 3') --- 652,658 ---- call delete('Xtcl_file') endfunc ! " Test exiting current Tcl interpreter and re-creating one. func Test_tcl_exit() tcl set foo "foo" call assert_fails('tcl exit 3', 'E572: exit code 3') *** ../vim-8.1.0162/src/version.c Sat Jul 7 22:26:49 2018 --- src/version.c Sat Jul 7 22:39:52 2018 *************** *** 791,792 **** --- 791,794 ---- { /* Add new patch number below this line */ + /**/ + 163, /**/ -- hundred-and-one symptoms of being an internet addict: 200. You really believe in the concept of a "paperless" office. /// 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 ///