Mercurial > vim
comparison src/testdir/test_vimscript.vim @ 15406:63b02fcf1361 v8.1.0711
patch 8.1.0711: test files still use function!
commit https://github.com/vim/vim/commit/1e1153600c0377472d62cc553173fe555ddcf5a7
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 9 23:01:02 2019 +0100
patch 8.1.0711: test files still use function!
Problem: Test files still use function!.
Solution: Remove the exclamation mark. Fix overwriting a function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 09 Jan 2019 23:15:05 +0100 |
parents | 33a2277b8d4d |
children | 05d836c8f1c4 |
comparison
equal
deleted
inserted
replaced
15405:3a8785d45112 | 15406:63b02fcf1361 |
---|---|
3 | 3 |
4 "------------------------------------------------------------------------------- | 4 "------------------------------------------------------------------------------- |
5 " Test environment {{{1 | 5 " Test environment {{{1 |
6 "------------------------------------------------------------------------------- | 6 "------------------------------------------------------------------------------- |
7 | 7 |
8 com! XpathINIT let g:Xpath = '' | 8 com! XpathINIT let g:Xpath = '' |
9 com! -nargs=1 -bar Xpath let g:Xpath = g:Xpath . <args> | 9 com! -nargs=1 -bar Xpath let g:Xpath = g:Xpath . <args> |
10 | 10 |
11 " Append a message to the "messages" file | 11 " Append a message to the "messages" file |
12 func! Xout(text) | 12 func Xout(text) |
13 split messages | 13 split messages |
14 $put =a:text | 14 $put =a:text |
15 wq | 15 wq |
16 endfunc | 16 endfunc |
17 | 17 |
23 " Replace any ":return" by a ":finish", any argument variable by a global | 23 " Replace any ":return" by a ":finish", any argument variable by a global |
24 " variable, and and every ":call" by a ":source" for the next following argument | 24 " variable, and and every ":call" by a ":source" for the next following argument |
25 " in the variable argument list. This function is useful if similar tests are | 25 " in the variable argument list. This function is useful if similar tests are |
26 " to be made for a ":return" from a function call or a ":finish" in a script | 26 " to be made for a ":return" from a function call or a ":finish" in a script |
27 " file. | 27 " file. |
28 function! MakeScript(funcname, ...) | 28 func MakeScript(funcname, ...) |
29 let script = tempname() | 29 let script = tempname() |
30 execute "redir! >" . script | 30 execute "redir! >" . script |
31 execute "function" a:funcname | 31 execute "function" a:funcname |
32 redir END | 32 redir END |
33 execute "edit" script | 33 execute "edit" script |
48 endwhile | 48 endwhile |
49 g/^\s*$/d | 49 g/^\s*$/d |
50 write | 50 write |
51 bwipeout | 51 bwipeout |
52 return script | 52 return script |
53 endfunction | 53 endfunc |
54 | 54 |
55 " ExecAsScript - Source a temporary script made from a function. {{{2 | 55 " ExecAsScript - Source a temporary script made from a function. {{{2 |
56 " | 56 " |
57 " Make a temporary script file from the function a:funcname, ":source" it, and | 57 " Make a temporary script file from the function a:funcname, ":source" it, and |
58 " delete it afterwards. However, if an exception is thrown the file may remain, | 58 " delete it afterwards. However, if an exception is thrown the file may remain, |
299 " the function is defined. For inner functions, do so only if the outer | 299 " the function is defined. For inner functions, do so only if the outer |
300 " function is not being executed. | 300 " function is not being executed. |
301 " | 301 " |
302 let calls = "" | 302 let calls = "" |
303 com! -nargs=1 CALL | 303 com! -nargs=1 CALL |
304 \ if !exists("calls") && !exists("outer") | | 304 \ if !exists("calls") && !exists("outer") | |
305 \ let g:calls = g:calls . <args> | | 305 \ let g:calls = g:calls . <args> | |
306 \ endif | 306 \ endif |
307 | 307 |
308 let i = 0 | 308 let i = 0 |
309 while i < 3 | 309 while i < 3 |
310 let i = i + 1 | 310 let i = i + 1 |
311 if i == 1 | 311 if i == 1 |
355 Xpath 'j' | 355 Xpath 'j' |
356 endif | 356 endif |
357 if exists("*F1") | 357 if exists("*F1") |
358 call F1("F1") | 358 call F1("F1") |
359 if exists("*G1") | 359 if exists("*G1") |
360 call G1("G1") | 360 call G1("G1") |
361 endif | 361 endif |
362 endif | 362 endif |
363 | 363 |
364 if exists("G21") || exists("G22") || exists("G23") | 364 if exists("G21") || exists("G22") || exists("G23") |
365 Xpath 'k' | 365 Xpath 'k' |
366 endif | 366 endif |
367 if exists("*F2") | 367 if exists("*F2") |
368 call F2(2, "F2") | 368 call F2(2, "F2") |
369 if exists("*G21") | 369 if exists("*G21") |
370 call G21("G21") | 370 call G21("G21") |
371 endif | 371 endif |
372 if exists("*G22") | 372 if exists("*G22") |
373 call G22("G22") | 373 call G22("G22") |
374 endif | 374 endif |
375 if exists("*G23") | 375 if exists("*G23") |
376 call G23("G23") | 376 call G23("G23") |
377 endif | 377 endif |
378 endif | 378 endif |
379 | 379 |
380 if exists("G31") || exists("G32") || exists("G33") | 380 if exists("G31") || exists("G32") || exists("G33") |
381 Xpath 'l' | 381 Xpath 'l' |
382 endif | 382 endif |
383 if exists("*F3") | 383 if exists("*F3") |
384 call F3(3, "F3") | 384 call F3(3, "F3") |
385 if exists("*G31") | 385 if exists("*G31") |
386 call G31("G31") | 386 call G31("G31") |
387 endif | 387 endif |
388 if exists("*G32") | 388 if exists("*G32") |
389 call G32("G32") | 389 call G32("G32") |
390 endif | 390 endif |
391 if exists("*G33") | 391 if exists("*G33") |
392 call G33("G33") | 392 call G33("G33") |
393 endif | 393 endif |
394 endif | 394 endif |
395 | 395 |
396 Xpath 'm' | 396 Xpath 'm' |
397 | 397 |
638 let v:errmsg = escape(v:errmsg, '"') | 638 let v:errmsg = escape(v:errmsg, '"') |
639 Xout "Unexpected message:" v:errmsg | 639 Xout "Unexpected message:" v:errmsg |
640 endif | 640 endif |
641 endif | 641 endif |
642 return match | 642 return match |
643 endfunction | 643 endfunc |
644 | 644 |
645 if 1 || strlen("\"") | Xpath 'a' | 645 if 1 || strlen("\"") | Xpath 'a' |
646 Xpath 'b' | 646 Xpath 'b' |
647 endif | 647 endif |
648 Xpath 'c' | 648 Xpath 'c' |
1030 call assert_false(empty(v:true)) | 1030 call assert_false(empty(v:true)) |
1031 call assert_true(empty(v:null)) | 1031 call assert_true(empty(v:null)) |
1032 call assert_true(empty(v:none)) | 1032 call assert_true(empty(v:none)) |
1033 | 1033 |
1034 func ChangeYourMind() | 1034 func ChangeYourMind() |
1035 try | 1035 try |
1036 return v:true | 1036 return v:true |
1037 finally | 1037 finally |
1038 return 'something else' | 1038 return 'something else' |
1039 endtry | 1039 endtry |
1040 endfunc | 1040 endfunc |
1041 | 1041 |
1042 call ChangeYourMind() | 1042 call ChangeYourMind() |
1043 endfunc | 1043 endfunc |
1044 | 1044 |
1248 endfunction | 1248 endfunction |
1249 | 1249 |
1250 func Test_script_lines() | 1250 func Test_script_lines() |
1251 " :append | 1251 " :append |
1252 try | 1252 try |
1253 call DefineFunction('T_Append', [ | 1253 call DefineFunction('T_Append', [ |
1254 \ 'append', | 1254 \ 'append', |
1255 \ 'py <<EOS', | 1255 \ 'py <<EOS', |
1256 \ '.', | 1256 \ '.', |
1257 \ ]) | 1257 \ ]) |
1258 catch | 1258 catch |
1259 call assert_report("Can't define function") | 1259 call assert_report("Can't define function") |
1260 endtry | 1260 endtry |
1261 try | 1261 try |
1262 call DefineFunction('T_Append', [ | 1262 call DefineFunction('T_Append', [ |
1263 \ 'append', | 1263 \ 'append', |
1264 \ 'abc', | 1264 \ 'abc', |
1265 \ ]) | 1265 \ ]) |
1266 call assert_report("Shouldn't be able to define function") | 1266 call assert_report("Shouldn't be able to define function") |
1267 catch | 1267 catch |
1268 call assert_exception('Vim(function):E126: Missing :endfunction') | 1268 call assert_exception('Vim(function):E126: Missing :endfunction') |
1269 endtry | 1269 endtry |
1270 | 1270 |
1271 " :change | 1271 " :change |
1272 try | 1272 try |
1273 call DefineFunction('T_Change', [ | 1273 call DefineFunction('T_Change', [ |
1274 \ 'change', | 1274 \ 'change', |
1275 \ 'py <<EOS', | 1275 \ 'py <<EOS', |
1276 \ '.', | 1276 \ '.', |
1277 \ ]) | 1277 \ ]) |
1278 catch | 1278 catch |
1279 call assert_report("Can't define function") | 1279 call assert_report("Can't define function") |
1280 endtry | 1280 endtry |
1281 try | 1281 try |
1282 call DefineFunction('T_Change', [ | 1282 call DefineFunction('T_Change', [ |
1283 \ 'change', | 1283 \ 'change', |
1284 \ 'abc', | 1284 \ 'abc', |
1285 \ ]) | 1285 \ ]) |
1286 call assert_report("Shouldn't be able to define function") | 1286 call assert_report("Shouldn't be able to define function") |
1287 catch | 1287 catch |
1288 call assert_exception('Vim(function):E126: Missing :endfunction') | 1288 call assert_exception('Vim(function):E126: Missing :endfunction') |
1289 endtry | 1289 endtry |
1290 | 1290 |
1291 " :insert | 1291 " :insert |
1292 try | 1292 try |
1293 call DefineFunction('T_Insert', [ | 1293 call DefineFunction('T_Insert', [ |
1294 \ 'insert', | 1294 \ 'insert', |
1295 \ 'py <<EOS', | 1295 \ 'py <<EOS', |
1296 \ '.', | 1296 \ '.', |
1297 \ ]) | 1297 \ ]) |
1298 catch | 1298 catch |
1299 call assert_report("Can't define function") | 1299 call assert_report("Can't define function") |
1300 endtry | 1300 endtry |
1301 try | 1301 try |
1302 call DefineFunction('T_Insert', [ | 1302 call DefineFunction('T_Insert', [ |
1303 \ 'insert', | 1303 \ 'insert', |
1304 \ 'abc', | 1304 \ 'abc', |
1305 \ ]) | 1305 \ ]) |
1306 call assert_report("Shouldn't be able to define function") | 1306 call assert_report("Shouldn't be able to define function") |
1307 catch | 1307 catch |
1308 call assert_exception('Vim(function):E126: Missing :endfunction') | 1308 call assert_exception('Vim(function):E126: Missing :endfunction') |
1309 endtry | 1309 endtry |
1310 endfunc | 1310 endfunc |
1311 | 1311 |
1312 "------------------------------------------------------------------------------- | 1312 "------------------------------------------------------------------------------- |
1313 " Test 96: line continuation {{{1 | 1313 " Test 96: line continuation {{{1 |
1314 " | 1314 " |
1315 " Undefined behavior was detected by ubsan with line continuation | 1315 " Undefined behavior was detected by ubsan with line continuation |
1316 " after an empty line. | 1316 " after an empty line. |
1317 "------------------------------------------------------------------------------- | 1317 "------------------------------------------------------------------------------- |
1318 func Test_script_emty_line_continuation() | 1318 func Test_script_emty_line_continuation() |
1319 | 1319 |
1320 \ | 1320 \ |
1321 endfunc | 1321 endfunc |