annotate src/testdir/test_tcl.vim @ 18045:af0b4ffab794 v8.1.2018

patch 8.1.2018: using freed memory when out of memory and displaying message Commit: https://github.com/vim/vim/commit/e5fbd7393067c279860598ac8359d1617b1082b9 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 9 20:04:13 2019 +0200 patch 8.1.2018: using freed memory when out of memory and displaying message Problem: Using freed memory when out of memory and displaying message. Solution: Make a copy of the message first.
author Bram Moolenaar <Bram@vim.org>
date Mon, 09 Sep 2019 20:15:03 +0200
parents 9606c0adc148
children a653d1a165ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10763
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the Tcl interface.
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
3 source check.vim
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17049
diff changeset
4 CheckFeature tcl
10763
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
6 " Helper function as there is no builtin tcleval() function similar
17918
9606c0adc148 patch 8.1.1955: tests contain typos
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
7 " to perleval, luaeval(), pyeval(), etc.
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
8 func TclEval(tcl_expr)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
9 let s = split(execute('tcl ' . a:tcl_expr), "\n")
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
10 return (len(s) == 0) ? '' : s[-1]
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
11 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
12
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
13 func Test_tcldo()
10763
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 " Check deleting lines does not trigger ml_get error.
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 new
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call setline(1, ['one', 'two', 'three'])
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 tcldo ::vim::command %d_
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 bwipe!
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
20 " Check that switching to another buffer does not trigger ml_get error.
10763
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 new
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 let wincount = winnr('$')
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call setline(1, ['one', 'two', 'three'])
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 tcldo ::vim::command new
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call assert_equal(wincount + 1, winnr('$'))
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
26 %bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
27 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
28
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
29 " Test :tcldo with a range
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
30 func Test_tcldo_range()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
31 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
32 call setline(1, ['line1', 'line2', 'line3', 'line4'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
33 2,3tcldo set line [string toupper $line]
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
34 call assert_equal(['line1', 'LINE2', 'LINE3', 'line4'], getline(1, '$'))
10763
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 bwipe!
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
36 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
37
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
38 " Test ::vim::beep
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
39 func Test_vim_beep()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
40 call assert_beeps('tcl ::vim::beep')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
41 call assert_fails('tcl ::vim::beep x', 'wrong # args: should be "::vim::beep"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
42 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
43
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
44 " Test ::vim::buffer
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
45 func Test_vim_buffer()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
46 " Test ::vim::buffer {nr}
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
47 e Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
48 call setline(1, ['foobar'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
49 let bn1 = bufnr('%')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
50 let b1 = TclEval('::vim::buffer ' . bn1)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
51 call assert_equal(b1, TclEval('set ::vim::current(buffer)'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
52
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
53 new Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
54 call setline(1, ['barfoo'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
55 let bn2 = bufnr('%')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
56 let b2 = TclEval('::vim::buffer ' . bn2)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
57 call assert_equal(b2, TclEval('set ::vim::current(buffer)'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
58
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
59 call assert_match('Xfoo1$', TclEval(b1 . ' name'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
60 call assert_match('Xfoo2$', TclEval(b2 . ' name'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
61
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
62 " Test ::vim::buffer exists {nr}
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
63 call assert_match('^[1-9]\d*$', TclEval('::vim::buffer exists ' . bn1))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
64 call assert_match('^[1-9]\d*$', TclEval('::vim::buffer exists ' . bn2))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
65 call assert_equal('0', TclEval('::vim::buffer exists 54321'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
66
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
67 " Test ::vim::buffer list
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
68 call assert_equal('2', TclEval('llength [::vim::buffer list]'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
69 call assert_equal(b1.' '.b2, TclEval('::vim::buffer list'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
70 tcl <<EOF
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
71 proc eachbuf { cmd } {
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
72 foreach b [::vim::buffer list] { $b command $cmd }
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
73 }
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
74 EOF
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
75 tcl eachbuf %s/foo/FOO/g
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
76 b! Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
77 call assert_equal(['FOObar'], getline(1, '$'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
78 b! Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
79 call assert_equal(['barFOO'], getline(1, '$'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
80
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
81 call assert_fails('tcl ::vim::buffer',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
82 \ 'wrong # args: should be "::vim::buffer option"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
83 call assert_fails('tcl ::vim::buffer ' . bn1 . ' x',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
84 \ 'wrong # args: should be "::vim::buffer bufNumber"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
85 call assert_fails('tcl ::vim::buffer 4321', 'invalid buffer number')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
86 call assert_fails('tcl ::vim::buffer x',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
87 \ 'bad option "x": must be exists or list')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
88 call assert_fails('tcl ::vim::buffer exists',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
89 \ 'wrong # args: should be "::vim::buffer exists bufNumber"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
90 call assert_fails('tcl ::vim::buffer exists x',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
91 \ 'expected integer but got "x"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
92 call assert_fails('tcl ::vim::buffer list x',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
93 \ 'wrong # args: should be "::vim::buffer list "')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
94
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
95 tcl rename eachbuf ""
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
96 %bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
97 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
98
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
99 " Test ::vim::option
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
100 func Test_vim_option()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
101 set cc=3,5
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
102
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
103 " Test getting option 'cc'
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
104 call assert_equal('3,5', TclEval('::vim::option cc'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
105 call assert_equal('3,5', &cc)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
106
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
107 " Test setting option 'cc' (it returns the old option value)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
108 call assert_equal('3,5', TclEval('::vim::option cc +4'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
109 call assert_equal('+4', &cc)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
110 call assert_equal('+4', TclEval('::vim::option cc'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
111
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
112 " Test boolean option with 'toggle', 'on' and 'off' keywords.
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
113 call assert_equal('0', TclEval('::vim::option nu toggle'))
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
114 call assert_equal(1, &nu)
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
115 call assert_equal('1', TclEval('::vim::option nu toggle'))
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
116 call assert_equal(0, &nu)
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
117 call assert_equal('0', TclEval('::vim::option nu on'))
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
118 call assert_equal(1, &nu)
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
119 call assert_equal('1', TclEval('::vim::option nu off'))
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
120 call assert_equal(0, &nu)
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
121
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
122 call assert_fails('tcl ::vim::option nu x', 'expected integer but got "x"')
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
123 call assert_fails('tcl ::vim::option xxx', 'unknown vimOption')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
124 call assert_fails('tcl ::vim::option',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
125 \ 'wrong # args: should be "::vim::option vimOption ?value?"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
126
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
127 set cc&
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
128 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
129
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
130 " Test ::vim::expr
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
131 func Test_vim_expr()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
132 call assert_equal(string(char2nr('X')),
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
133 \ TclEval('::vim::expr char2nr("X")'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
134
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
135 call assert_fails('tcl ::vim::expr x y',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
136 \ 'wrong # args: should be "::vim::expr vimExpr"')
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
137 call assert_fails('tcl ::vim::expr 1-', 'E15: Invalid expression: 1-')
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
138 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
139
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
140 " Test ::vim::command
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
141 func Test_vim_command()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
142 call assert_equal('hello world',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
143 \ TclEval('::vim::command {echo "hello world"}'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
144
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
145 " Check that if ::vim::command created a new Tcl interpreter, it is removed.
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
146 tcl set foo 123
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
147 call assert_equal('321', TclEval('::vim::command "tcl set foo 321"'))
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
148 call assert_equal('123', TclEval('set foo'))
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
149
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
150 " With the -quiet option, the error should silently be ignored.
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
151 call assert_equal('', TclEval('::vim::command -quiet xyz'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
152
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
153 call assert_fails('tcl ::vim::command',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
154 \ 'wrong # args: should be "::vim::command ?-quiet? exCommand"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
155 call assert_fails('tcl ::vim::command -foo xyz', 'unknown flag: -foo')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
156 call assert_fails('tcl ::vim::command xyz',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
157 \ 'E492: Not an editor command: xyz')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
158
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
159 " With the -quiet option, the error should silently be ignored.
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
160 call assert_equal('', TclEval('::vim::command -quiet xyz'))
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
161
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
162 tcl unset foo
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
163 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
164
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
165 " Test ::vim::window list
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
166 func Test_vim_window_list()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
167 e Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
168 new Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
169 let w2 = TclEval('set ::vim::current(window)')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
170 wincmd j
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
171 let w1 = TclEval('set ::vim::current(window)')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
172
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
173 call assert_equal('2', TclEval('llength [::vim::window list]'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
174 call assert_equal(w2.' '.w1, TclEval('::vim::window list'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
175
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
176 call assert_fails('tcl ::vim::window x', 'unknown option')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
177 call assert_fails('tcl ::vim::window list x',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
178 \ 'wrong # args: should be "::vim::window option"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
179
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
180 %bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
181 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
182
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
183 " Test output messages
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
184 func Test_output()
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
185 call assert_fails('tcl puts vimerr "error #1"', 'error #1')
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
186 call assert_fails('tcl puts stderr "error #2"', 'error #2')
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
187 tcl puts vimout "message #1"
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
188 tcl puts stdout "message #2"
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
189 tcl puts "message #3"
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
190 let messages = split(execute('message'), "\n")
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
191 call assert_equal('message #3', messages[-1])
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
192 call assert_equal('message #2', messages[-2])
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
193 call assert_equal('message #1', messages[-3])
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
194
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
195 call assert_fails('tcl puts',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
196 \ 'wrong # args: should be "puts ?-nonewline? ?channelId? string"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
197 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
198
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
199 " Test $win height (get and set window height)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
200 func Test_window_height()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
201 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
202
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
203 " Test setting window height
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
204 tcl $::vim::current(window) height 2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
205 call assert_equal(2, winheight(0))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
206
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
207 " Test getting window height
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
208 call assert_equal('2', TclEval('$::vim::current(window) height'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
209
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
210 call assert_fails('tcl $::vim::current(window) height 2 2', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
211 call assert_fails('tcl $::vim::current(window) height x',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
212 \ 'expected integer but got "x"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
213 bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
214 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
215
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
216 " Test $win cursor (get and set cursor)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
217 func Test_window_cursor()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
218 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
219 call setline(1, ['line1', 'line2', 'line3', 'line5'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
220 tcl set win $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
221
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
222 tcl $win cursor 2 4
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
223 call assert_equal([0, 2, 4, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
224 call assert_equal('row 2 column 4', TclEval('$win cursor'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
225
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
226 " When setting ::vim::lbase to 0, line/col are counted from 0
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
227 " instead of 1.
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
228 tcl set ::vim::lbase 0
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
229 call assert_equal([0, 2, 4, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
230 call assert_equal('row 1 column 3', TclEval('$win cursor'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
231 tcl $win cursor 2 4
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
232 call assert_equal([0, 3, 5, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
233 call assert_equal('row 2 column 4', TclEval('$win cursor'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
234 tcl set ::vim::lbase 1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
235 call assert_equal('row 3 column 5', TclEval('$win cursor'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
236 call assert_equal([0, 3, 5, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
237
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
238 " test $win cursor {$var}
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
239 call cursor(2, 3)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
240 tcl array set here [$win cursor]
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
241 call assert_equal([0, 2, 3, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
242 call cursor(3, 1)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
243 call assert_equal([0, 3, 1, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
244 tcl $win cursor here
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
245 call assert_equal([0, 2, 3, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
246 call cursor(3, 1)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
247 call assert_equal([0, 3, 1, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
248 tcl $win cursor $here(row) $here(column)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
249 call assert_equal([0, 2, 3, 0], getpos('.'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
250
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
251 call assert_fails('tcl $win cursor 1 1 1', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
252
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
253 tcl unset win here
10763
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 bwipe!
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 endfunc
ae0bbbbe2a38 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
257 " Test $win buffer
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
258 func Test_window_buffer()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
259 new Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
260 new Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
261 tcl set b2 $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
262 tcl set w2 $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
263 wincmd j
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
264 tcl set b1 $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
265 tcl set w1 $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
266
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
267 call assert_equal(TclEval('set b1'), TclEval('$w1 buffer'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
268 call assert_equal(TclEval('set b2'), TclEval('$w2 buffer'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
269 call assert_equal(string(bufnr('Xfoo1')), TclEval('[$w1 buffer] number'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
270 call assert_equal(string(bufnr('Xfoo2')), TclEval('[$w2 buffer] number'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
271
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
272 call assert_fails('tcl $w1 buffer x', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
273
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
274 tcl unset b1 b2 w1 w2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
275 %bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
276 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
277
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
278 " Test $win command
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
279 func Test_window_command()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
280 new Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
281 call setline(1, ['FOObar'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
282 new Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
283 call setline(1, ['fooBAR'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
284 tcl set w2 $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
285 wincmd j
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
286 tcl set w1 $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
287
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
288 tcl $w1 command "norm VU"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
289 tcl $w2 command "norm Vu"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
290 b! Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
291 call assert_equal('FOOBAR', getline(1))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
292 b! Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
293 call assert_equal('foobar', getline(1))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
294
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
295 call assert_fails('tcl $w1 command xyz',
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
296 \ 'E492: Not an editor command: xyz')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
297 tcl $w1 command -quiet xyz
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
298
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
299 tcl unset w1 w2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
300 %bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
301 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
302
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
303 " Test $win expr
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
304 func Test_window_expr()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
305 new Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
306 new Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
307 tcl set w2 $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
308 wincmd j
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
309 tcl set w1 $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
310
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
311 call assert_equal('Xfoo1', TclEval('$w1 expr bufname("%")'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
312 call assert_equal('Xfoo2', TclEval('$w2 expr bufname("%")'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
313
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
314 call assert_fails('tcl $w1 expr', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
315 call assert_fails('tcl $w1 expr x x', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
316
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
317 tcl unset w1 w2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
318 %bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
319 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
320
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
321 " Test $win option
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
322 func Test_window_option()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
323 new Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
324 new Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
325 tcl set w2 $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
326 wincmd j
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
327 tcl set w1 $::vim::current(window)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
328
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
329 " Test setting window option
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
330 tcl $w1 option syntax java
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
331 tcl $w2 option syntax rust
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
332
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
333 call assert_equal('java', &syntax)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
334 wincmd k
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
335 call assert_equal('rust', &syntax)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
336
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
337 " Test getting window option
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
338 call assert_equal('java', TclEval('$w1 option syntax'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
339 call assert_equal('rust', TclEval('$w2 option syntax'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
340
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
341 tcl unset w1 w2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
342 %bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
343 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
344
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
345 " Test $win delcmd {cmd}
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
346 func Test_window_delcmd()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
347 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
348 tcl $::vim::current(window) delcmd [list set msg "window deleted"]
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
349 call assert_fails('tcl set msg', "can't read \"msg\": no such variable")
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
350 q
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
351 call assert_equal('window deleted', TclEval('set msg'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
352
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
353 call assert_fails('tcl $::vim::current(window) delcmd', 'wrong # args')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
354
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
355 tcl unset msg
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
356 bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
357 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
358
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
359 " Test $buf name
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
360 func Test_buffer_name()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
361 " Test buffer name with a named buffer
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
362 new Xfoo
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
363 call assert_equal(expand('%:p'), TclEval('$::vim::current(buffer) name'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
364 bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
365
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
366 " Test buffer name with an unnamed buffer
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
367 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
368 call assert_equal('', TclEval('$::vim::current(buffer) name'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
369
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
370 call assert_fails('tcl $::vim::current(buffer) name x', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
371
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
372 bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
373 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
374
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
375 " Test $buf number
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
376 func Test_buffer_number()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
377 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
378 call assert_equal(string(bufnr('%')), TclEval('$::vim::current(buffer) number'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
379 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
380 call assert_equal(string(bufnr('%')), TclEval('$::vim::current(buffer) number'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
381
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
382 call assert_fails('tcl $::vim::current(buffer) number x', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
383
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
384 %bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
385 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
386
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
387 " Test $buf count and $buf last
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
388 func Test_buffer_count()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
389 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
390 call setline(1, ['one', 'two', 'three'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
391 call assert_equal('3', TclEval('$::vim::current(buffer) count'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
392 call assert_equal('3', TclEval('$::vim::current(buffer) last'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
393
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
394 " Check that $buf count and $buf last differ when ::vim::lbase is 0.
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
395 tcl set ::vim::lbase 0
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
396 call assert_equal('3', TclEval('$::vim::current(buffer) count'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
397 call assert_equal('2', TclEval('$::vim::current(buffer) last'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
398
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
399 call assert_fails('tcl $::vim::current(buffer) count x', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
400 call assert_fails('tcl $::vim::current(buffer) last x', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
401
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
402 tcl set ::vim::lbase 1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
403 bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
404 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
405
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
406 " Test $buf delete (delete line(s) in buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
407 func Test_buffer_delete()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
408 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
409 call setline(1, ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
410 tcl $::vim::current(buffer) delete 4 6
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
411 tcl $::vim::current(buffer) delete 2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
412 call assert_equal(['one', 'three', 'seven', 'eight'], getline(1, '$'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
413
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
414 call assert_fails('tcl $::vim::current(buffer) delete -1', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
415 call assert_fails('tcl $::vim::current(buffer) delete 0', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
416 call assert_fails('tcl $::vim::current(buffer) delete 5', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
417
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
418 call assert_fails('tcl $::vim::current(buffer) delete', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
419 call assert_fails('tcl $::vim::current(buffer) delete 1 2 3', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
420
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
421 bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
422 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
423
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
424 " Test $buf insert (insert line(s) in buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
425 func Test_buffer_insert()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
426 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
427 tcl set buf $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
428 tcl $buf insert 1 "first"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
429 tcl $buf insert 2 "second"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
430 tcl $buf insert 2 "third"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
431 tcl $buf insert 4 "fourth"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
432 tcl $buf insert 1 "fifth"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
433 call assert_equal(['fifth', 'first', 'third', 'second', 'fourth', ''], getline(1, '$'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
434
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
435 call assert_fails('tcl $buf insert -1 "x"', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
436 call assert_fails('tcl $buf insert 0 "x"', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
437 call assert_fails('tcl $buf insert 7 "x"', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
438
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
439 tcl unset buf
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
440 bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
441 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
442
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
443 " Test $buf append (append line in buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
444 func Test_buffer_append()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
445 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
446 tcl set buf $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
447 tcl $buf append 1 "first"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
448 tcl $buf append 2 "second"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
449 tcl $buf append 2 "third"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
450 tcl $buf append 4 "fourth"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
451 tcl $buf append 1 "fifth"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
452 call assert_equal(['', 'fifth', 'first', 'third', 'second', 'fourth'], getline(1, '$'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
453
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
454 call assert_fails('tcl $buf append -1 "x"', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
455 call assert_fails('tcl $buf append 0 "x"', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
456 call assert_fails('tcl $buf append 7 "x"', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
457
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
458 call assert_fails('tcl $buf append', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
459 call assert_fails('tcl $buf append 1 x x', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
460
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
461 tcl unset buf
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
462 bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
463 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
464
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
465 " Test $buf set (replacing line(s) in a buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
466 func Test_buffer_set()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
467 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
468 call setline(1, ['line1', 'line2', 'line3', 'line4', 'line5'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
469 tcl $::vim::current(buffer) set 2 a
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
470 call assert_equal(['line1', 'a', 'line3', 'line4', 'line5'], getline(1, '$'))
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
471
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
472 " Test with fewer replacing lines than replaced lines: lines get deleted.
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
473 tcl $::vim::current(buffer) set 3 4 b
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
474 call assert_equal(['line1', 'a', 'b', 'line5'], getline(1, '$'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
475 tcl $::vim::current(buffer) set 4 3 c
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
476 call assert_equal(['line1', 'a', 'c'], getline(1, '$'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
477
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
478 " Test with more replacing lines than replaced lines: lines get added.
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
479 tcl $::vim::current(buffer) set 2 3 {x y z}
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
480 call assert_equal(['line1', 'x', 'y', 'z'], getline(1, '$'))
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
481 tcl $::vim::current(buffer) set 3 2 {X Y Z}
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
482 call assert_equal(['line1', 'X', 'Y', 'Z', 'z'], getline(1, '$'))
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
483
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
484 call assert_fails('tcl $::vim::current(buffer) set 0 "x"', 'line number out of range')
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
485 call assert_fails('tcl $::vim::current(buffer) set 6 "x"', 'line number out of range')
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
486
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
487 call assert_fails('tcl $::vim::current(buffer) set', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
488 bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
489 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
490
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
491 " Test $buf get (get line(s) from buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
492 func Test_buffer_get()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
493 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
494 call setline(1, ['first line', 'two', 'three', 'last line'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
495 tcl set buf $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
496
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
497 call assert_equal('first line', TclEval('$buf get top'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
498 call assert_equal('first line', TclEval('$buf get begin'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
499 call assert_equal('last line', TclEval('$buf get bottom'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
500 call assert_equal('last line', TclEval('$buf get last'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
501
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
502 call assert_equal('first line', TclEval('$buf get 1'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
503 call assert_equal('two', TclEval('$buf get 2'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
504 call assert_equal('three', TclEval('$buf get 3'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
505 call assert_equal('last line', TclEval('$buf get 4'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
506
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
507 call assert_equal('two three', TclEval('$buf get 2 3'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
508 call assert_equal('two three', TclEval('$buf get 3 2'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
509 call assert_equal('three {last line}', TclEval('$buf get 3 last'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
510
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
511 call assert_fails('tcl $buf get -1', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
512 call assert_fails('tcl $buf get 0', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
513 call assert_fails('tcl $buf get 5', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
514 call assert_fails('tcl $buf get 0 1', 'line number out of range')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
515
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
516 call assert_fails('tcl $::vim::current(buffer) get x', 'expected integer but got "x"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
517 call assert_fails('tcl $::vim::current(buffer) get 1 1 1', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
518
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
519 tcl unset buf
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
520 bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
521 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
522
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
523 " Test $buf mark (get position of a mark)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
524 func Test_buffer_mark()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
525 new
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
526 call setline(1, ['one', 'two', 'three', 'four'])
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
527 /three
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
528 norm! ma
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
529 norm! jllmB
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
530
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
531 call assert_equal('row 3 column 1', TclEval('$::vim::current(buffer) mark a'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
532 call assert_equal('row 4 column 3', TclEval('$::vim::current(buffer) mark B'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
533
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
534 call assert_fails('tcl $::vim::current(buffer) mark /', 'invalid mark name')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
535 call assert_fails('tcl $::vim::current(buffer) mark z', 'mark not set')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
536 call assert_fails('tcl $::vim::current(buffer) mark', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
537
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
538 delmarks aB
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
539 bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
540 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
541
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
542 " Test $buf option (test and set option in context of a buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
543 func Test_buffer_option()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
544 new Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
545 tcl set b1 $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
546 new Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
547 tcl set b2 $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
548
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
549 tcl $b1 option foldcolumn 2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
550 tcl $b2 option foldcolumn 3
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
551
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
552 call assert_equal(3, &foldcolumn)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
553 wincmd j
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
554 call assert_equal(2, &foldcolumn)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
555
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
556 call assert_equal('2', TclEval('$b1 option foldcolumn'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
557 call assert_equal('3', TclEval('$b2 option foldcolumn'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
558
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
559 call assert_fails('tcl $::vim::current(buffer) option', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
560
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
561 set foldcolumn&
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
562 tcl unset b1 b2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
563 %bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
564 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
565
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
566 " Test $buf expr (evaluate vim expression)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
567 func Test_buffer_expr()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
568 new Xfoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
569 norm ifoo1
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
570 tcl set b1 $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
571
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
572 new Xfoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
573 norm ifoo2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
574 tcl set b2 $::vim::current(buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
575
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
576 call assert_equal('foo1', TclEval('$b1 expr getline(1)'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
577 call assert_equal('foo2', TclEval('$b2 expr getline(1)'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
578
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
579 call assert_fails('tcl expr', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
580
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
581 tcl unset b1 b2
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
582 %bwipe!
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
583 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
584
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
585 " Test $buf delcmd {cmd} (command executed when buffer is deleted)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
586 func Test_buffer_delcmd()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
587 new Xfoo
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
588 split
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
589 tcl $::vim::current(buffer) delcmd [list set msg "buffer deleted"]
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
590 q
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
591 call assert_fails('tcl set msg', "can't read \"msg\": no such variable")
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
592 q
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
593 call assert_equal('buffer deleted', TclEval('set msg'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
594
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
595 call assert_fails('tcl $::vim::current(window) delcmd', 'wrong # args')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
596 call assert_fails('tcl $::vim::current(window) delcmd x x', 'wrong # args')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
597
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
598 tcl unset msg
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
599 %bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
600 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
601
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
602 func Test_vim_current()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
603 " Only test errors as ::vim::current(...) is already indirectly
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
604 " tested by many other tests.
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
605 call assert_fails('tcl $::vim::current(buffer)', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
606 call assert_fails('tcl $::vim::current(window)', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
607 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
608
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
609 " Test $buf windows (windows list of a buffer)
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
610 func Test_buffer_windows()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
611 new Xfoo
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
612 split
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
613 new Xbar
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
614 split
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
615 vsplit
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
616
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
617 tcl set bar_wl [$::vim::current(buffer) windows]
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
618 2wincmd j
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
619 tcl set foo_wl [$::vim::current(buffer) windows]
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
620
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
621 call assert_equal('2', TclEval('llength $foo_wl'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
622 call assert_equal('3', TclEval('llength $bar_wl'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
623
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
624 call assert_fails('tcl $::vim::current(buffer) windows x', 'wrong # args:')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
625
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
626 tcl unset bar_wl foo_wl
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
627 %bwipe
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
628 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
629
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
630 " Test :tclfile
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
631 func Test_tclfile()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
632 call delete('Xtcl_file')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
633 call writefile(['set pi [format "%.2f" [expr acos(-1.0)]]'], 'Xtcl_file')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
634 call setfperm('Xtcl_file', 'r-xr-xr-x')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
635
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
636 tclfile Xtcl_file
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
637 call assert_equal('3.14', TclEval('set pi'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
638
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
639 tcl unset pi
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
640 call delete('Xtcl_file')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
641 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
642
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
643 " Test :tclfile with syntax error in tcl script
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
644 func Test_tclfile_error()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
645 call delete('Xtcl_file')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
646 call writefile(['xyz'], 'Xtcl_file')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
647 call setfperm('Xtcl_file', 'r-xr-xr-x')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
648
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
649 call assert_fails('tclfile Xtcl_file', 'invalid command name "xyz"')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
650
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
651 call delete('Xtcl_file')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
652 endfunc
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
653
14294
6c5c8de48152 patch 8.1.0163: insufficient testing for Tcl
Christian Brabandt <cb@256bit.org>
parents: 14268
diff changeset
654 " Test exiting current Tcl interpreter and re-creating one.
14268
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
655 func Test_tcl_exit()
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
656 tcl set foo "foo"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
657 call assert_fails('tcl exit 3', 'E572: exit code 3')
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
658
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
659 " The Tcl interpreter should have been deleted and a new one
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
660 " is re-created with the next :tcl command.
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
661 call assert_fails('tcl set foo', "can't read \"foo\": no such variable")
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
662 tcl set bar "bar"
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
663 call assert_equal('bar', TclEval('set bar'))
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
664
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
665 tcl unset bar
c80acf74e7df patch 8.1.0150: insufficient test coverage for Tcl
Christian Brabandt <cb@256bit.org>
parents: 10763
diff changeset
666 endfunc
14395
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
667
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
668 func Test_set_cursor()
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
669 " Check that setting the cursor position works.
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
670 new
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
671 call setline(1, ['first line', 'second line'])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
672 normal gg
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
673 tcldo $::vim::current(window) cursor 1 5
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
674 call assert_equal([1, 5], [line('.'), col('.')])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
675
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
676 " Check that movement after setting cursor position keeps current column.
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
677 normal j
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
678 call assert_equal([2, 5], [line('.'), col('.')])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 14294
diff changeset
679 endfunc