annotate src/testdir/test_let.vim @ 30035:bbcdc76dcd71 v9.0.0355

patch 9.0.0355: check for uppercase char in autoload name is wrong Commit: https://github.com/vim/vim/commit/6c667bdc9489963102bd6c46b1b73e4d43c034ce Author: thinca <thinca@gmail.com> Date: Fri Sep 2 11:25:37 2022 +0100 patch 9.0.0355: check for uppercase char in autoload name is wrong Problem: Check for uppercase char in autoload name is wrong, it checks the name of the script. Solution: Remove the check. (closes #11031)
author Bram Moolenaar <Bram@vim.org>
date Fri, 02 Sep 2022 12:30:06 +0200
parents 3626ca6a20ea
children f08ed0738f7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11961
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the :let command.
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
3 import './vim9.vim' as v9
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
4
11961
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_let()
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " Test to not autoload when assigning. It causes internal error.
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 set runtimepath+=./sautest
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 let Test104#numvar = function('tr')
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call assert_equal("function('tr')", string(Test104#numvar))
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
30035
bbcdc76dcd71 patch 9.0.0355: check for uppercase char in autoload name is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28813
diff changeset
11 let foo#tr = function('tr')
bbcdc76dcd71 patch 9.0.0355: check for uppercase char in autoload name is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28813
diff changeset
12 call assert_equal("function('tr')", string(foo#tr))
bbcdc76dcd71 patch 9.0.0355: check for uppercase char in autoload name is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28813
diff changeset
13 unlet foo#tr
bbcdc76dcd71 patch 9.0.0355: check for uppercase char in autoload name is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28813
diff changeset
14
11961
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let a = 1
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 let b = 2
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let out = execute('let a b')
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 let s = "\na #1\nb #2"
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(s, out)
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 let out = execute('let {0 == 1 ? "a" : "b"}')
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 let s = "\nb #2"
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call assert_equal(s, out)
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 let out = execute('let {0 == 1 ? "a" : "b"} a')
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 let s = "\nb #2\na #1"
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call assert_equal(s, out)
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 let out = execute('let a {0 == 1 ? "a" : "b"}')
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 let s = "\na #1\nb #2"
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call assert_equal(s, out)
18713
baf890fa1621 patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18540
diff changeset
33
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
34 " Test for displaying a string variable
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
35 let s = 'vim'
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
36 let out = execute('let s')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
37 let s = "\ns vim"
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
38 call assert_equal(s, out)
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
39
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
40 " Test for displaying a list variable
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
41 let l = [1, 2]
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
42 let out = execute('let l')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
43 let s = "\nl [1, 2]"
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
44 call assert_equal(s, out)
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
45
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
46 " Test for displaying a dict variable
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
47 let d = {'k' : 'v'}
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
48 let out = execute('let d')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
49 let s = "\nd {'k': 'v'}"
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
50 call assert_equal(s, out)
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
51
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
52 " Test for displaying a function reference variable
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
53 let F = function('min')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
54 let out = execute('let F')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
55 let s = "\nF *min()"
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
56 call assert_equal(s, out)
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
57
18713
baf890fa1621 patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18540
diff changeset
58 let x = 0
baf890fa1621 patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18540
diff changeset
59 if 0 | let x = 1 | endif
baf890fa1621 patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18540
diff changeset
60 call assert_equal(0, x)
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
61
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
62 " Display a list item using an out of range index
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
63 let l = [10]
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
64 call assert_fails('let l[1]', 'E684:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
65
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
66 " List special variable dictionaries
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
67 let g:Test_Global_Var = 5
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
68 call assert_match("\nTest_Global_Var #5", execute('let g:'))
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
69 unlet g:Test_Global_Var
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
70
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
71 let b:Test_Buf_Var = 8
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
72 call assert_match("\nb:Test_Buf_Var #8", execute('let b:'))
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
73 unlet b:Test_Buf_Var
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
74
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
75 let w:Test_Win_Var = 'foo'
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
76 call assert_equal("\nw:Test_Win_Var foo", execute('let w:'))
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
77 unlet w:Test_Win_Var
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
78
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
79 let t:Test_Tab_Var = 'bar'
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
80 call assert_equal("\nt:Test_Tab_Var bar", execute('let t:'))
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
81 unlet t:Test_Tab_Var
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
82
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
83 let s:Test_Script_Var = [7]
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
84 call assert_match("\ns:Test_Script_Var \\[7]", execute('let s:'))
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
85 unlet s:Test_Script_Var
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
86
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
87 let l:Test_Local_Var = {'k' : 5}
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
88 call assert_match("\nl:Test_Local_Var {'k': 5}", execute('let l:'))
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
89 call assert_match("v:errors []", execute('let v:'))
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
90
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
91 " Test for assigning multiple list items
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
92 let l = [1, 2, 3]
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
93 let [l[0], l[1]] = [10, 20]
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
94 call assert_equal([10, 20, 3], l)
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
95
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
96 " Test for errors in conditional expression
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
97 call assert_fails('let val = [] ? 1 : 2', 'E745:')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
98 call assert_fails('let val = 1 ? 5+ : 6', 'E121:')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
99 call assert_fails('let val = 1 ? 0 : 5+', 'E15:')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
100 call assert_false(exists('val'))
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
101
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
102 " Test for errors in logical operators
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
103 let @a = 'if [] || 0 | let val = 2 | endif'
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
104 call assert_fails('exe @a', 'E745:')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
105 call assert_fails('call feedkeys(":let val = 0 || []\<cr>", "xt")', 'E745:')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
106 call assert_fails('exe "let val = [] && 5"', 'E745:')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
107 call assert_fails('exe "let val = 6 && []"', 'E745:')
11961
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 endfunc
15762
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
109
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
110 func s:set_arg1(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
111 let a:a = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
112 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
113
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
114 func s:set_arg2(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
115 let a:b = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
116 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
117
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
118 func s:set_arg3(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
119 let b = a:
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
120 let b['a'] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
121 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
122
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
123 func s:set_arg4(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
124 let b = a:
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
125 let b['a'] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
126 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
127
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
128 func s:set_arg5(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
129 let b = a:
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
130 let b['a'][0] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
131 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
132
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
133 func s:set_arg6(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
134 let a:a[0] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
135 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
136
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
137 func s:set_arg7(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
138 call extend(a:, {'a': 1})
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
139 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
140
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
141 func s:set_arg8(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
142 call extend(a:, {'b': 1})
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
143 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
144
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
145 func s:set_arg9(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
146 let a:['b'] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
147 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
148
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
149 func s:set_arg10(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
150 let b = a:
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
151 call extend(b, {'a': 1})
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
152 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
153
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
154 func s:set_arg11(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
155 let b = a:
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
156 call extend(b, {'b': 1})
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
157 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
158
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
159 func s:set_arg12(a) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
160 let b = a:
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
161 let b['b'] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
162 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
163
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
164 func Test_let_arg_fail()
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
165 call assert_fails('call s:set_arg1(1)', 'E46:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
166 call assert_fails('call s:set_arg2(1)', 'E461:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
167 call assert_fails('call s:set_arg3(1)', 'E46:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
168 call assert_fails('call s:set_arg4(1)', 'E46:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
169 call assert_fails('call s:set_arg5(1)', 'E46:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
170 call s:set_arg6([0])
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
171 call assert_fails('call s:set_arg7(1)', 'E742:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
172 call assert_fails('call s:set_arg8(1)', 'E742:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
173 call assert_fails('call s:set_arg9(1)', 'E461:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
174 call assert_fails('call s:set_arg10(1)', 'E742:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
175 call assert_fails('call s:set_arg11(1)', 'E742:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
176 call assert_fails('call s:set_arg12(1)', 'E461:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
177 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
178
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
179 func s:set_varg1(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
180 let a:000 = []
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
181 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
182
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
183 func s:set_varg2(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
184 let a:000[0] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
185 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
186
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
187 func s:set_varg3(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
188 let a:000 += [1]
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
189 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
190
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
191 func s:set_varg4(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
192 call add(a:000, 1)
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
193 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
194
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
195 func s:set_varg5(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
196 let a:000[0][0] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
197 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
198
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
199 func s:set_varg6(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
200 let b = a:000
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
201 let b[0] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
202 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
203
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
204 func s:set_varg7(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
205 let b = a:000
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
206 let b += [1]
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
207 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
208
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
209 func s:set_varg8(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
210 let b = a:000
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
211 call add(b, 1)
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
212 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
213
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
214 func s:set_varg9(...) abort
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
215 let b = a:000
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
216 let b[0][0] = 1
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
217 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
218
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
219 func Test_let_varg_fail()
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
220 call assert_fails('call s:set_varg1(1)', 'E46:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
221 call assert_fails('call s:set_varg2(1)', 'E742:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
222 call assert_fails('call s:set_varg3(1)', 'E46:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
223 call assert_fails('call s:set_varg4(1)', 'E742:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
224 call s:set_varg5([0])
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
225 call assert_fails('call s:set_varg6(1)', 'E742:')
15780
5b6c3c7feba8 patch 8.1.0897: can modify a:000 when using a reference
Bram Moolenaar <Bram@vim.org>
parents: 15762
diff changeset
226 call assert_fails('call s:set_varg7(1)', 'E742:')
15762
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
227 call assert_fails('call s:set_varg8(1)', 'E742:')
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
228 call s:set_varg9([0])
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
229 endfunction
16172
6b0836727cf3 patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
230
6b0836727cf3 patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
231 func Test_let_utf8_environment()
6b0836727cf3 patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
232 let $a = 'ĀĒĪŌŪあいうえお'
6b0836727cf3 patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
233 call assert_equal('ĀĒĪŌŪあいうえお', $a)
6b0836727cf3 patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
234 endfunc
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
235
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
236 func Test_let_no_type_checking()
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
237 let v = 1
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
238 let v = [1,2,3]
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
239 let v = {'a': 1, 'b': 2}
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
240 let v = 3.4
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
241 let v = 'hello'
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
242 endfunc
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
243
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
244 func Test_let_termcap()
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
245 " Terminal code
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
246 let old_t_te = &t_te
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
247 let &t_te = "\<Esc>[yes;"
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
248 call assert_match('t_te.*^[[yes;', execute("set termcap"))
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
249 let &t_te = old_t_te
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
250
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
251 if exists("+t_k1")
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
252 " Key code
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
253 let old_t_k1 = &t_k1
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
254 let &t_k1 = "that"
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
255 call assert_match('t_k1.*that', execute("set termcap"))
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
256 let &t_k1 = old_t_k1
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
257 endif
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
258
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21512
diff changeset
259 call assert_fails('let x = &t_xx', 'E113:')
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
260 let &t_xx = "yes"
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
261 call assert_equal("yes", &t_xx)
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
262 let &t_xx = ""
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21512
diff changeset
263 call assert_fails('let x = &t_xx', 'E113:')
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
264 endfunc
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
265
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
266 func Test_let_option_error()
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
267 let _w = &tw
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
268 let &tw = 80
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21512
diff changeset
269 call assert_fails('let &tw .= 1', 'E734:')
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
270 call assert_equal(80, &tw)
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
271 let &tw = _w
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
272
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
273 let _w = &fillchars
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
274 let &fillchars = "vert:|"
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21512
diff changeset
275 call assert_fails('let &fillchars += "diff:-"', 'E734:')
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
276 call assert_equal("vert:|", &fillchars)
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
277 let &fillchars = _w
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
278 endfunc
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
279
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
280 " Errors with the :let statement
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
281 func Test_let_errors()
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
282 let s = 'abcd'
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
283 call assert_fails('let s[1] = 5', 'E689:')
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
284
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
285 let l = [1, 2, 3]
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
286 call assert_fails('let l[:] = 5', 'E709:')
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
287
25611
f142bfebaac1 patch 8.2.3342: test for :let errors fails
Bram Moolenaar <Bram@vim.org>
parents: 25036
diff changeset
288 call assert_fails('let x:lnum=5', ['E121:', 'E121:'])
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
289 call assert_fails('let v:=5', 'E461:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
290 call assert_fails('let [a]', 'E474:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
291 call assert_fails('let [a, b] = [', 'E697:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
292 call assert_fails('let [a, b] = [10, 20', 'E696:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
293 call assert_fails('let [a, b] = 10', 'E714:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
294 call assert_fails('let [a, , b] = [10, 20]', 'E475:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
295 call assert_fails('let [a, b&] = [10, 20]', 'E475:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
296 call assert_fails('let $ = 10', 'E475:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
297 call assert_fails('let $FOO[1] = "abc"', 'E18:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
298 call assert_fails('let &buftype[1] = "nofile"', 'E18:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
299 let s = "var"
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
300 let var = 1
20128
0b35a7ffceb2 patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
301 call assert_fails('let var += [1,2]', 'E734:')
25036
3b8d3b383fd6 patch 8.2.3055: strange error for assigning to "x.key" on non-dictionary
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
302 call assert_fails('let {s}.1 = 2', 'E1203:')
19724
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
303 call assert_fails('let a[1] = 5', 'E121:')
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
304 let l = [[1,2]]
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
305 call assert_fails('let l[:][0] = [5]', 'E708:')
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
306 let d = {'k' : 4}
21447
369cde0d5771 patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
307 call assert_fails('let d.# = 5', 'E488:')
24365
f2bd92589670 patch 8.2.2723: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 23185
diff changeset
308 call assert_fails('let d.m += 5', 'E716:')
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
309 call assert_fails('let m = d[{]', 'E15:')
19724
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
310 let l = [1, 2]
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
311 call assert_fails('let l[2] = 0', 'E684:')
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
312 call assert_fails('let l[0:1] = [1, 2, 3]', 'E710:')
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
313 call assert_fails('let l[-2:-3] = [3, 4]', 'E684:')
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
314 call assert_fails('let l[0:4] = [5, 6]', 'E711:')
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
315 call assert_fails('let l -= 2', 'E734:')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
316 call assert_fails('let l += 2', 'E734:')
20128
0b35a7ffceb2 patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
317 call assert_fails('let g:["a;b"] = 10', 'E461:')
0b35a7ffceb2 patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
318 call assert_fails('let g:.min = function("max")', 'E704:')
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
319 if has('channel')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
320 let ch = test_null_channel()
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
321 call assert_fails('let ch += 1', 'E734:')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
322 endif
24958
21ec48d542a8 patch 8.2.3016: confusing error when expression is followed by comma
Bram Moolenaar <Bram@vim.org>
parents: 24365
diff changeset
323 call assert_fails('let name = "a" .. "b",', 'E488: Trailing characters: ,')
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
324
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
325 " This test works only when the language is English
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
326 if v:lang == "C" || v:lang =~ '^[Ee]n'
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
327 call assert_fails('let [a ; b;] = [10, 20]',
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
328 \ 'Double ; in list of variables')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
329 endif
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
330 endfunc
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
331
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
332 func Test_let_heredoc_fails()
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
333 call assert_fails('let v =<< marker', 'E991:')
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
334 try
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
335 exe "let v =<< TEXT | abc | TEXT"
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
336 call assert_report('No exception thrown')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
337 catch /E488:/
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
338 catch
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
339 call assert_report("Caught exception: " .. v:exception)
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
340 endtry
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
341
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
342 let text =<< trim END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
343 func WrongSyntax()
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
344 let v =<< that there
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
345 endfunc
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
346 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
347 call writefile(text, 'XheredocFail')
23185
055fa9db6f39 patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
348 call assert_fails('source XheredocFail', 'E1145:')
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
349 call delete('XheredocFail')
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
350
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
351 let text =<< trim CodeEnd
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
352 func MissingEnd()
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
353 let v =<< END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
354 endfunc
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
355 CodeEnd
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
356 call writefile(text, 'XheredocWrong')
23185
055fa9db6f39 patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
357 call assert_fails('source XheredocWrong', 'E1145:')
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
358 call delete('XheredocWrong')
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
359
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
360 let text =<< trim TEXTend
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
361 let v =<< " comment
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
362 TEXTend
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
363 call writefile(text, 'XheredocNoMarker')
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
364 call assert_fails('source XheredocNoMarker', 'E172:')
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
365 call delete('XheredocNoMarker')
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
366
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
367 let text =<< trim TEXTend
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
368 let v =<< text
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
369 TEXTend
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
370 call writefile(text, 'XheredocBadMarker')
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
371 call assert_fails('source XheredocBadMarker', 'E221:')
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
372 call delete('XheredocBadMarker')
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
373
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
374 call writefile(['let v =<< TEXT', 'abc'], 'XheredocMissingMarker')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
375 call assert_fails('source XheredocMissingMarker', 'E990:')
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
376 call delete('XheredocMissingMarker')
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
377 endfunc
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
378
17462
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
379 func Test_let_heredoc_trim_no_indent_marker()
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
380 let text =<< trim END
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
381 Text
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
382 with
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
383 indent
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
384 END
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
385 call assert_equal(['Text', 'with', 'indent'], text)
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
386 endfunc
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
387
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
388 func Test_let_interpolated()
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
389 call assert_equal('{text}', $'{{text}}')
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
390 call assert_equal('{{text}}', $'{{{{text}}}}')
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
391 let text = 'text'
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
392 call assert_equal('text{{', $'{text .. "{{"}')
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
393 call assert_equal('text{{', $"{text .. '{{'}")
28813
3626ca6a20ea patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents: 28718
diff changeset
394 call assert_equal('text{{', $'{text .. '{{'}')
3626ca6a20ea patch 8.2.4930: interpolated string expression requires escaping
Bram Moolenaar <Bram@vim.org>
parents: 28718
diff changeset
395 call assert_equal('text{{', $"{text .. "{{"}")
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
396 endfunc
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
397
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
398 " Test for the setting a variable using the heredoc syntax.
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
399 " Keep near the end, this messes up highlighting.
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
400 func Test_let_heredoc()
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
401 let var1 =<< END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
402 Some sample text
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
403 Text with indent
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
404 !@#$%^&*()-+_={}|[]\~`:";'<>?,./
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
405 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
406
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
407 call assert_equal(["Some sample text", "\tText with indent", " !@#$%^&*()-+_={}|[]\\~`:\";'<>?,./"], var1)
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
408
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
409 let var2 =<< XXX
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
410 Editor
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
411 XXX
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
412 call assert_equal(['Editor'], var2)
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
413
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
414 let var3 =<<END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
415 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
416 call assert_equal([], var3)
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
417
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
418 let var3 =<<END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
419 vim
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
420
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
421 end
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
422 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
423 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
424 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
425 call assert_equal(['vim', '', 'end', ' END', 'END '], var3)
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
426
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
427 let var1 =<< trim END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
428 Line1
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
429 Line2
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
430 Line3
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
431 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
432 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
433 call assert_equal(['Line1', ' Line2', "\tLine3", ' END'], var1)
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
434
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
435 let var1 =<< trim !!!
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
436 Line1
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
437 line2
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
438 Line3
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
439 !!!
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
440 !!!
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
441 call assert_equal(['Line1', ' line2', "\tLine3", '!!!',], var1)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
442
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
443 let var1 =<< trim XX
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
444 Line1
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
445 XX
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
446 call assert_equal(['Line1'], var1)
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
447
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
448 " ignore "endfunc"
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
449 let var1 =<< END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
450 something
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
451 endfunc
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
452 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
453 call assert_equal(['something', 'endfunc'], var1)
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
454
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
455 " ignore "endfunc" with trim
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
456 let var1 =<< trim END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
457 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
458 endfunc
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
459 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
460 call assert_equal(['something', 'endfunc'], var1)
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
461
17178
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
462 " not concatenate lines
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
463 let var1 =<< END
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
464 some
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
465 \thing
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
466 \ else
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
467 END
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
468 call assert_equal(['some', ' \thing', ' \ else'], var1)
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
469
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
470 " ignore "python << xx"
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
471 let var1 =<<END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
472 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
473 python << xx
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
474 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
475 call assert_equal(['something', 'python << xx'], var1)
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
476
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
477 " ignore "python << xx" with trim
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
478 let var1 =<< trim END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
479 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
480 python << xx
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
481 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
482 call assert_equal(['something', 'python << xx'], var1)
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
483
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
484 " ignore "append"
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
485 let var1 =<< E
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
486 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
487 app
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
488 E
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
489 call assert_equal(['something', 'app'], var1)
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
490
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
491 " ignore "append" with trim
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
492 let var1 =<< trim END
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
493 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
494 app
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
495 END
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
496 call assert_equal(['something', 'app'], var1)
18348
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
497
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
498 let check = []
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
499 if 0
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
500 let check =<< trim END
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
501 from heredoc
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
502 END
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
503 endif
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
504 call assert_equal([], check)
18536
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
505
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
506 " unpack assignment
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
507 let [a, b, c] =<< END
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
508 x
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
509 \y
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
510 z
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
511 END
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
512 call assert_equal([' x', ' \y', ' z'], [a, b, c])
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
513 endfunc
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
514
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
515 " Test for evaluating Vim expressions in a heredoc using {expr}
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
516 " Keep near the end, this messes up highlighting.
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
517 func Test_let_heredoc_eval()
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
518 let str = ''
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
519 let code =<< trim eval END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
520 let a = {5 + 10}
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
521 let b = {min([10, 6])} + {max([4, 6])}
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
522 {str}
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
523 let c = "abc{str}d"
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
524 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
525 call assert_equal(['let a = 15', 'let b = 6 + 6', '', 'let c = "abcd"'], code)
28633
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
526
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
527 let $TESTVAR = "Hello"
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
528 let code =<< eval trim END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
529 let s = "{$TESTVAR}"
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
530 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
531 call assert_equal(['let s = "Hello"'], code)
28633
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
532
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
533 let code =<< eval END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
534 let s = "{$TESTVAR}"
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
535 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
536 call assert_equal([' let s = "Hello"'], code)
28633
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
537
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
538 let a = 10
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
539 let data =<< eval END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
540 {a}
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
541 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
542 call assert_equal(['10'], data)
28633
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
543
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
544 let x = 'X'
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
545 let code =<< eval trim END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
546 let a = {{abc}}
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
547 let b = {x}
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
548 let c = {{
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
549 END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
550 call assert_equal(['let a = {abc}', 'let b = X', 'let c = {'], code)
28633
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
551
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
552 let code = 'xxx'
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
553 let code =<< eval trim END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
554 let n = {5 +
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
555 6}
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
556 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
557 call assert_equal('xxx', code)
28633
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
558
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
559 let code =<< eval trim END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
560 let n = {min([1, 2]} + {max([3, 4])}
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
561 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
562 call assert_equal('xxx', code)
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
563
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
564 let lines =<< trim LINES
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
565 let text =<< eval trim END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
566 let b = {
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
567 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
568 LINES
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
569 call v9.CheckScriptFailure(lines, 'E1279:')
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
570
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
571 let lines =<< trim LINES
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
572 let text =<< eval trim END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
573 let b = {abc
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
574 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
575 LINES
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
576 call v9.CheckScriptFailure(lines, 'E1279:')
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
577
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
578 let lines =<< trim LINES
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
579 let text =<< eval trim END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
580 let b = {}
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
581 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
582 LINES
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
583 call v9.CheckScriptFailure(lines, 'E15:')
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
584
28633
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
585 " skipped heredoc
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
586 if 0
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
587 let msg =<< trim eval END
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
588 n is: {n}
28633
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
589 END
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
590 endif
7a39c20a42fa patch 8.2.4840: heredoc expression evaluated even when skipping
Bram Moolenaar <Bram@vim.org>
parents: 28491
diff changeset
591
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
592 " Test for sourcing a script containing a heredoc with invalid expression.
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
593 " Variable assignment should fail, if expression evaluation fails
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
594 new
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
595 let g:Xvar = 'test'
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
596 let g:b = 10
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
597 let lines =<< trim END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
598 let Xvar =<< eval CODE
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
599 let a = 1
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
600 let b = {5+}
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
601 let c = 2
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
602 CODE
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
603 let g:Count += 1
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
604 END
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
605 call setline(1, lines)
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
606 let g:Count = 0
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
607 call assert_fails('source', 'E15:')
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
608 call assert_equal(1, g:Count)
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
609 call setline(3, 'let b = {abc}')
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
610 call assert_fails('source', 'E121:')
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
611 call assert_equal(2, g:Count)
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28633
diff changeset
612 call setline(3, 'let b = {abc} + {min([9, 4])} + 2')
28491
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
613 call assert_fails('source', 'E121:')
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
614 call assert_equal(3, g:Count)
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
615 call assert_equal('test', g:Xvar)
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
616 call assert_equal(10, g:b)
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
617 bw!
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
618 endfunc
769599ee9f06 patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents: 25611
diff changeset
619
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
620 " vim: shiftwidth=2 sts=2 expandtab