Mercurial > vim
comparison src/testdir/test_vim9_expr.vim @ 21863:809b1e7fbd72 v8.2.1481
patch 8.2.1481: Vim9: line number reported with error may be wrong
Commit: https://github.com/vim/vim/commit/3affe7a6c6fc813f5d29857933ee6aca0b9c7bd6
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 18 20:34:13 2020 +0200
patch 8.2.1481: Vim9: line number reported with error may be wrong
Problem: Vim9: line number reported with error may be wrong.
Solution: Check line number in tests.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 18 Aug 2020 20:45:03 +0200 |
parents | 3e5d0832a2e7 |
children | c16af87df654 |
comparison
equal
deleted
inserted
replaced
21862:961d816a163f | 21863:809b1e7fbd72 |
---|---|
91 # check white space | 91 # check white space |
92 lines =<< trim END | 92 lines =<< trim END |
93 vim9script | 93 vim9script |
94 let var = v:true?1:2 | 94 let var = v:true?1:2 |
95 END | 95 END |
96 CheckScriptFailure(lines, 'E1004:') | 96 CheckScriptFailure(lines, 'E1004:', 2) |
97 lines =<< trim END | 97 lines =<< trim END |
98 vim9script | 98 vim9script |
99 let var = v:true? 1 : 2 | 99 let var = v:true? 1 : 2 |
100 END | 100 END |
101 CheckScriptFailure(lines, 'E1004:') | 101 CheckScriptFailure(lines, 'E1004:', 2) |
102 lines =<< trim END | 102 lines =<< trim END |
103 vim9script | 103 vim9script |
104 let var = v:true ?1 : 2 | 104 let var = v:true ?1 : 2 |
105 END | 105 END |
106 CheckScriptFailure(lines, 'E1004:') | 106 CheckScriptFailure(lines, 'E1004:', 2) |
107 lines =<< trim END | 107 lines =<< trim END |
108 vim9script | 108 vim9script |
109 let var = v:true ? 1: 2 | 109 let var = v:true ? 1: 2 |
110 END | 110 END |
111 CheckScriptFailure(lines, 'E1004:') | 111 CheckScriptFailure(lines, 'E1004:', 2) |
112 lines =<< trim END | 112 lines =<< trim END |
113 vim9script | 113 vim9script |
114 let var = v:true ? 1 :2 | 114 let var = v:true ? 1 :2 |
115 END | 115 END |
116 CheckScriptFailure(lines, 'E1004:') | 116 CheckScriptFailure(lines, 'E1004:', 2) |
117 enddef | 117 enddef |
118 | 118 |
119 func Test_expr1_fails() | 119 func Test_expr1_fails() |
120 call CheckDefFailure(["let x = 1 ? 'one'"], "Missing ':' after '?'") | 120 call CheckDefFailure(["let x = 1 ? 'one'"], "Missing ':' after '?'", 1) |
121 call CheckDefFailure(["let x = 1 ? 'one' : xxx"], "E1001:") | 121 call CheckDefFailure(["let x = 1 ? 'one' : xxx"], "E1001:", 1) |
122 | 122 |
123 let msg = "white space required before and after '?'" | 123 let msg = "white space required before and after '?'" |
124 call CheckDefFailure(["let x = 1? 'one' : 'two'"], msg) | 124 call CheckDefFailure(["let x = 1? 'one' : 'two'"], msg, 1) |
125 call CheckDefFailure(["let x = 1 ?'one' : 'two'"], msg) | 125 call CheckDefFailure(["let x = 1 ?'one' : 'two'"], msg, 1) |
126 call CheckDefFailure(["let x = 1?'one' : 'two'"], msg) | 126 call CheckDefFailure(["let x = 1?'one' : 'two'"], msg, 1) |
127 | 127 |
128 let msg = "white space required before and after ':'" | 128 let msg = "white space required before and after ':'" |
129 call CheckDefFailure(["let x = 1 ? 'one': 'two'"], msg) | 129 call CheckDefFailure(["let x = 1 ? 'one': 'two'"], msg, 1) |
130 call CheckDefFailure(["let x = 1 ? 'one' :'two'"], msg) | 130 call CheckDefFailure(["let x = 1 ? 'one' :'two'"], msg, 1) |
131 call CheckDefFailure(["let x = 1 ? 'one':'two'"], msg) | 131 call CheckDefFailure(["let x = 1 ? 'one':'two'"], msg, 1) |
132 | 132 |
133 " missing argument detected even when common type is used | 133 " missing argument detected even when common type is used |
134 call CheckDefFailure([ | 134 call CheckDefFailure([ |
135 \ 'let X = FuncOne', | 135 \ 'let X = FuncOne', |
136 \ 'let Y = FuncTwo', | 136 \ 'let Y = FuncTwo', |
137 \ 'let Z = g:cond ? FuncOne : FuncTwo', | 137 \ 'let Z = g:cond ? FuncOne : FuncTwo', |
138 \ 'Z()'], 'E119:') | 138 \ 'Z()'], 'E119:', 4) |
139 endfunc | 139 endfunc |
140 | 140 |
141 " TODO: define inside test function | 141 " TODO: define inside test function |
142 def Record(val: any): any | 142 def Record(val: any): any |
143 g:vals->add(val) | 143 g:vals->add(val) |
205 # check white space | 205 # check white space |
206 lines =<< trim END | 206 lines =<< trim END |
207 vim9script | 207 vim9script |
208 let var = v:true||v:true | 208 let var = v:true||v:true |
209 END | 209 END |
210 CheckScriptFailure(lines, 'E1004:') | 210 CheckScriptFailure(lines, 'E1004:', 2) |
211 lines =<< trim END | 211 lines =<< trim END |
212 vim9script | 212 vim9script |
213 let var = v:true ||v:true | 213 let var = v:true ||v:true |
214 END | 214 END |
215 CheckScriptFailure(lines, 'E1004:') | 215 CheckScriptFailure(lines, 'E1004:', 2) |
216 lines =<< trim END | 216 lines =<< trim END |
217 vim9script | 217 vim9script |
218 let var = v:true|| v:true | 218 let var = v:true|| v:true |
219 END | 219 END |
220 CheckScriptFailure(lines, 'E1004:') | 220 CheckScriptFailure(lines, 'E1004:', 2) |
221 | 221 |
222 # check keeping the value | 222 # check keeping the value |
223 lines =<< trim END | 223 lines =<< trim END |
224 vim9script | 224 vim9script |
225 assert_equal(2, 2 || 0) | 225 assert_equal(2, 2 || 0) |
252 CheckScriptSuccess(lines) | 252 CheckScriptSuccess(lines) |
253 enddef | 253 enddef |
254 | 254 |
255 func Test_expr2_fails() | 255 func Test_expr2_fails() |
256 let msg = "white space required before and after '||'" | 256 let msg = "white space required before and after '||'" |
257 call CheckDefFailure(["let x = 1||2"], msg) | 257 call CheckDefFailure(["let x = 1||2"], msg, 1) |
258 call CheckDefFailure(["let x = 1 ||2"], msg) | 258 call CheckDefFailure(["let x = 1 ||2"], msg, 1) |
259 call CheckDefFailure(["let x = 1|| 2"], msg) | 259 call CheckDefFailure(["let x = 1|| 2"], msg, 1) |
260 | 260 |
261 call CheckDefFailure(["let x = 1 || xxx"], 'E1001:') | 261 call CheckDefFailure(["let x = 1 || xxx"], 'E1001:', 1) |
262 endfunc | 262 endfunc |
263 | 263 |
264 " test && | 264 " test && |
265 def Test_expr3() | 265 def Test_expr3() |
266 assert_equal(0, 2 && 0) | 266 assert_equal(0, 2 && 0) |
326 # check white space | 326 # check white space |
327 lines =<< trim END | 327 lines =<< trim END |
328 vim9script | 328 vim9script |
329 let var = v:true&&v:true | 329 let var = v:true&&v:true |
330 END | 330 END |
331 CheckScriptFailure(lines, 'E1004:') | 331 CheckScriptFailure(lines, 'E1004:', 2) |
332 lines =<< trim END | 332 lines =<< trim END |
333 vim9script | 333 vim9script |
334 let var = v:true &&v:true | 334 let var = v:true &&v:true |
335 END | 335 END |
336 CheckScriptFailure(lines, 'E1004:') | 336 CheckScriptFailure(lines, 'E1004:', 2) |
337 lines =<< trim END | 337 lines =<< trim END |
338 vim9script | 338 vim9script |
339 let var = v:true&& v:true | 339 let var = v:true&& v:true |
340 END | 340 END |
341 CheckScriptFailure(lines, 'E1004:') | 341 CheckScriptFailure(lines, 'E1004:', 2) |
342 | 342 |
343 # check keeping the value | 343 # check keeping the value |
344 lines =<< trim END | 344 lines =<< trim END |
345 vim9script | 345 vim9script |
346 assert_equal(0, 2 && 0) | 346 assert_equal(0, 2 && 0) |
377 CheckScriptSuccess(lines) | 377 CheckScriptSuccess(lines) |
378 enddef | 378 enddef |
379 | 379 |
380 func Test_expr3_fails() | 380 func Test_expr3_fails() |
381 let msg = "white space required before and after '&&'" | 381 let msg = "white space required before and after '&&'" |
382 call CheckDefFailure(["let x = 1&&2"], msg) | 382 call CheckDefFailure(["let x = 1&&2"], msg, 1) |
383 call CheckDefFailure(["let x = 1 &&2"], msg) | 383 call CheckDefFailure(["let x = 1 &&2"], msg, 1) |
384 call CheckDefFailure(["let x = 1&& 2"], msg) | 384 call CheckDefFailure(["let x = 1&& 2"], msg, 1) |
385 endfunc | 385 endfunc |
386 | 386 |
387 " global variables to use for tests with the "any" type | 387 " global variables to use for tests with the "any" type |
388 let atrue = v:true | 388 let atrue = v:true |
389 let afalse = v:false | 389 let afalse = v:false |
455 set ignorecase | 455 set ignorecase |
456 assert_equal(false, 'abc' == 'ABC') | 456 assert_equal(false, 'abc' == 'ABC') |
457 assert_equal(false, 'abc' ==# 'ABC') | 457 assert_equal(false, 'abc' ==# 'ABC') |
458 set noignorecase | 458 set noignorecase |
459 | 459 |
460 call CheckDefFailure(["let x = 'a' == xxx"], 'E1001:') | 460 call CheckDefFailure(["let x = 'a' == xxx"], 'E1001:', 1) |
461 | 461 |
462 let bb = 0z3f | 462 let bb = 0z3f |
463 assert_equal(true, 0z3f == bb) | 463 assert_equal(true, 0z3f == bb) |
464 assert_equal(false, bb == 0z4f) | 464 assert_equal(false, bb == 0z4f) |
465 assert_equal(true, g:ablob == 0z01ab) | 465 assert_equal(true, g:ablob == 0z01ab) |
755 # spot check mismatching types | 755 # spot check mismatching types |
756 lines =<< trim END | 756 lines =<< trim END |
757 vim9script | 757 vim9script |
758 echo '' == 0 | 758 echo '' == 0 |
759 END | 759 END |
760 CheckScriptFailure(lines, 'E1072:') | 760 CheckScriptFailure(lines, 'E1072:', 2) |
761 | 761 |
762 lines =<< trim END | 762 lines =<< trim END |
763 vim9script | 763 vim9script |
764 echo v:true > v:false | 764 echo v:true > v:false |
765 END | 765 END |
766 CheckScriptFailure(lines, 'Cannot compare bool with bool') | 766 CheckScriptFailure(lines, 'Cannot compare bool with bool', 2) |
767 | 767 |
768 lines =<< trim END | 768 lines =<< trim END |
769 vim9script | 769 vim9script |
770 echo 123 is 123 | 770 echo 123 is 123 |
771 END | 771 END |
772 CheckScriptFailure(lines, 'Cannot use "is" with number') | 772 CheckScriptFailure(lines, 'Cannot use "is" with number', 2) |
773 | 773 |
774 # check 'ignorecase' not being used | 774 # check 'ignorecase' not being used |
775 lines =<< trim END | 775 lines =<< trim END |
776 vim9script | 776 vim9script |
777 set ignorecase | 777 set ignorecase |
793 # check missing white space | 793 # check missing white space |
794 lines =<< trim END | 794 lines =<< trim END |
795 vim9script | 795 vim9script |
796 echo 2>3 | 796 echo 2>3 |
797 END | 797 END |
798 CheckScriptFailure(lines, 'E1004:') | 798 CheckScriptFailure(lines, 'E1004:', 2) |
799 lines =<< trim END | 799 lines =<< trim END |
800 vim9script | 800 vim9script |
801 echo 2 >3 | 801 echo 2 >3 |
802 END | 802 END |
803 CheckScriptFailure(lines, 'E1004:') | 803 CheckScriptFailure(lines, 'E1004:', 2) |
804 lines =<< trim END | 804 lines =<< trim END |
805 vim9script | 805 vim9script |
806 echo 2> 3 | 806 echo 2> 3 |
807 END | 807 END |
808 CheckScriptFailure(lines, 'E1004:') | 808 CheckScriptFailure(lines, 'E1004:', 2) |
809 lines =<< trim END | 809 lines =<< trim END |
810 vim9script | 810 vim9script |
811 echo 2!=3 | 811 echo 2!=3 |
812 END | 812 END |
813 CheckScriptFailure(lines, 'E1004:') | 813 CheckScriptFailure(lines, 'E1004:', 2) |
814 lines =<< trim END | 814 lines =<< trim END |
815 vim9script | 815 vim9script |
816 echo 2 !=3 | 816 echo 2 !=3 |
817 END | 817 END |
818 CheckScriptFailure(lines, 'E1004:') | 818 CheckScriptFailure(lines, 'E1004:', 2) |
819 lines =<< trim END | 819 lines =<< trim END |
820 vim9script | 820 vim9script |
821 echo 2!= 3 | 821 echo 2!= 3 |
822 END | 822 END |
823 CheckScriptFailure(lines, 'E1004:') | 823 CheckScriptFailure(lines, 'E1004:', 2) |
824 | 824 |
825 lines =<< trim END | 825 lines =<< trim END |
826 vim9script | 826 vim9script |
827 echo len('xxx') == 3 | 827 echo len('xxx') == 3 |
828 END | 828 END |
836 CheckScriptSuccess(lines) | 836 CheckScriptSuccess(lines) |
837 enddef | 837 enddef |
838 | 838 |
839 func Test_expr4_fails() | 839 func Test_expr4_fails() |
840 let msg = "white space required before and after '>'" | 840 let msg = "white space required before and after '>'" |
841 call CheckDefFailure(["let x = 1>2"], msg) | 841 call CheckDefFailure(["let x = 1>2"], msg, 1) |
842 call CheckDefFailure(["let x = 1 >2"], msg) | 842 call CheckDefFailure(["let x = 1 >2"], msg, 1) |
843 call CheckDefFailure(["let x = 1> 2"], msg) | 843 call CheckDefFailure(["let x = 1> 2"], msg, 1) |
844 | 844 |
845 let msg = "white space required before and after '=='" | 845 let msg = "white space required before and after '=='" |
846 call CheckDefFailure(["let x = 1==2"], msg) | 846 call CheckDefFailure(["let x = 1==2"], msg, 1) |
847 call CheckDefFailure(["let x = 1 ==2"], msg) | 847 call CheckDefFailure(["let x = 1 ==2"], msg, 1) |
848 call CheckDefFailure(["let x = 1== 2"], msg) | 848 call CheckDefFailure(["let x = 1== 2"], msg, 1) |
849 | 849 |
850 let msg = "white space required before and after 'is'" | 850 let msg = "white space required before and after 'is'" |
851 call CheckDefFailure(["let x = '1'is'2'"], msg) | 851 call CheckDefFailure(["let x = '1'is'2'"], msg, 1) |
852 call CheckDefFailure(["let x = '1' is'2'"], msg) | 852 call CheckDefFailure(["let x = '1' is'2'"], msg, 1) |
853 call CheckDefFailure(["let x = '1'is '2'"], msg) | 853 call CheckDefFailure(["let x = '1'is '2'"], msg, 1) |
854 | 854 |
855 let msg = "white space required before and after 'isnot'" | 855 let msg = "white space required before and after 'isnot'" |
856 call CheckDefFailure(["let x = '1'isnot'2'"], msg) | 856 call CheckDefFailure(["let x = '1'isnot'2'"], msg, 1) |
857 call CheckDefFailure(["let x = '1' isnot'2'"], msg) | 857 call CheckDefFailure(["let x = '1' isnot'2'"], msg, 1) |
858 call CheckDefFailure(["let x = '1'isnot '2'"], msg) | 858 call CheckDefFailure(["let x = '1'isnot '2'"], msg, 1) |
859 | 859 |
860 call CheckDefFailure(["let x = 1 is# 2"], 'E15:') | 860 call CheckDefFailure(["let x = 1 is# 2"], 'E15:', 1) |
861 call CheckDefFailure(["let x = 1 is? 2"], 'E15:') | 861 call CheckDefFailure(["let x = 1 is? 2"], 'E15:', 1) |
862 call CheckDefFailure(["let x = 1 isnot# 2"], 'E15:') | 862 call CheckDefFailure(["let x = 1 isnot# 2"], 'E15:', 1) |
863 call CheckDefFailure(["let x = 1 isnot? 2"], 'E15:') | 863 call CheckDefFailure(["let x = 1 isnot? 2"], 'E15:', 1) |
864 | 864 |
865 call CheckDefFailure(["let x = 1 == '2'"], 'Cannot compare number with string') | 865 call CheckDefFailure(["let x = 1 == '2'"], 'Cannot compare number with string', 1) |
866 call CheckDefFailure(["let x = '1' == 2"], 'Cannot compare string with number') | 866 call CheckDefFailure(["let x = '1' == 2"], 'Cannot compare string with number', 1) |
867 call CheckDefFailure(["let x = 1 == RetVoid()"], 'Cannot compare number with void') | 867 call CheckDefFailure(["let x = 1 == RetVoid()"], 'Cannot compare number with void', 1) |
868 call CheckDefFailure(["let x = RetVoid() == 1"], 'Cannot compare void with number') | 868 call CheckDefFailure(["let x = RetVoid() == 1"], 'Cannot compare void with number', 1) |
869 | 869 |
870 call CheckDefFailure(["let x = true > false"], 'Cannot compare bool with bool') | 870 call CheckDefFailure(["let x = true > false"], 'Cannot compare bool with bool', 1) |
871 call CheckDefFailure(["let x = true >= false"], 'Cannot compare bool with bool') | 871 call CheckDefFailure(["let x = true >= false"], 'Cannot compare bool with bool', 1) |
872 call CheckDefFailure(["let x = true < false"], 'Cannot compare bool with bool') | 872 call CheckDefFailure(["let x = true < false"], 'Cannot compare bool with bool', 1) |
873 call CheckDefFailure(["let x = true <= false"], 'Cannot compare bool with bool') | 873 call CheckDefFailure(["let x = true <= false"], 'Cannot compare bool with bool', 1) |
874 call CheckDefFailure(["let x = true =~ false"], 'Cannot compare bool with bool') | 874 call CheckDefFailure(["let x = true =~ false"], 'Cannot compare bool with bool', 1) |
875 call CheckDefFailure(["let x = true !~ false"], 'Cannot compare bool with bool') | 875 call CheckDefFailure(["let x = true !~ false"], 'Cannot compare bool with bool', 1) |
876 call CheckDefFailure(["let x = true is false"], 'Cannot use "is" with bool') | 876 call CheckDefFailure(["let x = true is false"], 'Cannot use "is" with bool', 1) |
877 call CheckDefFailure(["let x = true isnot false"], 'Cannot use "isnot" with bool') | 877 call CheckDefFailure(["let x = true isnot false"], 'Cannot use "isnot" with bool', 1) |
878 | 878 |
879 call CheckDefFailure(["let x = v:none is v:null"], 'Cannot use "is" with special') | 879 call CheckDefFailure(["let x = v:none is v:null"], 'Cannot use "is" with special', 1) |
880 call CheckDefFailure(["let x = v:none isnot v:null"], 'Cannot use "isnot" with special') | 880 call CheckDefFailure(["let x = v:none isnot v:null"], 'Cannot use "isnot" with special', 1) |
881 call CheckDefFailure(["let x = 123 is 123"], 'Cannot use "is" with number') | 881 call CheckDefFailure(["let x = 123 is 123"], 'Cannot use "is" with number', 1) |
882 call CheckDefFailure(["let x = 123 isnot 123"], 'Cannot use "isnot" with number') | 882 call CheckDefFailure(["let x = 123 isnot 123"], 'Cannot use "isnot" with number', 1) |
883 if has('float') | 883 if has('float') |
884 call CheckDefFailure(["let x = 1.3 is 1.3"], 'Cannot use "is" with float') | 884 call CheckDefFailure(["let x = 1.3 is 1.3"], 'Cannot use "is" with float', 1) |
885 call CheckDefFailure(["let x = 1.3 isnot 1.3"], 'Cannot use "isnot" with float') | 885 call CheckDefFailure(["let x = 1.3 isnot 1.3"], 'Cannot use "isnot" with float', 1) |
886 endif | 886 endif |
887 | 887 |
888 call CheckDefFailure(["let x = 0za1 > 0z34"], 'Cannot compare blob with blob') | 888 call CheckDefFailure(["let x = 0za1 > 0z34"], 'Cannot compare blob with blob', 1) |
889 call CheckDefFailure(["let x = 0za1 >= 0z34"], 'Cannot compare blob with blob') | 889 call CheckDefFailure(["let x = 0za1 >= 0z34"], 'Cannot compare blob with blob', 1) |
890 call CheckDefFailure(["let x = 0za1 < 0z34"], 'Cannot compare blob with blob') | 890 call CheckDefFailure(["let x = 0za1 < 0z34"], 'Cannot compare blob with blob', 1) |
891 call CheckDefFailure(["let x = 0za1 <= 0z34"], 'Cannot compare blob with blob') | 891 call CheckDefFailure(["let x = 0za1 <= 0z34"], 'Cannot compare blob with blob', 1) |
892 call CheckDefFailure(["let x = 0za1 =~ 0z34"], 'Cannot compare blob with blob') | 892 call CheckDefFailure(["let x = 0za1 =~ 0z34"], 'Cannot compare blob with blob', 1) |
893 call CheckDefFailure(["let x = 0za1 !~ 0z34"], 'Cannot compare blob with blob') | 893 call CheckDefFailure(["let x = 0za1 !~ 0z34"], 'Cannot compare blob with blob', 1) |
894 | 894 |
895 call CheckDefFailure(["let x = [13] > [88]"], 'Cannot compare list with list') | 895 call CheckDefFailure(["let x = [13] > [88]"], 'Cannot compare list with list', 1) |
896 call CheckDefFailure(["let x = [13] >= [88]"], 'Cannot compare list with list') | 896 call CheckDefFailure(["let x = [13] >= [88]"], 'Cannot compare list with list', 1) |
897 call CheckDefFailure(["let x = [13] < [88]"], 'Cannot compare list with list') | 897 call CheckDefFailure(["let x = [13] < [88]"], 'Cannot compare list with list', 1) |
898 call CheckDefFailure(["let x = [13] <= [88]"], 'Cannot compare list with list') | 898 call CheckDefFailure(["let x = [13] <= [88]"], 'Cannot compare list with list', 1) |
899 call CheckDefFailure(["let x = [13] =~ [88]"], 'Cannot compare list with list') | 899 call CheckDefFailure(["let x = [13] =~ [88]"], 'Cannot compare list with list', 1) |
900 call CheckDefFailure(["let x = [13] !~ [88]"], 'Cannot compare list with list') | 900 call CheckDefFailure(["let x = [13] !~ [88]"], 'Cannot compare list with list', 1) |
901 | 901 |
902 call CheckDefFailure(['let j: job', 'let chan: channel', 'let r = j == chan'], 'Cannot compare job with channel') | 902 call CheckDefFailure(['let j: job', 'let chan: channel', 'let r = j == chan'], 'Cannot compare job with channel', 3) |
903 call CheckDefFailure(['let j: job', 'let x: list<any>', 'let r = j == x'], 'Cannot compare job with list') | 903 call CheckDefFailure(['let j: job', 'let x: list<any>', 'let r = j == x'], 'Cannot compare job with list', 3) |
904 call CheckDefFailure(['let j: job', 'let Xx: func', 'let r = j == Xx'], 'Cannot compare job with func') | 904 call CheckDefFailure(['let j: job', 'let Xx: func', 'let r = j == Xx'], 'Cannot compare job with func', 3) |
905 call CheckDefFailure(['let j: job', 'let Xx: func', 'let r = j == Xx'], 'Cannot compare job with func') | 905 call CheckDefFailure(['let j: job', 'let Xx: func', 'let r = j == Xx'], 'Cannot compare job with func', 3) |
906 endfunc | 906 endfunc |
907 | 907 |
908 " test addition, subtraction, concatenation | 908 " test addition, subtraction, concatenation |
909 def Test_expr5() | 909 def Test_expr5() |
910 assert_equal(66, 60 + 6) | 910 assert_equal(66, 60 + 6) |
976 | 976 |
977 lines =<< trim END | 977 lines =<< trim END |
978 vim9script | 978 vim9script |
979 echo 'abc' is# 'abc' | 979 echo 'abc' is# 'abc' |
980 END | 980 END |
981 CheckScriptFailure(lines, 'E15:') | 981 CheckScriptFailure(lines, 'E15:', 2) |
982 | 982 |
983 lines =<< trim END | 983 lines =<< trim END |
984 vim9script | 984 vim9script |
985 echo 'abc' is? 'abc' | 985 echo 'abc' is? 'abc' |
986 END | 986 END |
987 CheckScriptFailure(lines, 'E15:') | 987 CheckScriptFailure(lines, 'E15:', 2) |
988 | 988 |
989 lines =<< trim END | 989 lines =<< trim END |
990 vim9script | 990 vim9script |
991 echo 'abc' isnot# 'abc' | 991 echo 'abc' isnot# 'abc' |
992 END | 992 END |
993 CheckScriptFailure(lines, 'E15:') | 993 CheckScriptFailure(lines, 'E15:', 2) |
994 | 994 |
995 lines =<< trim END | 995 lines =<< trim END |
996 vim9script | 996 vim9script |
997 echo 'abc' isnot? 'abc' | 997 echo 'abc' isnot? 'abc' |
998 END | 998 END |
999 CheckScriptFailure(lines, 'E15:') | 999 CheckScriptFailure(lines, 'E15:', 2) |
1000 | 1000 |
1001 # check white space | 1001 # check white space |
1002 lines =<< trim END | 1002 lines =<< trim END |
1003 vim9script | 1003 vim9script |
1004 echo 5+6 | 1004 echo 5+6 |
1005 END | 1005 END |
1006 CheckScriptFailure(lines, 'E1004:') | 1006 CheckScriptFailure(lines, 'E1004:', 2) |
1007 lines =<< trim END | 1007 lines =<< trim END |
1008 vim9script | 1008 vim9script |
1009 echo 5 +6 | 1009 echo 5 +6 |
1010 END | 1010 END |
1011 CheckScriptFailure(lines, 'E1004:') | 1011 CheckScriptFailure(lines, 'E1004:', 2) |
1012 lines =<< trim END | 1012 lines =<< trim END |
1013 vim9script | 1013 vim9script |
1014 echo 5+ 6 | 1014 echo 5+ 6 |
1015 END | 1015 END |
1016 CheckScriptFailure(lines, 'E1004:') | 1016 CheckScriptFailure(lines, 'E1004:', 2) |
1017 | 1017 |
1018 lines =<< trim END | 1018 lines =<< trim END |
1019 vim9script | 1019 vim9script |
1020 echo 'a'..'b' | 1020 echo 'a'..'b' |
1021 END | 1021 END |
1022 CheckScriptFailure(lines, 'E1004:') | 1022 CheckScriptFailure(lines, 'E1004:', 2) |
1023 lines =<< trim END | 1023 lines =<< trim END |
1024 vim9script | 1024 vim9script |
1025 echo 'a' ..'b' | 1025 echo 'a' ..'b' |
1026 END | 1026 END |
1027 CheckScriptFailure(lines, 'E1004:') | 1027 CheckScriptFailure(lines, 'E1004:', 2) |
1028 lines =<< trim END | 1028 lines =<< trim END |
1029 vim9script | 1029 vim9script |
1030 echo 'a'.. 'b' | 1030 echo 'a'.. 'b' |
1031 END | 1031 END |
1032 CheckScriptFailure(lines, 'E1004:') | 1032 CheckScriptFailure(lines, 'E1004:', 2) |
1033 | 1033 |
1034 # check valid string concatenation | 1034 # check valid string concatenation |
1035 lines =<< trim END | 1035 lines =<< trim END |
1036 vim9script | 1036 vim9script |
1037 assert_equal('one123', 'one' .. 123) | 1037 assert_equal('one123', 'one' .. 123) |
1047 # check invalid string concatenation | 1047 # check invalid string concatenation |
1048 lines =<< trim END | 1048 lines =<< trim END |
1049 vim9script | 1049 vim9script |
1050 echo 'a' .. [1] | 1050 echo 'a' .. [1] |
1051 END | 1051 END |
1052 CheckScriptFailure(lines, 'E730:') | 1052 CheckScriptFailure(lines, 'E730:', 2) |
1053 lines =<< trim END | 1053 lines =<< trim END |
1054 vim9script | 1054 vim9script |
1055 echo 'a' .. #{a: 1} | 1055 echo 'a' .. #{a: 1} |
1056 END | 1056 END |
1057 CheckScriptFailure(lines, 'E731:') | 1057 CheckScriptFailure(lines, 'E731:', 2) |
1058 lines =<< trim END | 1058 lines =<< trim END |
1059 vim9script | 1059 vim9script |
1060 echo 'a' .. test_void() | 1060 echo 'a' .. test_void() |
1061 END | 1061 END |
1062 CheckScriptFailure(lines, 'E908:') | 1062 CheckScriptFailure(lines, 'E908:', 2) |
1063 lines =<< trim END | 1063 lines =<< trim END |
1064 vim9script | 1064 vim9script |
1065 echo 'a' .. 0z33 | 1065 echo 'a' .. 0z33 |
1066 END | 1066 END |
1067 CheckScriptFailure(lines, 'E976:') | 1067 CheckScriptFailure(lines, 'E976:', 2) |
1068 lines =<< trim END | 1068 lines =<< trim END |
1069 vim9script | 1069 vim9script |
1070 echo 'a' .. function('len') | 1070 echo 'a' .. function('len') |
1071 END | 1071 END |
1072 CheckScriptFailure(lines, 'E729:') | 1072 CheckScriptFailure(lines, 'E729:', 2) |
1073 lines =<< trim END | 1073 lines =<< trim END |
1074 vim9script | 1074 vim9script |
1075 echo 'a' .. test_null_job() | 1075 echo 'a' .. test_null_job() |
1076 END | 1076 END |
1077 CheckScriptFailure(lines, 'E908:') | 1077 CheckScriptFailure(lines, 'E908:', 2) |
1078 lines =<< trim END | 1078 lines =<< trim END |
1079 vim9script | 1079 vim9script |
1080 echo 'a' .. test_null_channel() | 1080 echo 'a' .. test_null_channel() |
1081 END | 1081 END |
1082 CheckScriptFailure(lines, 'E908:') | 1082 CheckScriptFailure(lines, 'E908:', 2) |
1083 enddef | 1083 enddef |
1084 | 1084 |
1085 def Test_expr5_float() | 1085 def Test_expr5_float() |
1086 if !has('float') | 1086 if !has('float') |
1087 MissingFeature 'float' | 1087 MissingFeature 'float' |
1107 endif | 1107 endif |
1108 enddef | 1108 enddef |
1109 | 1109 |
1110 func Test_expr5_fails() | 1110 func Test_expr5_fails() |
1111 let msg = "white space required before and after '+'" | 1111 let msg = "white space required before and after '+'" |
1112 call CheckDefFailure(["let x = 1+2"], msg) | 1112 call CheckDefFailure(["let x = 1+2"], msg, 1) |
1113 call CheckDefFailure(["let x = 1 +2"], msg) | 1113 call CheckDefFailure(["let x = 1 +2"], msg, 1) |
1114 call CheckDefFailure(["let x = 1+ 2"], msg) | 1114 call CheckDefFailure(["let x = 1+ 2"], msg, 1) |
1115 | 1115 |
1116 let msg = "white space required before and after '-'" | 1116 let msg = "white space required before and after '-'" |
1117 call CheckDefFailure(["let x = 1-2"], msg) | 1117 call CheckDefFailure(["let x = 1-2"], msg, 1) |
1118 call CheckDefFailure(["let x = 1 -2"], msg) | 1118 call CheckDefFailure(["let x = 1 -2"], msg, 1) |
1119 call CheckDefFailure(["let x = 1- 2"], msg) | 1119 call CheckDefFailure(["let x = 1- 2"], msg, 1) |
1120 | 1120 |
1121 let msg = "white space required before and after '..'" | 1121 let msg = "white space required before and after '..'" |
1122 call CheckDefFailure(["let x = '1'..'2'"], msg) | 1122 call CheckDefFailure(["let x = '1'..'2'"], msg, 1) |
1123 call CheckDefFailure(["let x = '1' ..'2'"], msg) | 1123 call CheckDefFailure(["let x = '1' ..'2'"], msg, 1) |
1124 call CheckDefFailure(["let x = '1'.. '2'"], msg) | 1124 call CheckDefFailure(["let x = '1'.. '2'"], msg, 1) |
1125 | 1125 |
1126 call CheckDefFailure(["let x = 0z1122 + 33"], 'E1051') | 1126 call CheckDefFailure(["let x = 0z1122 + 33"], 'E1051', 1) |
1127 call CheckDefFailure(["let x = 0z1122 + [3]"], 'E1051') | 1127 call CheckDefFailure(["let x = 0z1122 + [3]"], 'E1051', 1) |
1128 call CheckDefFailure(["let x = 0z1122 + 'asd'"], 'E1051') | 1128 call CheckDefFailure(["let x = 0z1122 + 'asd'"], 'E1051', 1) |
1129 call CheckDefFailure(["let x = 33 + 0z1122"], 'E1051') | 1129 call CheckDefFailure(["let x = 33 + 0z1122"], 'E1051', 1) |
1130 call CheckDefFailure(["let x = [3] + 0z1122"], 'E1051') | 1130 call CheckDefFailure(["let x = [3] + 0z1122"], 'E1051', 1) |
1131 call CheckDefFailure(["let x = 'asdf' + 0z1122"], 'E1051') | 1131 call CheckDefFailure(["let x = 'asdf' + 0z1122"], 'E1051', 1) |
1132 call CheckDefFailure(["let x = 6 + xxx"], 'E1001') | 1132 call CheckDefFailure(["let x = 6 + xxx"], 'E1001', 1) |
1133 | 1133 |
1134 call CheckDefFailure(["let x = 'a' .. [1]"], 'E1105') | 1134 call CheckDefFailure(["let x = 'a' .. [1]"], 'E1105', 1) |
1135 call CheckDefFailure(["let x = 'a' .. #{a: 1}"], 'E1105') | 1135 call CheckDefFailure(["let x = 'a' .. #{a: 1}"], 'E1105', 1) |
1136 call CheckDefFailure(["let x = 'a' .. test_void()"], 'E1105') | 1136 call CheckDefFailure(["let x = 'a' .. test_void()"], 'E1105', 1) |
1137 call CheckDefFailure(["let x = 'a' .. 0z32"], 'E1105') | 1137 call CheckDefFailure(["let x = 'a' .. 0z32"], 'E1105', 1) |
1138 call CheckDefFailure(["let x = 'a' .. function('len')"], 'E1105') | 1138 call CheckDefFailure(["let x = 'a' .. function('len')"], 'E1105', 1) |
1139 call CheckDefFailure(["let x = 'a' .. function('len', ['a'])"], 'E1105') | 1139 call CheckDefFailure(["let x = 'a' .. function('len', ['a'])"], 'E1105', 1) |
1140 call CheckDefFailure(["let x = 'a' .. test_null_job()"], 'E1105') | 1140 call CheckDefFailure(["let x = 'a' .. test_null_job()"], 'E1105', 1) |
1141 call CheckDefFailure(["let x = 'a' .. test_null_channel()"], 'E1105') | 1141 call CheckDefFailure(["let x = 'a' .. test_null_channel()"], 'E1105', 1) |
1142 endfunc | 1142 endfunc |
1143 | 1143 |
1144 " test multiply, divide, modulo | 1144 " test multiply, divide, modulo |
1145 def Test_expr6() | 1145 def Test_expr6() |
1146 assert_equal(36, 6 * 6) | 1146 assert_equal(36, 6 * 6) |
1177 + yf[0]) | 1177 + yf[0]) |
1178 assert_equal(6.0, xf[0] | 1178 assert_equal(6.0, xf[0] |
1179 * yf[0]) | 1179 * yf[0]) |
1180 endif | 1180 endif |
1181 | 1181 |
1182 call CheckDefFailure(["let x = 6 * xxx"], 'E1001') | 1182 call CheckDefFailure(["let x = 6 * xxx"], 'E1001', 1) |
1183 enddef | 1183 enddef |
1184 | 1184 |
1185 def Test_expr6_vim9script() | 1185 def Test_expr6_vim9script() |
1186 # check line continuation | 1186 # check line continuation |
1187 let lines =<< trim END | 1187 let lines =<< trim END |
1213 # check white space | 1213 # check white space |
1214 lines =<< trim END | 1214 lines =<< trim END |
1215 vim9script | 1215 vim9script |
1216 echo 5*6 | 1216 echo 5*6 |
1217 END | 1217 END |
1218 CheckScriptFailure(lines, 'E1004:') | 1218 CheckScriptFailure(lines, 'E1004:', 2) |
1219 lines =<< trim END | 1219 lines =<< trim END |
1220 vim9script | 1220 vim9script |
1221 echo 5 *6 | 1221 echo 5 *6 |
1222 END | 1222 END |
1223 CheckScriptFailure(lines, 'E1004:') | 1223 CheckScriptFailure(lines, 'E1004:', 2) |
1224 lines =<< trim END | 1224 lines =<< trim END |
1225 vim9script | 1225 vim9script |
1226 echo 5* 6 | 1226 echo 5* 6 |
1227 END | 1227 END |
1228 CheckScriptFailure(lines, 'E1004:') | 1228 CheckScriptFailure(lines, 'E1004:', 2) |
1229 enddef | 1229 enddef |
1230 | 1230 |
1231 def Test_expr6_float() | 1231 def Test_expr6_float() |
1232 if !has('float') | 1232 if !has('float') |
1233 MissingFeature 'float' | 1233 MissingFeature 'float' |
1258 endif | 1258 endif |
1259 enddef | 1259 enddef |
1260 | 1260 |
1261 func Test_expr6_fails() | 1261 func Test_expr6_fails() |
1262 let msg = "white space required before and after '*'" | 1262 let msg = "white space required before and after '*'" |
1263 call CheckDefFailure(["let x = 1*2"], msg) | 1263 call CheckDefFailure(["let x = 1*2"], msg, 1) |
1264 call CheckDefFailure(["let x = 1 *2"], msg) | 1264 call CheckDefFailure(["let x = 1 *2"], msg, 1) |
1265 call CheckDefFailure(["let x = 1* 2"], msg) | 1265 call CheckDefFailure(["let x = 1* 2"], msg, 1) |
1266 | 1266 |
1267 let msg = "white space required before and after '/'" | 1267 let msg = "white space required before and after '/'" |
1268 call CheckDefFailure(["let x = 1/2"], msg) | 1268 call CheckDefFailure(["let x = 1/2"], msg, 1) |
1269 call CheckDefFailure(["let x = 1 /2"], msg) | 1269 call CheckDefFailure(["let x = 1 /2"], msg, 1) |
1270 call CheckDefFailure(["let x = 1/ 2"], msg) | 1270 call CheckDefFailure(["let x = 1/ 2"], msg, 1) |
1271 | 1271 |
1272 let msg = "white space required before and after '%'" | 1272 let msg = "white space required before and after '%'" |
1273 call CheckDefFailure(["let x = 1%2"], msg) | 1273 call CheckDefFailure(["let x = 1%2"], msg, 1) |
1274 call CheckDefFailure(["let x = 1 %2"], msg) | 1274 call CheckDefFailure(["let x = 1 %2"], msg, 1) |
1275 call CheckDefFailure(["let x = 1% 2"], msg) | 1275 call CheckDefFailure(["let x = 1% 2"], msg, 1) |
1276 | 1276 |
1277 call CheckDefFailure(["let x = '1' * '2'"], 'E1036:') | 1277 call CheckDefFailure(["let x = '1' * '2'"], 'E1036:', 1) |
1278 call CheckDefFailure(["let x = '1' / '2'"], 'E1036:') | 1278 call CheckDefFailure(["let x = '1' / '2'"], 'E1036:', 1) |
1279 call CheckDefFailure(["let x = '1' % '2'"], 'E1035:') | 1279 call CheckDefFailure(["let x = '1' % '2'"], 'E1035:', 1) |
1280 | 1280 |
1281 call CheckDefFailure(["let x = 0z01 * 0z12"], 'E1036:') | 1281 call CheckDefFailure(["let x = 0z01 * 0z12"], 'E1036:', 1) |
1282 call CheckDefFailure(["let x = 0z01 / 0z12"], 'E1036:') | 1282 call CheckDefFailure(["let x = 0z01 / 0z12"], 'E1036:', 1) |
1283 call CheckDefFailure(["let x = 0z01 % 0z12"], 'E1035:') | 1283 call CheckDefFailure(["let x = 0z01 % 0z12"], 'E1035:', 1) |
1284 | 1284 |
1285 call CheckDefFailure(["let x = [1] * [2]"], 'E1036:') | 1285 call CheckDefFailure(["let x = [1] * [2]"], 'E1036:', 1) |
1286 call CheckDefFailure(["let x = [1] / [2]"], 'E1036:') | 1286 call CheckDefFailure(["let x = [1] / [2]"], 'E1036:', 1) |
1287 call CheckDefFailure(["let x = [1] % [2]"], 'E1035:') | 1287 call CheckDefFailure(["let x = [1] % [2]"], 'E1035:', 1) |
1288 | 1288 |
1289 call CheckDefFailure(["let x = #{one: 1} * #{two: 2}"], 'E1036:') | 1289 call CheckDefFailure(["let x = #{one: 1} * #{two: 2}"], 'E1036:', 1) |
1290 call CheckDefFailure(["let x = #{one: 1} / #{two: 2}"], 'E1036:') | 1290 call CheckDefFailure(["let x = #{one: 1} / #{two: 2}"], 'E1036:', 1) |
1291 call CheckDefFailure(["let x = #{one: 1} % #{two: 2}"], 'E1035:') | 1291 call CheckDefFailure(["let x = #{one: 1} % #{two: 2}"], 'E1035:', 1) |
1292 | 1292 |
1293 call CheckDefFailure(["let x = 0xff[1]"], 'E1107:') | 1293 call CheckDefFailure(["let x = 0xff[1]"], 'E1107:', 1) |
1294 if has('float') | 1294 if has('float') |
1295 call CheckDefFailure(["let x = 0.7[1]"], 'E1107:') | 1295 call CheckDefFailure(["let x = 0.7[1]"], 'E1107:', 1) |
1296 endif | 1296 endif |
1297 endfunc | 1297 endfunc |
1298 | 1298 |
1299 func Test_expr6_float_fails() | 1299 func Test_expr6_float_fails() |
1300 CheckFeature float | 1300 CheckFeature float |
1301 call CheckDefFailure(["let x = 1.0 % 2"], 'E1035:') | 1301 call CheckDefFailure(["let x = 1.0 % 2"], 'E1035:', 1) |
1302 endfunc | 1302 endfunc |
1303 | 1303 |
1304 " define here to use old style parsing | 1304 " define here to use old style parsing |
1305 if has('float') | 1305 if has('float') |
1306 let g:float_zero = 0.0 | 1306 let g:float_zero = 0.0 |
1334 let ls: list<string> = ['a', <string>g:string_empty] | 1334 let ls: list<string> = ['a', <string>g:string_empty] |
1335 let ln: list<number> = [<number>g:anint, <number>g:thefour] | 1335 let ln: list<number> = [<number>g:anint, <number>g:thefour] |
1336 let nr = <number>234 | 1336 let nr = <number>234 |
1337 assert_equal(234, nr) | 1337 assert_equal(234, nr) |
1338 | 1338 |
1339 call CheckDefFailure(["let x = <nr>123"], 'E1010:') | 1339 call CheckDefFailure(["let x = <nr>123"], 'E1010:', 1) |
1340 call CheckDefFailure(["let x = <number >123"], 'E1068:') | 1340 call CheckDefFailure(["let x = <number >123"], 'E1068:', 1) |
1341 call CheckDefFailure(["let x = <number 123"], 'E1104:') | 1341 call CheckDefFailure(["let x = <number 123"], 'E1104:', 1) |
1342 enddef | 1342 enddef |
1343 | 1343 |
1344 " test low level expression | 1344 " test low level expression |
1345 def Test_expr7_number() | 1345 def Test_expr7_number() |
1346 # number constant | 1346 # number constant |
1368 # blob constant | 1368 # blob constant |
1369 assert_equal(g:blob_empty, 0z) | 1369 assert_equal(g:blob_empty, 0z) |
1370 assert_equal(g:blob_one, 0z01) | 1370 assert_equal(g:blob_one, 0z01) |
1371 assert_equal(g:blob_long, 0z0102.0304) | 1371 assert_equal(g:blob_long, 0z0102.0304) |
1372 | 1372 |
1373 call CheckDefFailure(["let x = 0z123"], 'E973:') | 1373 call CheckDefFailure(["let x = 0z123"], 'E973:', 1) |
1374 enddef | 1374 enddef |
1375 | 1375 |
1376 def Test_expr7_string() | 1376 def Test_expr7_string() |
1377 # string constant | 1377 # string constant |
1378 assert_equal(g:string_empty, '') | 1378 assert_equal(g:string_empty, '') |
1381 assert_equal(g:string_short, "x") | 1381 assert_equal(g:string_short, "x") |
1382 assert_equal(g:string_long, 'abcdefghijklm') | 1382 assert_equal(g:string_long, 'abcdefghijklm') |
1383 assert_equal(g:string_long, "abcdefghijklm") | 1383 assert_equal(g:string_long, "abcdefghijklm") |
1384 assert_equal(g:string_special, "ab\ncd\ref\ekk") | 1384 assert_equal(g:string_special, "ab\ncd\ref\ekk") |
1385 | 1385 |
1386 call CheckDefFailure(['let x = "abc'], 'E114:') | 1386 call CheckDefFailure(['let x = "abc'], 'E114:', 1) |
1387 call CheckDefFailure(["let x = 'abc"], 'E115:') | 1387 call CheckDefFailure(["let x = 'abc"], 'E115:', 1) |
1388 enddef | 1388 enddef |
1389 | 1389 |
1390 def Test_expr7_vimvar() | 1390 def Test_expr7_vimvar() |
1391 let old: list<string> = v:oldfiles | 1391 let old: list<string> = v:oldfiles |
1392 let compl: dict<any> = v:completed_item | 1392 let compl: dict<any> = v:completed_item |
1393 | 1393 |
1394 call CheckDefFailure(["let old: list<number> = v:oldfiles"], 'E1012: type mismatch, expected list<number> but got list<string>') | 1394 call CheckDefFailure(["let old: list<number> = v:oldfiles"], 'E1012: type mismatch, expected list<number> but got list<string>', 1) |
1395 call CheckDefFailure(["let old: dict<number> = v:completed_item"], 'E1012: type mismatch, expected dict<number> but got dict<any>') | 1395 call CheckDefFailure(["let old: dict<number> = v:completed_item"], 'E1012: type mismatch, expected dict<number> but got dict<any>', 1) |
1396 enddef | 1396 enddef |
1397 | 1397 |
1398 def Test_expr7_special() | 1398 def Test_expr7_special() |
1399 # special constant | 1399 # special constant |
1400 assert_equal(g:special_true, true) | 1400 assert_equal(g:special_true, true) |
1412 assert_equal(true, !!1) | 1412 assert_equal(true, !!1) |
1413 | 1413 |
1414 assert_equal(g:special_null, v:null) | 1414 assert_equal(g:special_null, v:null) |
1415 assert_equal(g:special_none, v:none) | 1415 assert_equal(g:special_none, v:none) |
1416 | 1416 |
1417 call CheckDefFailure(['v:true = true'], 'E46:') | 1417 call CheckDefFailure(['v:true = true'], 'E46:', 1) |
1418 call CheckDefFailure(['v:true = false'], 'E46:') | 1418 call CheckDefFailure(['v:true = false'], 'E46:', 1) |
1419 call CheckDefFailure(['v:false = true'], 'E46:') | 1419 call CheckDefFailure(['v:false = true'], 'E46:', 1) |
1420 call CheckDefFailure(['v:null = 11'], 'E46:') | 1420 call CheckDefFailure(['v:null = 11'], 'E46:', 1) |
1421 call CheckDefFailure(['v:none = 22'], 'E46:') | 1421 call CheckDefFailure(['v:none = 22'], 'E46:', 1) |
1422 enddef | 1422 enddef |
1423 | 1423 |
1424 def Test_expr7_special_vim9script() | 1424 def Test_expr7_special_vim9script() |
1425 let lines =<< trim END | 1425 let lines =<< trim END |
1426 vim9script | 1426 vim9script |
1461 | 1461 |
1462 echo [1, | 1462 echo [1, |
1463 2] [3, | 1463 2] [3, |
1464 4] | 1464 4] |
1465 | 1465 |
1466 call CheckDefFailure(["let x = 1234[3]"], 'E1107:') | 1466 call CheckDefFailure(["let x = 1234[3]"], 'E1107:', 1) |
1467 call CheckDefExecFailure(["let x = g:anint[3]"], 'E1062:', 1) | 1467 call CheckDefExecFailure(["let x = g:anint[3]"], 'E1062:', 1) |
1468 | 1468 |
1469 call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:') | 1469 call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:', 1) |
1470 | 1470 |
1471 call CheckDefFailure(["let x = [1,2,3]"], 'E1069:') | 1471 call CheckDefFailure(["let x = [1,2,3]"], 'E1069:', 1) |
1472 call CheckDefFailure(["let x = [1 ,2, 3]"], 'E1068:') | 1472 call CheckDefFailure(["let x = [1 ,2, 3]"], 'E1068:', 1) |
1473 | 1473 |
1474 call CheckDefExecFailure(["echo 1", "let x = [][0]", "echo 3"], 'E684:', 2) | 1474 call CheckDefExecFailure(["echo 1", "let x = [][0]", "echo 3"], 'E684:', 2) |
1475 | 1475 |
1476 call CheckDefExecFailure(["let x = g:list_mixed['xx']"], 'E1029:', 1) | 1476 call CheckDefExecFailure(["let x = g:list_mixed['xx']"], 'E1029:', 1) |
1477 call CheckDefFailure(["let x = g:list_mixed["], 'E1097:') | 1477 call CheckDefFailure(["let x = g:list_mixed["], 'E1097:', 2) |
1478 call CheckDefFailure(["let x = g:list_mixed[0"], 'E1097:', 1) | 1478 call CheckDefFailure(["let x = g:list_mixed[0"], 'E1097:', 2) |
1479 call CheckDefExecFailure(["let x = g:list_empty[3]"], 'E684:') | 1479 call CheckDefExecFailure(["let x = g:list_empty[3]"], 'E684:', 1) |
1480 call CheckDefFailure(["let l: list<number> = [234, 'x']"], 'E1012:') | 1480 call CheckDefFailure(["let l: list<number> = [234, 'x']"], 'E1012:', 1) |
1481 call CheckDefFailure(["let l: list<number> = ['x', 234]"], 'E1012:') | 1481 call CheckDefFailure(["let l: list<number> = ['x', 234]"], 'E1012:', 1) |
1482 call CheckDefFailure(["let l: list<string> = [234, 'x']"], 'E1012:') | 1482 call CheckDefFailure(["let l: list<string> = [234, 'x']"], 'E1012:', 1) |
1483 call CheckDefFailure(["let l: list<string> = ['x', 123]"], 'E1012:') | 1483 call CheckDefFailure(["let l: list<string> = ['x', 123]"], 'E1012:', 1) |
1484 enddef | 1484 enddef |
1485 | 1485 |
1486 def Test_expr7_list_vim9script() | 1486 def Test_expr7_list_vim9script() |
1487 let lines =<< trim END | 1487 let lines =<< trim END |
1488 vim9script | 1488 vim9script |
1508 | 1508 |
1509 lines =<< trim END | 1509 lines =<< trim END |
1510 vim9script | 1510 vim9script |
1511 let l = [11,22] | 1511 let l = [11,22] |
1512 END | 1512 END |
1513 CheckScriptFailure(lines, 'E1069:') | 1513 CheckScriptFailure(lines, 'E1069:', 2) |
1514 | 1514 |
1515 lines =<< trim END | 1515 lines =<< trim END |
1516 vim9script | 1516 vim9script |
1517 let l = [11 , 22] | 1517 let l = [11 , 22] |
1518 END | 1518 END |
1519 CheckScriptFailure(lines, 'E1068:') | 1519 CheckScriptFailure(lines, 'E1068:', 2) |
1520 | 1520 |
1521 lines =<< trim END | 1521 lines =<< trim END |
1522 vim9script | 1522 vim9script |
1523 let l: list<number> = [234, 'x'] | 1523 let l: list<number> = [234, 'x'] |
1524 END | 1524 END |
1525 CheckScriptFailure(lines, 'E1012:') | 1525 CheckScriptFailure(lines, 'E1012:', 2) |
1526 lines =<< trim END | 1526 lines =<< trim END |
1527 vim9script | 1527 vim9script |
1528 let l: list<number> = ['x', 234] | 1528 let l: list<number> = ['x', 234] |
1529 END | 1529 END |
1530 CheckScriptFailure(lines, 'E1012:') | 1530 CheckScriptFailure(lines, 'E1012:', 2) |
1531 lines =<< trim END | 1531 lines =<< trim END |
1532 vim9script | 1532 vim9script |
1533 let l: list<string> = ['x', 234] | 1533 let l: list<string> = ['x', 234] |
1534 END | 1534 END |
1535 CheckScriptFailure(lines, 'E1012:') | 1535 CheckScriptFailure(lines, 'E1012:', 2) |
1536 lines =<< trim END | 1536 lines =<< trim END |
1537 vim9script | 1537 vim9script |
1538 let l: list<string> = [234, 'x'] | 1538 let l: list<string> = [234, 'x'] |
1539 END | 1539 END |
1540 CheckScriptFailure(lines, 'E1012:') | 1540 CheckScriptFailure(lines, 'E1012:', 2) |
1541 enddef | 1541 enddef |
1542 | 1542 |
1543 def LambdaWithComments(): func | 1543 def LambdaWithComments(): func |
1544 return {x -> | 1544 return {x -> |
1545 # some comment | 1545 # some comment |
1599 assert_equal(false, LambdaWithComments()(3)) | 1599 assert_equal(false, LambdaWithComments()(3)) |
1600 | 1600 |
1601 assert_equal(false, LambdaUsingArg(0)()) | 1601 assert_equal(false, LambdaUsingArg(0)()) |
1602 assert_equal(true, LambdaUsingArg(1)()) | 1602 assert_equal(true, LambdaUsingArg(1)()) |
1603 | 1603 |
1604 call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:') | 1604 call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:', 1) |
1605 call CheckDefFailure(["let L = {a -> a + b}"], 'E1001:') | 1605 # error is in first line of the lambda |
1606 call CheckDefFailure(["let L = {a -> a + b}"], 'E1001:', 0) | |
1606 | 1607 |
1607 assert_equal('xxxyyy', 'xxx'->{a, b -> a .. b}('yyy')) | 1608 assert_equal('xxxyyy', 'xxx'->{a, b -> a .. b}('yyy')) |
1608 | 1609 |
1609 CheckDefExecFailure(["let s = 'asdf'->{a -> a}('x')"], | 1610 CheckDefExecFailure(["let s = 'asdf'->{a -> a}('x')"], |
1610 'E1106: one argument too many') | 1611 'E1106: one argument too many') |
1611 CheckDefExecFailure(["let s = 'asdf'->{a -> a}('x', 'y')"], | 1612 CheckDefExecFailure(["let s = 'asdf'->{a -> a}('x', 'y')"], |
1612 'E1106: 2 arguments too many') | 1613 'E1106: 2 arguments too many') |
1613 CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:') | 1614 CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1) |
1614 enddef | 1615 enddef |
1615 | 1616 |
1616 def Test_expr7_lambda_vim9script() | 1617 def Test_expr7_lambda_vim9script() |
1617 let lines =<< trim END | 1618 let lines =<< trim END |
1618 vim9script | 1619 vim9script |
1645 let mixed: dict<any> = #{a: 'a', b: 42} | 1646 let mixed: dict<any> = #{a: 'a', b: 42} |
1646 mixed = #{a: 'x'} | 1647 mixed = #{a: 'x'} |
1647 mixed = #{a: 234} | 1648 mixed = #{a: 234} |
1648 mixed = #{} | 1649 mixed = #{} |
1649 | 1650 |
1650 call CheckDefFailure(["let x = #{a:8}"], 'E1069:') | 1651 call CheckDefFailure(["let x = #{a:8}"], 'E1069:', 1) |
1651 call CheckDefFailure(["let x = #{a : 8}"], 'E1068:') | 1652 call CheckDefFailure(["let x = #{a : 8}"], 'E1068:', 1) |
1652 call CheckDefFailure(["let x = #{a :8}"], 'E1068:') | 1653 call CheckDefFailure(["let x = #{a :8}"], 'E1068:', 1) |
1653 call CheckDefFailure(["let x = #{a: 8 , b: 9}"], 'E1068:') | 1654 call CheckDefFailure(["let x = #{a: 8 , b: 9}"], 'E1068:', 1) |
1654 | 1655 |
1655 call CheckDefFailure(["let x = #{8: 8}"], 'E1014:') | 1656 call CheckDefFailure(["let x = #{8: 8}"], 'E1014:', 1) |
1656 call CheckDefFailure(["let x = #{xxx}"], 'E720:') | 1657 call CheckDefFailure(["let x = #{xxx}"], 'E720:', 1) |
1657 call CheckDefFailure(["let x = #{xxx: 1", "let y = 2"], 'E722:') | 1658 call CheckDefFailure(["let x = #{xxx: 1", "let y = 2"], 'E722:', 2) |
1658 call CheckDefFailure(["let x = #{xxx: 1,"], 'E723:') | 1659 call CheckDefFailure(["let x = #{xxx: 1,"], 'E723:', 2) |
1659 call CheckDefFailure(["let x = {'a': xxx}"], 'E1001:') | 1660 call CheckDefFailure(["let x = {'a': xxx}"], 'E1001:', 1) |
1660 call CheckDefFailure(["let x = {xxx: 8}"], 'E1001:') | 1661 call CheckDefFailure(["let x = {xxx: 8}"], 'E1001:', 1) |
1661 call CheckDefFailure(["let x = #{a: 1, a: 2}"], 'E721:') | 1662 call CheckDefFailure(["let x = #{a: 1, a: 2}"], 'E721:', 1) |
1662 call CheckDefFailure(["let x = #"], 'E1015:') | 1663 call CheckDefFailure(["let x = #"], 'E1015:', 1) |
1663 call CheckDefFailure(["let x += 1"], 'E1020:') | 1664 call CheckDefFailure(["let x += 1"], 'E1020:', 1) |
1664 call CheckDefFailure(["let x = x + 1"], 'E1001:') | 1665 call CheckDefFailure(["let x = x + 1"], 'E1001:', 1) |
1665 call CheckDefExecFailure(["let x = g:anint.member"], 'E715:') | 1666 call CheckDefExecFailure(["let x = g:anint.member"], 'E715:', 1) |
1666 call CheckDefExecFailure(["let x = g:dict_empty.member"], 'E716:') | 1667 call CheckDefExecFailure(["let x = g:dict_empty.member"], 'E716:', 1) |
1667 | 1668 |
1668 call CheckDefFailure(['let x: dict<number> = #{a: 234, b: "1"}'], 'E1012:') | 1669 call CheckDefFailure(['let x: dict<number> = #{a: 234, b: "1"}'], 'E1012:', 1) |
1669 call CheckDefFailure(['let x: dict<number> = #{a: "x", b: 134}'], 'E1012:') | 1670 call CheckDefFailure(['let x: dict<number> = #{a: "x", b: 134}'], 'E1012:', 1) |
1670 call CheckDefFailure(['let x: dict<string> = #{a: 234, b: "1"}'], 'E1012:') | 1671 call CheckDefFailure(['let x: dict<string> = #{a: 234, b: "1"}'], 'E1012:', 1) |
1671 call CheckDefFailure(['let x: dict<string> = #{a: "x", b: 134}'], 'E1012:') | 1672 call CheckDefFailure(['let x: dict<string> = #{a: "x", b: 134}'], 'E1012:', 1) |
1672 enddef | 1673 enddef |
1673 | 1674 |
1674 def Test_expr7_dict_vim9script() | 1675 def Test_expr7_dict_vim9script() |
1675 let lines =<< trim END | 1676 let lines =<< trim END |
1676 vim9script | 1677 vim9script |
1701 | 1702 |
1702 lines =<< trim END | 1703 lines =<< trim END |
1703 vim9script | 1704 vim9script |
1704 let d = #{one:1, two: 2} | 1705 let d = #{one:1, two: 2} |
1705 END | 1706 END |
1706 CheckScriptFailure(lines, 'E1069:') | 1707 CheckScriptFailure(lines, 'E1069:', 2) |
1707 | 1708 |
1708 lines =<< trim END | 1709 lines =<< trim END |
1709 vim9script | 1710 vim9script |
1710 let d = #{one: 1,two: 2} | 1711 let d = #{one: 1,two: 2} |
1711 END | 1712 END |
1712 CheckScriptFailure(lines, 'E1069:') | 1713 CheckScriptFailure(lines, 'E1069:', 2) |
1713 | 1714 |
1714 lines =<< trim END | 1715 lines =<< trim END |
1715 vim9script | 1716 vim9script |
1716 let d = #{one : 1} | 1717 let d = #{one : 1} |
1717 END | 1718 END |
1718 CheckScriptFailure(lines, 'E1068:') | 1719 CheckScriptFailure(lines, 'E1068:', 2) |
1719 | 1720 |
1720 lines =<< trim END | 1721 lines =<< trim END |
1721 vim9script | 1722 vim9script |
1722 let d = #{one:1} | 1723 let d = #{one:1} |
1723 END | 1724 END |
1724 CheckScriptFailure(lines, 'E1069:') | 1725 CheckScriptFailure(lines, 'E1069:', 2) |
1725 | 1726 |
1726 lines =<< trim END | 1727 lines =<< trim END |
1727 vim9script | 1728 vim9script |
1728 let d = #{one: 1 , two: 2} | 1729 let d = #{one: 1 , two: 2} |
1729 END | 1730 END |
1730 CheckScriptFailure(lines, 'E1068:') | 1731 CheckScriptFailure(lines, 'E1068:', 2) |
1731 | 1732 |
1732 lines =<< trim END | 1733 lines =<< trim END |
1733 vim9script | 1734 vim9script |
1734 let l: dict<number> = #{a: 234, b: 'x'} | 1735 let l: dict<number> = #{a: 234, b: 'x'} |
1735 END | 1736 END |
1736 CheckScriptFailure(lines, 'E1012:') | 1737 CheckScriptFailure(lines, 'E1012:', 2) |
1737 lines =<< trim END | 1738 lines =<< trim END |
1738 vim9script | 1739 vim9script |
1739 let l: dict<number> = #{a: 'x', b: 234} | 1740 let l: dict<number> = #{a: 'x', b: 234} |
1740 END | 1741 END |
1741 CheckScriptFailure(lines, 'E1012:') | 1742 CheckScriptFailure(lines, 'E1012:', 2) |
1742 lines =<< trim END | 1743 lines =<< trim END |
1743 vim9script | 1744 vim9script |
1744 let l: dict<string> = #{a: 'x', b: 234} | 1745 let l: dict<string> = #{a: 'x', b: 234} |
1745 END | 1746 END |
1746 CheckScriptFailure(lines, 'E1012:') | 1747 CheckScriptFailure(lines, 'E1012:', 2) |
1747 lines =<< trim END | 1748 lines =<< trim END |
1748 vim9script | 1749 vim9script |
1749 let l: dict<string> = #{a: 234, b: 'x'} | 1750 let l: dict<string> = #{a: 234, b: 'x'} |
1750 END | 1751 END |
1751 CheckScriptFailure(lines, 'E1012:') | 1752 CheckScriptFailure(lines, 'E1012:', 2) |
1752 enddef | 1753 enddef |
1753 | 1754 |
1754 let g:oneString = 'one' | 1755 let g:oneString = 'one' |
1755 | 1756 |
1756 def Test_expr_member() | 1757 def Test_expr_member() |
1770 | 1771 |
1771 # getting the one member should clear the dict after getting the item | 1772 # getting the one member should clear the dict after getting the item |
1772 assert_equal('one', #{one: 'one'}.one) | 1773 assert_equal('one', #{one: 'one'}.one) |
1773 assert_equal('one', #{one: 'one'}[g:oneString]) | 1774 assert_equal('one', #{one: 'one'}[g:oneString]) |
1774 | 1775 |
1775 call CheckDefFailure(["let x = g:dict_one.#$!"], 'E1002:') | 1776 call CheckDefFailure(["let x = g:dict_one.#$!"], 'E1002:', 1) |
1776 call CheckDefExecFailure(["let d: dict<any>", "echo d['a']"], 'E716:') | 1777 call CheckDefExecFailure(["let d: dict<any>", "echo d['a']"], 'E716:', 2) |
1777 call CheckDefExecFailure(["let d: dict<number>", "d = g:list_empty"], 'E1029: Expected dict but got list') | 1778 call CheckDefExecFailure(["let d: dict<number>", "d = g:list_empty"], 'E1029: Expected dict but got list', 2) |
1778 enddef | 1779 enddef |
1779 | 1780 |
1780 def Test_expr7_any_index_slice() | 1781 def Test_expr7_any_index_slice() |
1781 let lines =<< trim END | 1782 let lines =<< trim END |
1782 # getting the one member should clear the list only after getting the item | 1783 # getting the one member should clear the list only after getting the item |
1842 END | 1843 END |
1843 | 1844 |
1844 CheckDefSuccess(lines) | 1845 CheckDefSuccess(lines) |
1845 CheckScriptSuccess(['vim9script'] + lines) | 1846 CheckScriptSuccess(['vim9script'] + lines) |
1846 | 1847 |
1847 CheckDefExecFailure(['echo g:testblob[2]'], 'E979:') | 1848 CheckDefExecFailure(['echo g:testblob[2]'], 'E979:', 1) |
1848 CheckScriptFailure(['vim9script', 'echo g:testblob[2]'], 'E979:') | 1849 CheckScriptFailure(['vim9script', 'echo g:testblob[2]'], 'E979:', 2) |
1849 CheckDefExecFailure(['echo g:testblob[-3]'], 'E979:') | 1850 CheckDefExecFailure(['echo g:testblob[-3]'], 'E979:', 1) |
1850 CheckScriptFailure(['vim9script', 'echo g:testblob[-3]'], 'E979:') | 1851 CheckScriptFailure(['vim9script', 'echo g:testblob[-3]'], 'E979:', 2) |
1851 | 1852 |
1852 CheckDefExecFailure(['echo g:testlist[4]'], 'E684:') | 1853 CheckDefExecFailure(['echo g:testlist[4]'], 'E684:', 1) |
1853 CheckScriptFailure(['vim9script', 'echo g:testlist[4]'], 'E684:') | 1854 CheckScriptFailure(['vim9script', 'echo g:testlist[4]'], 'E684:', 2) |
1854 CheckDefExecFailure(['echo g:testlist[-5]'], 'E684:') | 1855 CheckDefExecFailure(['echo g:testlist[-5]'], 'E684:', 1) |
1855 CheckScriptFailure(['vim9script', 'echo g:testlist[-5]'], 'E684:') | 1856 CheckScriptFailure(['vim9script', 'echo g:testlist[-5]'], 'E684:', 2) |
1856 | 1857 |
1857 CheckDefExecFailure(['echo g:testdict["a":"b"]'], 'E719:') | 1858 CheckDefExecFailure(['echo g:testdict["a":"b"]'], 'E719:', 1) |
1858 CheckScriptFailure(['vim9script', 'echo g:testdict["a":"b"]'], 'E719:') | 1859 CheckScriptFailure(['vim9script', 'echo g:testdict["a":"b"]'], 'E719:', 2) |
1859 CheckDefExecFailure(['echo g:testdict[1]'], 'E716:') | 1860 CheckDefExecFailure(['echo g:testdict[1]'], 'E716:', 1) |
1860 CheckScriptFailure(['vim9script', 'echo g:testdict[1]'], 'E716:') | 1861 CheckScriptFailure(['vim9script', 'echo g:testdict[1]'], 'E716:', 2) |
1861 | 1862 |
1862 unlet g:teststring | 1863 unlet g:teststring |
1863 unlet g:testblob | 1864 unlet g:testblob |
1864 unlet g:testlist | 1865 unlet g:testlist |
1865 enddef | 1866 enddef |
1924 def Test_expr7_environment() | 1925 def Test_expr7_environment() |
1925 # environment variable | 1926 # environment variable |
1926 assert_equal('testvar', $TESTVAR) | 1927 assert_equal('testvar', $TESTVAR) |
1927 assert_equal('', $ASDF_ASD_XXX) | 1928 assert_equal('', $ASDF_ASD_XXX) |
1928 | 1929 |
1929 call CheckDefFailure(["let x = $$$"], 'E1002:') | 1930 call CheckDefFailure(["let x = $$$"], 'E1002:', 1) |
1930 enddef | 1931 enddef |
1931 | 1932 |
1932 def Test_expr7_register() | 1933 def Test_expr7_register() |
1933 @a = 'register a' | 1934 @a = 'register a' |
1934 assert_equal('register a', @a) | 1935 assert_equal('register a', @a) |
1939 feedkeys(":echo 'some'\<CR>", "xt") | 1940 feedkeys(":echo 'some'\<CR>", "xt") |
1940 assert_equal("echo 'some'", @:) | 1941 assert_equal("echo 'some'", @:) |
1941 | 1942 |
1942 normal axyz | 1943 normal axyz |
1943 assert_equal("xyz", @.) | 1944 assert_equal("xyz", @.) |
1944 call CheckDefFailure(["@. = 'yes'"], 'E354:') | 1945 call CheckDefFailure(["@. = 'yes'"], 'E354:', 1) |
1945 | 1946 |
1946 @/ = 'slash' | 1947 @/ = 'slash' |
1947 assert_equal('slash', @/) | 1948 assert_equal('slash', @/) |
1948 | 1949 |
1949 @= = 'equal' | 1950 @= = 'equal' |
2024 assert_equal('yes', 'yes' | 2025 assert_equal('yes', 'yes' |
2025 ->s:Echo4Arg()) | 2026 ->s:Echo4Arg()) |
2026 assert_equal(true, !range(5)->empty()) | 2027 assert_equal(true, !range(5)->empty()) |
2027 assert_equal([0, 1, 2], --3->range()) | 2028 assert_equal([0, 1, 2], --3->range()) |
2028 | 2029 |
2029 call CheckDefFailure(["let x = 'yes'->Echo"], 'E107:') | 2030 call CheckDefFailure(["let x = 'yes'->Echo"], 'E107:', 1) |
2030 call CheckScriptFailure([ | 2031 call CheckScriptFailure([ |
2031 "vim9script", | 2032 "vim9script", |
2032 "let x = substitute ('x', 'x', 'x', 'x')" | 2033 "let x = substitute ('x', 'x', 'x', 'x')" |
2033 ], 'E121:') | 2034 ], 'E121:', 2) |
2034 | 2035 |
2035 let auto_lines =<< trim END | 2036 let auto_lines =<< trim END |
2036 def g:some#func(): string | 2037 def g:some#func(): string |
2037 return 'found' | 2038 return 'found' |
2038 enddef | 2039 enddef |
2083 CheckDefSuccess(lines) | 2084 CheckDefSuccess(lines) |
2084 CheckScriptSuccess(['vim9script'] + lines) | 2085 CheckScriptSuccess(['vim9script'] + lines) |
2085 enddef | 2086 enddef |
2086 | 2087 |
2087 func Test_expr7_fails() | 2088 func Test_expr7_fails() |
2088 call CheckDefFailure(["let x = (12"], "E110:") | 2089 call CheckDefFailure(["let x = (12"], "E110:", 1) |
2089 | 2090 |
2090 call CheckDefFailure(["let x = -'xx'"], "E1030:") | 2091 call CheckDefFailure(["let x = -'xx'"], "E1030:", 1) |
2091 call CheckDefFailure(["let x = +'xx'"], "E1030:") | 2092 call CheckDefFailure(["let x = +'xx'"], "E1030:", 1) |
2092 call CheckDefFailure(["let x = -0z12"], "E974:") | 2093 call CheckDefFailure(["let x = -0z12"], "E974:", 1) |
2093 call CheckDefExecFailure(["let x = -[8]"], "E39:") | 2094 call CheckDefExecFailure(["let x = -[8]"], "E39:", 1) |
2094 call CheckDefExecFailure(["let x = -{'a': 1}"], "E39:") | 2095 call CheckDefExecFailure(["let x = -{'a': 1}"], "E39:", 1) |
2095 | 2096 |
2096 call CheckDefFailure(["let x = @"], "E1002:") | 2097 call CheckDefFailure(["let x = @"], "E1002:", 1) |
2097 call CheckDefFailure(["let x = @<"], "E354:") | 2098 call CheckDefFailure(["let x = @<"], "E354:", 1) |
2098 | 2099 |
2099 call CheckDefFailure(["let x = [1, 2"], "E697:") | 2100 call CheckDefFailure(["let x = [1, 2"], "E697:", 2) |
2100 call CheckDefFailure(["let x = [notfound]"], "E1001:") | 2101 call CheckDefFailure(["let x = [notfound]"], "E1001:", 1) |
2101 | 2102 |
2102 call CheckDefFailure(["let x = { -> 123) }"], "E451:") | 2103 call CheckDefFailure(["let x = { -> 123) }"], "E451:", 1) |
2103 call CheckDefFailure(["let x = 123->{x -> x + 5) }"], "E451:") | 2104 call CheckDefFailure(["let x = 123->{x -> x + 5) }"], "E451:", 1) |
2104 | 2105 |
2105 call CheckDefFailure(["let x = ¬exist"], 'E113:') | 2106 call CheckDefFailure(["let x = ¬exist"], 'E113:', 1) |
2106 call CheckDefFailure(["&grepprg = [343]"], 'E1012:') | 2107 call CheckDefFailure(["&grepprg = [343]"], 'E1012:', 1) |
2107 | 2108 |
2108 call CheckDefExecFailure(["echo s:doesnt_exist"], 'E121:') | 2109 call CheckDefExecFailure(["echo s:doesnt_exist"], 'E121:', 1) |
2109 call CheckDefExecFailure(["echo g:doesnt_exist"], 'E121:') | 2110 call CheckDefExecFailure(["echo g:doesnt_exist"], 'E121:', 1) |
2110 | 2111 |
2111 call CheckDefFailure(["echo a:somevar"], 'E1075:') | 2112 call CheckDefFailure(["echo a:somevar"], 'E1075:', 1) |
2112 call CheckDefFailure(["echo l:somevar"], 'E1075:') | 2113 call CheckDefFailure(["echo l:somevar"], 'E1075:', 1) |
2113 call CheckDefFailure(["echo x:somevar"], 'E1075:') | 2114 call CheckDefFailure(["echo x:somevar"], 'E1075:', 1) |
2114 | 2115 |
2115 call CheckDefExecFailure(["let x = +g:astring"], 'E1030:') | 2116 call CheckDefExecFailure(["let x = +g:astring"], 'E1030:', 1) |
2116 call CheckDefExecFailure(["let x = +g:ablob"], 'E974:') | 2117 call CheckDefExecFailure(["let x = +g:ablob"], 'E974:', 1) |
2117 call CheckDefExecFailure(["let x = +g:alist"], 'E745:') | 2118 call CheckDefExecFailure(["let x = +g:alist"], 'E745:', 1) |
2118 call CheckDefExecFailure(["let x = +g:adict"], 'E728:') | 2119 call CheckDefExecFailure(["let x = +g:adict"], 'E728:', 1) |
2119 | 2120 |
2120 call CheckDefFailure(["let x = ''", "let y = x.memb"], 'E715:') | 2121 call CheckDefFailure(["let x = ''", "let y = x.memb"], 'E715:', 2) |
2121 | 2122 |
2122 call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->') | 2123 call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1) |
2123 | 2124 |
2124 call CheckDefExecFailure(["[1, 2->len()"], 'E697:') | 2125 call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) |
2125 call CheckDefExecFailure(["#{a: 1->len()"], 'E488:') | 2126 call CheckDefExecFailure(["#{a: 1->len()"], 'E488:', 1) |
2126 call CheckDefExecFailure(["{'a': 1->len()"], 'E723:') | 2127 call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2) |
2127 endfunc | 2128 endfunc |
2128 | 2129 |
2129 let g:Funcrefs = [function('add')] | 2130 let g:Funcrefs = [function('add')] |
2130 | 2131 |
2131 func CallMe(arg) | 2132 func CallMe(arg) |
2244 CheckDefSuccess(lines) | 2245 CheckDefSuccess(lines) |
2245 CheckScriptSuccess(['vim9script'] + lines) | 2246 CheckScriptSuccess(['vim9script'] + lines) |
2246 | 2247 |
2247 lines = ['let l = [0, 1, 2]', 'echo l[g:astring : g:theone]'] | 2248 lines = ['let l = [0, 1, 2]', 'echo l[g:astring : g:theone]'] |
2248 CheckDefExecFailure(lines, 'E1029:') | 2249 CheckDefExecFailure(lines, 'E1029:') |
2249 CheckScriptFailure(['vim9script'] + lines, 'E1030:') | 2250 CheckScriptFailure(['vim9script'] + lines, 'E1030:', 3) |
2250 enddef | 2251 enddef |
2251 | 2252 |
2252 def Test_expr7_subscript_linebreak() | 2253 def Test_expr7_subscript_linebreak() |
2253 let range = range( | 2254 let range = range( |
2254 3) | 2255 3) |
2305 module: ''} | 2306 module: ''} |
2306 ], getloclist(0)) | 2307 ], getloclist(0)) |
2307 enddef | 2308 enddef |
2308 | 2309 |
2309 func Test_expr7_trailing_fails() | 2310 func Test_expr7_trailing_fails() |
2310 call CheckDefFailure(['let l = [2]', 'l->{l -> add(l, 8)}'], 'E107') | 2311 call CheckDefFailure(['let l = [2]', 'l->{l -> add(l, 8)}'], 'E107:', 2) |
2311 call CheckDefFailure(['let l = [2]', 'l->{l -> add(l, 8)} ()'], 'E274') | 2312 call CheckDefFailure(['let l = [2]', 'l->{l -> add(l, 8)} ()'], 'E274:', 2) |
2312 endfunc | 2313 endfunc |
2313 | 2314 |
2314 func Test_expr_fails() | 2315 func Test_expr_fails() |
2315 call CheckDefFailure(["let x = '1'is2"], 'E488:') | 2316 call CheckDefFailure(["let x = '1'is2"], 'E488:', 1) |
2316 call CheckDefFailure(["let x = '1'isnot2"], 'E488:') | 2317 call CheckDefFailure(["let x = '1'isnot2"], 'E488:', 1) |
2317 | 2318 |
2318 call CheckDefFailure(["CallMe ('yes')"], 'E476:') | 2319 call CheckDefFailure(["CallMe ('yes')"], 'E476:', 1) |
2319 call CheckDefFailure(["CallMe2('yes','no')"], 'E1069:') | 2320 call CheckDefFailure(["CallMe2('yes','no')"], 'E1069:', 1) |
2320 call CheckDefFailure(["CallMe2('yes' , 'no')"], 'E1068:') | 2321 call CheckDefFailure(["CallMe2('yes' , 'no')"], 'E1068:', 1) |
2321 | 2322 |
2322 call CheckDefFailure(["v:nosuch += 3"], 'E1001:') | 2323 call CheckDefFailure(["v:nosuch += 3"], 'E1001:', 1) |
2323 call CheckDefFailure(["let v:statusmsg = ''"], 'E1016: Cannot declare a v: variable:') | 2324 call CheckDefFailure(["let v:statusmsg = ''"], 'E1016: Cannot declare a v: variable:', 1) |
2324 call CheckDefFailure(["let asdf = v:nosuch"], 'E1001:') | 2325 call CheckDefFailure(["let asdf = v:nosuch"], 'E1001:', 1) |
2325 | 2326 |
2326 call CheckDefFailure(["echo len('asdf'"], 'E110:') | 2327 call CheckDefFailure(["echo len('asdf'"], 'E110:', 2) |
2327 call CheckDefFailure(["echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()"], 'E1011:') | 2328 call CheckDefFailure(["echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()"], 'E1011:', 1) |
2328 call CheckDefFailure(["echo doesnotexist()"], 'E117:') | 2329 call CheckDefFailure(["echo doesnotexist()"], 'E117:', 1) |
2329 endfunc | 2330 endfunc |
2330 | 2331 |
2331 " vim: shiftwidth=2 sts=2 expandtab | 2332 " vim: shiftwidth=2 sts=2 expandtab |