annotate src/testdir/test_eval_stuff.vim @ 17448:f8cd16838434 v8.1.1722

patch 8.1.1722: error when scriptversion is 2 a making a dictionary access commit https://github.com/vim/vim/commit/61343f0c44c8e71df04918d033e0a744c0b7f8aa Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 20 21:11:13 2019 +0200 patch 8.1.1722: error when scriptversion is 2 a making a dictionary access Problem: Error when scriptversion is 2 a making a dictionary access. Solution: Parse the subscript even when not evaluating the sub-expression. (closes #4704)
author Bram Moolenaar <Bram@vim.org>
date Sat, 20 Jul 2019 21:15:04 +0200
parents d5fa04016df0
children 2029737e6a22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13096
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for various eval things.
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 function s:foo() abort
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 try
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 return [] == 0
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 catch
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 return 1
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 endtry
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endfunction
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 func Test_catch_return_with_error()
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_equal(1, s:foo())
30f9a62f5f51 patch 8.0.1423: error in return not caught by try/catch
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 endfunc
13288
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
14
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
15 func Test_nocatch_restore_silent_emsg()
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
16 silent! try
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
17 throw 1
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
18 catch
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
19 endtry
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
20 echoerr 'wrong'
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
21 let c1 = nr2char(screenchar(&lines, 1))
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
22 let c2 = nr2char(screenchar(&lines, 2))
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
23 let c3 = nr2char(screenchar(&lines, 3))
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
24 let c4 = nr2char(screenchar(&lines, 4))
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
25 let c5 = nr2char(screenchar(&lines, 5))
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
26 call assert_equal('wrong', c1 . c2 . c3 . c4 . c5)
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13096
diff changeset
27 endfunc
13672
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
28
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
29 func Test_mkdir_p()
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
30 call mkdir('Xmkdir/nested', 'p')
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
31 call assert_true(isdirectory('Xmkdir/nested'))
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
32 try
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
33 " Trying to make existing directories doesn't error
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
34 call mkdir('Xmkdir', 'p')
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
35 call mkdir('Xmkdir/nested', 'p')
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
36 catch /E739:/
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
37 call assert_report('mkdir(..., "p") failed for an existing directory')
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
38 endtry
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
39 " 'p' doesn't suppress real errors
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
40 call writefile([], 'Xfile')
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
41 call assert_fails('call mkdir("Xfile", "p")', 'E739')
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
42 call delete('Xfile')
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
43 call delete('Xmkdir', 'rf')
4a1efd1a6018 patch 8.0.1708: mkdir with 'p' flag fails on existing directory
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
44 endfunc
14714
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
45
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
46 func Test_line_continuation()
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
47 let array = [5,
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
48 "\ ignore this
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
49 \ 6,
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
50 "\ more to ignore
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
51 "\ more moreto ignore
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
52 \ ]
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
53 "\ and some more
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
54 call assert_equal([5, 6], array)
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 13672
diff changeset
55 endfunc
15107
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
56
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
57 func Test_E963()
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
58 " These commands used to cause an internal error prior to vim 8.1.0563
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
59 let v_e = v:errors
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
60 let v_o = v:oldfiles
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
61 call assert_fails("let v:errors=''", 'E963:')
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
62 call assert_equal(v_e, v:errors)
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
63 call assert_fails("let v:oldfiles=''", 'E963:')
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
64 call assert_equal(v_o, v:oldfiles)
6344377dc7dc patch 8.1.0564: setting v:errors to wrong type still possible
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
65 endfunc
15456
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15107
diff changeset
66
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15107
diff changeset
67 func Test_for_invalid()
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15107
diff changeset
68 call assert_fails("for x in 99", 'E714:')
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15107
diff changeset
69 call assert_fails("for x in 'asdf'", 'E714:')
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15107
diff changeset
70 call assert_fails("for x in {'a': 9}", 'E714:')
f01eb1aed348 patch 8.1.0736: code for Blob not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15107
diff changeset
71 endfunc
15468
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
72
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
73 func Test_readfile_binary()
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
74 new
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
75 call setline(1, ['one', 'two', 'three'])
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
76 setlocal ff=dos
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
77 write XReadfile
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
78 let lines = readfile('XReadfile')
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
79 call assert_equal(['one', 'two', 'three'], lines)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
80 let lines = readfile('XReadfile', '', 2)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
81 call assert_equal(['one', 'two'], lines)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
82 let lines = readfile('XReadfile', 'b')
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
83 call assert_equal(["one\r", "two\r", "three\r", ""], lines)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
84 let lines = readfile('XReadfile', 'b', 2)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
85 call assert_equal(["one\r", "two\r"], lines)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
86
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
87 bwipe!
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
88 call delete('XReadfile')
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
89 endfunc
15593
e26caeb30026 patch 8.1.0804: crash when setting v:errmsg to empty list
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
90
e26caeb30026 patch 8.1.0804: crash when setting v:errmsg to empty list
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
91 func Test_let_errmsg()
e26caeb30026 patch 8.1.0804: crash when setting v:errmsg to empty list
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
92 call assert_fails('let v:errmsg = []', 'E730:')
e26caeb30026 patch 8.1.0804: crash when setting v:errmsg to empty list
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
93 let v:errmsg = ''
e26caeb30026 patch 8.1.0804: crash when setting v:errmsg to empty list
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
94 call assert_fails('let v:errmsg = []', 'E730:')
e26caeb30026 patch 8.1.0804: crash when setting v:errmsg to empty list
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
95 let v:errmsg = ''
e26caeb30026 patch 8.1.0804: crash when setting v:errmsg to empty list
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
96 endfunc
16219
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
97
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
98 func Test_string_concatenation()
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
99 call assert_equal('ab', 'a'.'b')
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
100 call assert_equal('ab', 'a' .'b')
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
101 call assert_equal('ab', 'a'. 'b')
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
102 call assert_equal('ab', 'a' . 'b')
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
103
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
104 call assert_equal('ab', 'a'..'b')
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
105 call assert_equal('ab', 'a' ..'b')
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
106 call assert_equal('ab', 'a'.. 'b')
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
107 call assert_equal('ab', 'a' .. 'b')
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
108
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
109 let a = 'a'
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
110 let b = 'b'
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
111 let a .= b
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
112 call assert_equal('ab', a)
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
113
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
114 let a = 'a'
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
115 let a.=b
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
116 call assert_equal('ab', a)
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
117
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
118 let a = 'a'
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
119 let a ..= b
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
120 call assert_equal('ab', a)
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
121
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
122 let a = 'a'
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
123 let a..=b
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
124 call assert_equal('ab', a)
bd49e1656c72 patch 8.1.1114: confusing overloaded operator "." for string concatenation
Bram Moolenaar <Bram@vim.org>
parents: 15593
diff changeset
125 endfunc
16223
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
126
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
127 scriptversion 2
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
128 func Test_string_concat_scriptversion2()
16370
235a2b941498 patch 8.1.1190: has('vimscript-3') does not work
Bram Moolenaar <Bram@vim.org>
parents: 16366
diff changeset
129 call assert_true(has('vimscript-2'))
16223
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
130 let a = 'a'
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
131 let b = 'b'
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
132
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
133 call assert_fails('echo a . b', 'E15:')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
134 call assert_fails('let a .= b', 'E985:')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
135 call assert_fails('let vers = 1.2.3', 'E15:')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
136
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
137 if has('float')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
138 let f = .5
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
139 call assert_equal(0.5, f)
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
140 endif
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
141 endfunc
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
142
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
143 scriptversion 1
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
144 func Test_string_concat_scriptversion1()
16370
235a2b941498 patch 8.1.1190: has('vimscript-3') does not work
Bram Moolenaar <Bram@vim.org>
parents: 16366
diff changeset
145 call assert_true(has('vimscript-1'))
16223
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
146 let a = 'a'
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
147 let b = 'b'
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
148
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
149 echo a . b
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
150 let a .= b
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
151 let vers = 1.2.3
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
152 call assert_equal('123', vers)
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
153
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
154 if has('float')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
155 call assert_fails('let f = .5', 'E15:')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
156 endif
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
157 endfunc
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
158
16366
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
159 scriptversion 3
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
160 func Test_vvar_scriptversion3()
16370
235a2b941498 patch 8.1.1190: has('vimscript-3') does not work
Bram Moolenaar <Bram@vim.org>
parents: 16366
diff changeset
161 call assert_true(has('vimscript-3'))
16366
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
162 call assert_fails('echo version', 'E121:')
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
163 call assert_false(exists('version'))
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
164 let version = 1
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
165 call assert_equal(1, version)
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
166 endfunc
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
167
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
168 scriptversion 2
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
169 func Test_vvar_scriptversion2()
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
170 call assert_true(exists('version'))
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
171 echo version
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
172 call assert_fails('let version = 1', 'E46:')
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
173 call assert_equal(v:version, version)
17053
d5fa04016df0 patch 8.1.1526: no numerical value for the patchlevel
Bram Moolenaar <Bram@vim.org>
parents: 16982
diff changeset
174
d5fa04016df0 patch 8.1.1526: no numerical value for the patchlevel
Bram Moolenaar <Bram@vim.org>
parents: 16982
diff changeset
175 call assert_equal(v:version, v:versionlong / 10000)
d5fa04016df0 patch 8.1.1526: no numerical value for the patchlevel
Bram Moolenaar <Bram@vim.org>
parents: 16982
diff changeset
176 call assert_true(v:versionlong > 8011525)
16366
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
177 endfunc
6ee80f3b5ea9 patch 8.1.1188: not all Vim variables require the v: prefix
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
178
17448
f8cd16838434 patch 8.1.1722: error when scriptversion is 2 a making a dictionary access
Bram Moolenaar <Bram@vim.org>
parents: 17053
diff changeset
179 func Test_dict_access_scriptversion2()
f8cd16838434 patch 8.1.1722: error when scriptversion is 2 a making a dictionary access
Bram Moolenaar <Bram@vim.org>
parents: 17053
diff changeset
180 let l:x = {'foo': 1}
f8cd16838434 patch 8.1.1722: error when scriptversion is 2 a making a dictionary access
Bram Moolenaar <Bram@vim.org>
parents: 17053
diff changeset
181
f8cd16838434 patch 8.1.1722: error when scriptversion is 2 a making a dictionary access
Bram Moolenaar <Bram@vim.org>
parents: 17053
diff changeset
182 call assert_false(0 && l:x.foo)
f8cd16838434 patch 8.1.1722: error when scriptversion is 2 a making a dictionary access
Bram Moolenaar <Bram@vim.org>
parents: 17053
diff changeset
183 call assert_true(1 && l:x.foo)
f8cd16838434 patch 8.1.1722: error when scriptversion is 2 a making a dictionary access
Bram Moolenaar <Bram@vim.org>
parents: 17053
diff changeset
184 endfunc
f8cd16838434 patch 8.1.1722: error when scriptversion is 2 a making a dictionary access
Bram Moolenaar <Bram@vim.org>
parents: 17053
diff changeset
185
16223
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
186 func Test_scriptversion()
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
187 call writefile(['scriptversion 9'], 'Xversionscript')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
188 call assert_fails('source Xversionscript', 'E999:')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
189 call delete('Xversionscript')
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16219
diff changeset
190 endfunc
16982
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
191
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
192 " Test fix for issue #4507
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
193 func Test_skip_after_throw()
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
194 try
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
195 throw 'something'
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
196 let x = wincol() || &ts
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
197 catch /something/
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
198 endtry
301f6deea057 patch 8.1.1491: when skipping over code a function call may cause trouble
Bram Moolenaar <Bram@vim.org>
parents: 16370
diff changeset
199 endfunc