@@ -112,6 +112,8 @@ def Test_assignment()
112112 call CheckDefFailure ([' ¬ex += 3' ], ' E113:' )
113113 call CheckDefFailure ([' &ts ..= "xxx"' ], ' E1019:' )
114114 call CheckDefFailure ([' &path += 3' ], ' E1013:' )
115+ " test freeing ISN_STOREOPT
116+ call CheckDefFailure ([' &ts = 3' , ' let asdf' ], ' E1022:' )
115117 &ts = 8
116118
117119 g: inc_counter += 1
@@ -171,6 +173,9 @@ def Test_assignment()
171173 let thechannel: channel
172174 assert_equal (test_null_channel (), thechannel)
173175 endif
176+
177+ let nr = 1234 | nr = 5678
178+ assert_equal (5678 , nr)
174179enddef
175180
176181func Test_assignment_failure ()
@@ -253,8 +258,16 @@ enddef
253258
254259func Test_block_failure ()
255260 call CheckDefFailure ([' {' , ' let inner = 1' , ' }' , ' echo inner' ], ' E1001:' )
261+ call CheckDefFailure ([' }' ], ' E1025:' )
262+ call CheckDefFailure ([' {' , ' echo 1' ], ' E1026:' )
256263endfunc
257264
265+ def Test_cmd_modifier ()
266+ tab echo ' 0'
267+ call CheckDefFailure ([' 5tab echo 3' ], ' E16:' )
268+ enddef
269+
270+
258271def ReturnString (): string
259272 return ' string'
260273enddef
@@ -326,6 +339,8 @@ def Test_call_default_args()
326339 assert_equal (' string' , MyDefaultArgs ())
327340 assert_equal (' one' , MyDefaultArgs (' one' ))
328341 assert_fails (' call MyDefaultArgs("one", "two")' , ' E118:' )
342+
343+ call CheckScriptFailure ([' def Func(arg: number = asdf)' , ' enddef' ], ' E1001:' )
329344enddef
330345
331346func Test_call_default_args_from_func ()
@@ -480,6 +495,16 @@ def Test_try_catch_fails()
480495 call CheckDefFailure ([' catch' ], ' E603:' )
481496 call CheckDefFailure ([' try' , ' echo 0' , ' catch' ,' catch' ], ' E1033:' )
482497 call CheckDefFailure ([' try' , ' echo 0' , ' catch /pat' ], ' E1067:' )
498+ call CheckDefFailure ([' finally' ], ' E606:' )
499+ call CheckDefFailure ([' try' , ' echo 0' , ' finally' , ' echo 1' , ' finally' ], ' E607:' )
500+ call CheckDefFailure ([' endtry' ], ' E602:' )
501+ call CheckDefFailure ([' while 1' , ' endtry' ], ' E170:' )
502+ call CheckDefFailure ([' for i in range(5)' , ' endtry' ], ' E170:' )
503+ call CheckDefFailure ([' if 2' , ' endtry' ], ' E171:' )
504+ call CheckDefFailure ([' try' , ' echo 1' , ' endtry' ], ' E1032:' )
505+
506+ call CheckDefFailure ([' throw' ], ' E471:' )
507+ call CheckDefFailure ([' throw xxx' ], ' E1001:' )
483508enddef
484509
485510let s: export_script_lines = << trim END
@@ -939,6 +964,7 @@ def Test_if_elseif_else_fails()
939964 call CheckDefFailure ([' else' ], ' E581:' )
940965 call CheckDefFailure ([' endif' ], ' E580:' )
941966 call CheckDefFailure ([' if true' , ' elseif xxx' ], ' E1001:' )
967+ call CheckDefFailure ([' if true' , ' echo 1' ], ' E171:' )
942968enddef
943969
944970let g: bool_true = v: true
@@ -951,6 +977,16 @@ def Test_if_const_expr()
951977 endif
952978 assert_equal (true, res )
953979
980+ g: glob = 2
981+ if false
982+ execute (' let g:glob = 3' )
983+ endif
984+ assert_equal (2 , g: glob )
985+ if true
986+ execute (' let g:glob = 3' )
987+ endif
988+ assert_equal (3 , g: glob )
989+
954990 res = false
955991 if g: bool_true ? true : false
956992 res = true
@@ -1092,10 +1128,13 @@ def Test_execute_cmd()
10921128 execute cmd_first .. cmd_last
10931129 assert_equal (' execute-var-var' , getline (1 ))
10941130 bwipe!
1131+
1132+ call CheckDefFailure ([' execute xxx' ], ' E1001:' )
10951133enddef
10961134
10971135def Test_echo_cmd ()
1098- echo ' something'
1136+ echo ' some'
1137+ echon ' thing'
10991138 assert_match (' ^something$' , Screenline (&lines ))
11001139
11011140 let str1 = ' some'
@@ -1141,6 +1180,7 @@ def Test_for_loop_fails()
11411180 call CheckDefFailure ([' for i in "text"' ], ' E1024:' )
11421181 call CheckDefFailure ([' for i in xxx' ], ' E1001:' )
11431182 call CheckDefFailure ([' endfor' ], ' E588:' )
1183+ call CheckDefFailure ([' for i in range(3)' , ' echo 3' ], ' E170:' )
11441184enddef
11451185
11461186def Test_while_loop ()
@@ -1166,6 +1206,7 @@ def Test_while_loop_fails()
11661206 call CheckDefFailure ([' if true' , ' continue' ], ' E586:' )
11671207 call CheckDefFailure ([' break' ], ' E587:' )
11681208 call CheckDefFailure ([' if true' , ' break' ], ' E587:' )
1209+ call CheckDefFailure ([' while 1' , ' echo 3' ], ' E170:' )
11691210enddef
11701211
11711212def Test_interrupt_loop ()
@@ -1185,28 +1226,6 @@ def Test_interrupt_loop()
11851226 assert_true (caught, ' should have caught an exception' )
11861227enddef
11871228
1188- def Test_substitute_cmd ()
1189- new
1190- setline (1 , ' something' )
1191- : substitute (some (other (
1192- assert_equal (' otherthing' , getline (1 ))
1193- bwipe!
1194-
1195- " also when the context is Vim9 script
1196- let lines = << trim END
1197- vim9script
1198- new
1199- setline (1 , ' something' )
1200- : substitute (some (other (
1201- assert_equal (' otherthing' , getline (1 ))
1202- bwipe!
1203- END
1204- writefile (lines , ' Xvim9lines' )
1205- source Xvim9lines
1206-
1207- delete (' Xvim9lines' )
1208- enddef
1209-
12101229def Test_redef_failure ()
12111230 call writefile ([' def Func0(): string' , ' return "Func0"' , ' enddef' ], ' Xdef' )
12121231 so Xdef
@@ -1285,4 +1304,27 @@ func Test_internalfunc_arg_error()
12851304 call delete (' Xinvalidarg' )
12861305endfunc
12871306
1307+ " Keep this last, it messes up highlighting.
1308+ def Test_substitute_cmd ()
1309+ new
1310+ setline (1 , ' something' )
1311+ : substitute (some (other (
1312+ assert_equal (' otherthing' , getline (1 ))
1313+ bwipe!
1314+
1315+ " also when the context is Vim9 script
1316+ let lines = << trim END
1317+ vim9script
1318+ new
1319+ setline (1 , ' something' )
1320+ : substitute (some (other (
1321+ assert_equal (' otherthing' , getline (1 ))
1322+ bwipe!
1323+ END
1324+ writefile (lines , ' Xvim9lines' )
1325+ source Xvim9lines
1326+
1327+ delete (' Xvim9lines' )
1328+ enddef
1329+
12881330" vim: ts = 8 sw = 2 sts = 2 expandtab tw = 80 fdm = marker
0 commit comments