annotate src/testdir/test_let.vim @ 26644:2fc1e528e0e1 v8.2.3851

patch 8.2.3851: Vim9: overhead when comparing string, dict or function Commit: https://github.com/vim/vim/commit/265f811f5a2dac81d9698f5202a661a04ed095f1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 19 12:33:05 2021 +0000 patch 8.2.3851: Vim9: overhead when comparing string, dict or function Problem: Vim9: overhead when comparing string, dict or function. Solution: Call the intented compare function directly. Refactor to avoid duplicated code.
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Dec 2021 13:45:03 +0100
parents f142bfebaac1
children 769599ee9f06
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
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_let()
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " 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
5 set runtimepath+=./sautest
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 let Test104#numvar = function('tr')
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 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
8
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 let a = 1
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let b = 2
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 let out = execute('let a b')
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 let s = "\na #1\nb #2"
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_equal(s, out)
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 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
17 let s = "\nb #2"
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_equal(s, out)
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 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
21 let s = "\nb #2\na #1"
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal(s, out)
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 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
25 let s = "\na #1\nb #2"
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 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
27
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
28 " 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
29 let s = 'vim'
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
30 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
31 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
32 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
33
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 list variable
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
35 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
36 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
37 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
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 dict variable
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
41 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
42 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
43 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
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 function reference variable
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
47 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
48 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
49 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
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
18713
baf890fa1621 patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18540
diff changeset
52 let x = 0
baf890fa1621 patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18540
diff changeset
53 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
54 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
55
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
56 " 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
57 let l = [10]
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
58 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
59
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
60 " 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
61 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
62 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
63 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
64
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
65 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
66 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
67 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
68
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
69 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
70 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
71 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
72
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
73 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
74 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
75 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
76
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
77 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
78 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
79 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
80
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
81 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
82 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
83 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
84
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
85 " 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
86 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
87 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
88 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
89
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
90 " 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
91 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
92 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
93 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
94 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
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 logical operators
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
97 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
98 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
99 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
100 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
101 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
102 endfunc
15762
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
103
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
104 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
105 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
106 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
107
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
108 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
109 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
110 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
111
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
112 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
113 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
114 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
115 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
116
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
117 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
118 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
119 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
120 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
121
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
122 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
123 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
124 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
125 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
126
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
127 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
128 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
129 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
130
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
131 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
132 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
133 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
134
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
135 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
136 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
137 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
138
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
139 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
140 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
141 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
142
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
143 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
144 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
145 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
146 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
147
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
148 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
149 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
150 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
151 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
152
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
153 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
154 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
155 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
156 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
157
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
172
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
173 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
174 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
175 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
176
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
177 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
178 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
179 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
180
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
181 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
182 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
183 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
184
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
185 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
186 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
187 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
188
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
189 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
190 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
191 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
192
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
193 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
194 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
195 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
196 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
197
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
198 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
199 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
200 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
201 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
202
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
203 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
204 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
205 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
206 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
207
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
208 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
209 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
210 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
211 endfunction
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
212
dff66c4670b1 patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents: 11961
diff changeset
213 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
214 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224
6b0836727cf3 patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
225 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
226 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
227 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
228 endfunc
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
229
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
230 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
231 let v = 1
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
232 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
233 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
234 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
235 let v = 'hello'
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
236 endfunc
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
237
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
238 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
239 " Terminal code
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
240 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
241 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
242 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
243 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
244
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
245 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
246 " Key code
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
247 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
248 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
249 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
250 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
251 endif
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
252
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21512
diff changeset
253 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
254 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
255 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
256 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
257 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
258 endfunc
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
259
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
260 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
261 let _w = &tw
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
262 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
263 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
264 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
265 let &tw = _w
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
266
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
267 let _w = &fillchars
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
268 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
269 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
270 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
271 let &fillchars = _w
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
272 endfunc
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
273
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
274 " 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
275 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
276 let s = 'abcd'
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
277 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
278
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
279 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
280 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
281
25611
f142bfebaac1 patch 8.2.3342: test for :let errors fails
Bram Moolenaar <Bram@vim.org>
parents: 25036
diff changeset
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 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
292 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
293 let s = "var"
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
294 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
295 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
296 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
297 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
298 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
299 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
300 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
301 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
302 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
303 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
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[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
306 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
307 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
308 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
309 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
310 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
311 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
312 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
313 if has('channel')
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
314 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
315 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
316 endif
24958
21ec48d542a8 patch 8.2.3016: confusing error when expression is followed by comma
Bram Moolenaar <Bram@vim.org>
parents: 24365
diff changeset
317 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
318
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
319 " 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
320 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
321 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
322 \ '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
323 endif
18540
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
324 endfunc
f7bb0e413fe1 patch 8.1.2264: there are two test files for :let
Bram Moolenaar <Bram@vim.org>
parents: 18536
diff changeset
325
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
326 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
327 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
328 try
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
329 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
330 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
331 catch /E488:/
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
332 catch
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
333 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
334 endtry
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
335
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
336 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
337 func WrongSyntax()
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
338 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
339 endfunc
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
340 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
341 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
342 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
343 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
344
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
345 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
346 func MissingEnd()
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
347 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
348 endfunc
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
349 CodeEnd
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
350 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
351 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
352 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
353
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
354 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
355 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
356 TEXTend
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
357 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
358 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
359 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
360
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
361 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
362 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
363 TEXTend
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
364 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
365 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
366 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
367
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
368 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
369 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
370 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
371 endfunc
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
372
17462
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
373 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
374 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
375 Text
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
376 with
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
377 indent
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
378 END
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
379 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
380 endfunc
9088fafff9b3 patch 8.1.1729: heredoc with trim not properly handled in function
Bram Moolenaar <Bram@vim.org>
parents: 17450
diff changeset
381
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
382 " Test for the setting a variable using the heredoc syntax
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
383 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
384 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
385 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
386 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
387 !@#$%^&*()-+_={}|[]\~`:";'<>?,./
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
388 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
389
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
390 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
391
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
392 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
393 Editor
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
394 XXX
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
395 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
396
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
397 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
398 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
399 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
400
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
401 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
402 vim
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
403
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
404 end
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 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
407 END
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
408 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
409
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
410 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
411 Line1
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
412 Line2
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
413 Line3
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
414 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(['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
417
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
418 let var1 =<< trim !!!
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
419 Line1
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
420 line2
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
421 Line3
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
422 !!!
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
423 !!!
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
424 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
425
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
426 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
427 Line1
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
428 XX
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 16708
diff changeset
429 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
430
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
431 " ignore "endfunc"
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
432 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
433 something
16704
a927fdf9a4b0 patch 8.1.1354: getting a list of text lines is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16172
diff changeset
434 endfunc
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
435 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
436 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
437
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
438 " 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
439 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
440 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
441 endfunc
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
442 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
443 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
444
17178
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
445 " not concatenate lines
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
446 let var1 =<< END
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
447 some
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
448 \thing
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
449 \ else
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
450 END
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
451 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
452
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
453 " 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
454 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
455 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
456 python << xx
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
457 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
458 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
459
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
460 " 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
461 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
462 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
463 python << xx
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
464 END
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
465 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
466
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
467 " 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
468 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
469 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
470 app
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
471 E
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
472 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
473
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
474 " 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
475 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
476 something
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
477 app
17450
509542f1fffb patch 8.1.1723: heredoc assignment has no room for new features
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
478 END
16708
98393772bddd patch 8.1.1356: some text in heredoc assignment ends the text
Bram Moolenaar <Bram@vim.org>
parents: 16704
diff changeset
479 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
480
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
481 let check = []
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
482 if 0
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
483 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
484 from heredoc
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
485 END
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
486 endif
9ea364ccf216 patch 8.1.2168: heredoc assignment not skipped in if block
Bram Moolenaar <Bram@vim.org>
parents: 17462
diff changeset
487 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
488
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
489 " unpack assignment
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
490 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
491 x
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
492 \y
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
493 z
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
494 END
c0cd979000f9 patch 8.1.2262: unpack assignment in function not recognized
Bram Moolenaar <Bram@vim.org>
parents: 18348
diff changeset
495 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
496 endfunc
19689
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
497
da98d2ed8dc5 patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
498 " vim: shiftwidth=2 sts=2 expandtab