comparison src/testdir/test_vim9_script.vim @ 27970:212c5894b8b1 v8.2.4510

patch 8.2.4510: Vim9: shortening commands leads to confusing script Commit: https://github.com/vim/vim/commit/204852ae2adfdde10c656ca7f14e5b4207a69172 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 5 12:56:44 2022 +0000 patch 8.2.4510: Vim9: shortening commands leads to confusing script Problem: Vim9: shortening commands leads to confusing script. Solution: In Vim9 script require at least ":cont" for ":continue", "const" instead of "cons", "break" instead of "brea", "catch" instead of "cat", "else" instead of "el" "elseif" instead of "elsei" "endfor" instead of "endfo" "endif" instead of "en" "endtry" instead of "endt", "finally" instead of "fina", "throw" instead of "th", "while" instead of "wh".
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Mar 2022 14:00:03 +0100
parents 80f398bfc19f
children 442ca2007bec
comparison
equal deleted inserted replaced
27969:0e58183b329e 27970:212c5894b8b1
458 catch /right/ 458 catch /right/
459 add(l, v:exception) 459 add(l, v:exception)
460 endtry 460 endtry
461 catch /wrong/ 461 catch /wrong/
462 add(l, 'caught') 462 add(l, 'caught')
463 fina 463 finally
464 add(l, 'finally') 464 add(l, 'finally')
465 endtry 465 endtry
466 assert_equal(['1', 'caught', 'finally'], l) 466 assert_equal(['1', 'caught', 'finally'], l)
467 467
468 var n: number 468 var n: number
1002 enddef 1002 enddef
1003 1003
1004 def s:ReturnFinally(): string 1004 def s:ReturnFinally(): string
1005 try 1005 try
1006 return 'intry' 1006 return 'intry'
1007 finall 1007 finally
1008 g:in_finally = 'finally' 1008 g:in_finally = 'finally'
1009 endtry 1009 endtry
1010 return 'end' 1010 return 'end'
1011 enddef 1011 enddef
1012 1012
3372 3372
3373 # clean up 3373 # clean up
3374 g:StopVimInTerminal(buf) 3374 g:StopVimInTerminal(buf)
3375 enddef 3375 enddef
3376 3376
3377 def Test_minimal_command_name_length()
3378 var names = [
3379 'cons',
3380 'brea',
3381 'cat',
3382 'catc',
3383 'con',
3384 'el',
3385 'els',
3386 'elsei',
3387 'endfo',
3388 'en',
3389 'end',
3390 'endi',
3391 'endw',
3392 'endt',
3393 'endtr',
3394 'fina',
3395 'finall',
3396 'th',
3397 'thr',
3398 'thro',
3399 'wh',
3400 'whi',
3401 'whil',
3402 ]
3403 for name in names
3404 v9.CheckDefAndScriptFailure([name .. ' '], 'E1065:')
3405 endfor
3406 enddef
3407
3377 def Test_unset_any_variable() 3408 def Test_unset_any_variable()
3378 var lines =<< trim END 3409 var lines =<< trim END
3379 var name: any 3410 var name: any
3380 assert_equal(0, name) 3411 assert_equal(0, name)
3381 END 3412 END