From 62aec93bfdb9e1b40d03a6d2e8e9511f8b1bdb2d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 29 Jan 2022 21:45:34 +0000 Subject: patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent Problem: Vim9: finding global function without g: prefix but not finding global variable is inconsistent. Solution: Require using g: for a global function. Change the vim9.vim script into a Vim9 script with exports. Fix that import in legacy script does not work. --- src/testdir/test_blob.vim | 130 +-- src/testdir/test_debugger.vim | 18 +- src/testdir/test_execute_func.vim | 4 +- src/testdir/test_expr.vim | 116 +- src/testdir/test_filter_map.vim | 10 +- src/testdir/test_float_func.vim | 4 +- src/testdir/test_functions.vim | 12 +- src/testdir/test_glob2regpat.vim | 4 +- src/testdir/test_highlight.vim | 22 +- src/testdir/test_iminsert.vim | 22 +- src/testdir/test_ins_complete.vim | 46 +- src/testdir/test_listdict.vim | 158 +-- src/testdir/test_mapping.vim | 8 +- src/testdir/test_normal.vim | 6 +- src/testdir/test_popupwin.vim | 2 +- src/testdir/test_profile.vim | 1 - src/testdir/test_quickfix.vim | 14 +- src/testdir/test_tagfunc.vim | 16 +- src/testdir/test_textprop.vim | 14 +- src/testdir/test_usercommands.vim | 12 +- src/testdir/test_vim9_assign.vim | 530 ++++----- src/testdir/test_vim9_builtin.vim | 2072 +++++++++++++++++---------------- src/testdir/test_vim9_cmd.vim | 244 ++-- src/testdir/test_vim9_disassemble.vim | 72 +- src/testdir/test_vim9_expr.vim | 1192 +++++++++---------- src/testdir/test_vim9_func.vim | 638 +++++----- src/testdir/test_vim9_import.vim | 144 +-- src/testdir/test_vim9_script.vim | 754 ++++++------ src/testdir/vim9.vim | 122 +- 29 files changed, 3208 insertions(+), 3179 deletions(-) (limited to 'src/testdir') diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim index 69c86963c..e8bc2c9da 100644 --- a/src/testdir/test_blob.vim +++ b/src/testdir/test_blob.vim @@ -1,6 +1,6 @@ " Tests for the Blob types -source vim9.vim +import './vim9.vim' as v9 func TearDown() " Run garbage collection after every test @@ -39,7 +39,7 @@ func Test_blob_create() call assert_equal(0, len(test_null_blob())) call assert_equal(0z, copy(test_null_blob())) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " assignment to a blob @@ -75,49 +75,49 @@ func Test_blob_assign() VAR m = deepcopy(l) LET m[0] = 0z34 #" E742 or E741 should not occur. END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b = 0zDEADBEEF LET b[2 : 3] = 0z112233 END - call CheckLegacyAndVim9Failure(lines, 'E972:') + call v9.CheckLegacyAndVim9Failure(lines, 'E972:') let lines =<< trim END VAR b = 0zDEADBEEF LET b[2 : 3] = 0z11 END - call CheckLegacyAndVim9Failure(lines, 'E972:') + call v9.CheckLegacyAndVim9Failure(lines, 'E972:') let lines =<< trim END VAR b = 0zDEADBEEF LET b[3 : 2] = 0z END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0zDEADBEEF LET b ..= 0z33 END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) let lines =<< trim END VAR b = 0zDEADBEEF LET b ..= "xx" END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:']) let lines =<< trim END VAR b = 0zDEADBEEF LET b += "xx" END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) let lines =<< trim END VAR b = 0zDEADBEEF LET b[1 : 1] ..= 0z55 END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:']) endfunc func Test_blob_get_range() @@ -133,7 +133,7 @@ func Test_blob_get_range() call assert_equal(0z, b[5 : 6]) call assert_equal(0z0011, b[-10 : 1]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " legacy script white space let b = 0z0011223344 @@ -158,19 +158,19 @@ func Test_blob_get() call assert_equal(0x44, b[4]) call assert_equal(0x44, b[-1]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b = 0z0011223344 echo b[5] END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0z0011223344 echo b[-8] END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') endfunc func Test_blob_to_string() @@ -184,7 +184,7 @@ func Test_blob_to_string() call assert_equal('0z', string(b)) call assert_equal('0z', string(test_null_blob())) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_compare() @@ -211,54 +211,54 @@ func Test_blob_compare() call assert_false(b1 is b2) call assert_true(b1 isnot b2) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b1 = 0z0011 echo b1 == 9 END - call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) + call v9.CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) let lines =<< trim END VAR b1 = 0z0011 echo b1 != 9 END - call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) + call v9.CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 > b2 END - call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 < b2 END - call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 - b2 END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 / b2 END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) let lines =<< trim END VAR b1 = 0z0011 VAR b2 = 0z1100 VAR x = b1 * b2 END - call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:']) endfunc func Test_blob_index_assign() @@ -268,19 +268,19 @@ func Test_blob_index_assign() LET b[2] = 0x22 call assert_equal(0z001122, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b = 0z00 LET b[2] = 0x33 END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0z00 LET b[-2] = 0x33 END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') endfunc func Test_blob_for_loop() @@ -313,7 +313,7 @@ func Test_blob_for_loop() endfor call assert_equal(5, i) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_concatenate() @@ -325,19 +325,19 @@ func Test_blob_concatenate() LET b = 0zDEAD + 0zBEEF call assert_equal(0zDEADBEEF, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR b = 0z0011 LET b += "a" END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) let lines =<< trim END VAR b = 0z0011 LET b += 88 END - call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:']) endfunc func Test_blob_add() @@ -346,7 +346,7 @@ func Test_blob_add() call add(b, 0x22) call assert_equal(0z001122, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Only works in legacy script let b = 0z0011 @@ -358,18 +358,18 @@ func Test_blob_add() VAR b = 0z0011 call add(b, [9]) END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E1210:']) let lines =<< trim END VAR b = 0z0011 call add("", 0x01) END - call CheckLegacyAndVim9Failure(lines, ['E897:', 'E1013:', 'E1226:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E897:', 'E1013:', 'E1226:']) let lines =<< trim END add(test_null_blob(), 0x22) END - call CheckDefExecAndScriptFailure(lines, 'E1131:') + call v9.CheckDefExecAndScriptFailure(lines, 'E1131:') let lines =<< trim END let b = 0zDEADBEEF @@ -377,7 +377,7 @@ func Test_blob_add() call add(b, 0) unlockvar b END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_empty() @@ -411,32 +411,32 @@ func Test_blob_func_remove() call assert_equal(0zADBE, remove(b, 1, 2)) call assert_equal(0zDEEF, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test invalid cases let lines =<< trim END VAR b = 0zDEADBEEF call remove(b, 5) END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0zDEADBEEF call remove(b, 1, 5) END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0zDEADBEEF call remove(b, 3, 2) END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END VAR b = 0zDEADBEEF call remove(test_null_blob(), 1, 2) END - call CheckLegacyAndVim9Failure(lines, 'E979:') + call v9.CheckLegacyAndVim9Failure(lines, 'E979:') let lines =<< trim END let b = 0zDEADBEEF @@ -444,7 +444,7 @@ func Test_blob_func_remove() call remove(b, 0) unlockvar b END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') " can only check at script level, not in a :def function let lines =<< trim END @@ -453,7 +453,7 @@ func Test_blob_func_remove() lockvar b remove(b, 0) END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') call assert_fails('echo remove(0z1020, [])', 'E745:') call assert_fails('echo remove(0z1020, 0, [])', 'E745:') @@ -467,7 +467,7 @@ func Test_blob_read_write() call assert_equal(b, br) call delete('Xblob') END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " This was crashing when calling readfile() with a directory. call assert_fails("call readfile('.', 'B')", 'E17: "." is a directory') @@ -485,7 +485,7 @@ func Test_blob_filter() call assert_equal(0z01030103, filter(0z010203010203, 'v:val != 0x02')) call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2')) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_fails('echo filter(0z10, "a10")', 'E121:') endfunc @@ -496,12 +496,12 @@ func Test_blob_map() call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key')) call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val')) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END call map(0z00, '[9]') END - call CheckLegacyAndVim9Failure(lines, 'E978:') + call v9.CheckLegacyAndVim9Failure(lines, 'E978:') call assert_fails('echo map(0z10, "a10")', 'E121:') endfunc @@ -516,7 +516,7 @@ func Test_blob_index() call assert_equal(0, index(0z11110111, 0x11, -10)) call assert_equal(-1, index(test_null_blob(), 1)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_insert() @@ -529,7 +529,7 @@ func Test_blob_insert() call insert(b, 0x33, 2) call assert_equal(0zDEAD33BEEF, b) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " only works in legacy script call assert_equal(0, insert(test_null_blob(), 0x33)) @@ -538,42 +538,42 @@ func Test_blob_insert() VAR b = 0zDEADBEEF call insert(b, -1) END - call CheckLegacyAndVim9Failure(lines, 'E475:') + call v9.CheckLegacyAndVim9Failure(lines, 'E475:') let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, 257) END - call CheckLegacyAndVim9Failure(lines, 'E475:') + call v9.CheckLegacyAndVim9Failure(lines, 'E475:') let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, 0, [9]) END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, 0, -20) END - call CheckLegacyAndVim9Failure(lines, 'E475:') + call v9.CheckLegacyAndVim9Failure(lines, 'E475:') let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, 0, 20) END - call CheckLegacyAndVim9Failure(lines, 'E475:') + call v9.CheckLegacyAndVim9Failure(lines, 'E475:') let lines =<< trim END VAR b = 0zDEADBEEF call insert(b, []) END - call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:']) let lines =<< trim END insert(test_null_blob(), 0x33) END - call CheckDefExecAndScriptFailure(lines, 'E1131:') + call v9.CheckDefExecAndScriptFailure(lines, 'E1131:') let lines =<< trim END let b = 0zDEADBEEF @@ -581,7 +581,7 @@ func Test_blob_insert() call insert(b, 3) unlockvar b END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') let lines =<< trim END vim9script @@ -589,7 +589,7 @@ func Test_blob_insert() lockvar b insert(b, 3) END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_reverse() @@ -600,7 +600,7 @@ func Test_blob_reverse() call assert_equal(0zDE, reverse(0zDE)) call assert_equal(0z, reverse(test_null_blob())) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_json_encode() @@ -608,7 +608,7 @@ func Test_blob_json_encode() call assert_equal('[222,173,190,239]', json_encode(0zDEADBEEF)) call assert_equal('[]', json_encode(0z)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_blob_lock() @@ -618,7 +618,7 @@ func Test_blob_lock() unlockvar b let b = 0z44 END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) let lines =<< trim END vim9script @@ -627,14 +627,14 @@ func Test_blob_lock() unlockvar b b = 0z44 END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) let lines =<< trim END let b = 0z112233 lockvar b let b = 0z44 END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') let lines =<< trim END vim9script @@ -642,14 +642,14 @@ func Test_blob_lock() lockvar b b = 0z44 END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_sort() if has('float') - call CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') + call v9.CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:') endif - call CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') + call v9.CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:') endfunc " Tests for the blob2list() function diff --git a/src/testdir/test_debugger.vim b/src/testdir/test_debugger.vim index 0c4bc870d..c05f4e1e4 100644 --- a/src/testdir/test_debugger.vim +++ b/src/testdir/test_debugger.vim @@ -360,16 +360,16 @@ def Test_Debugger_breakadd_expr() writefile(lines, 'Xtest.vim') # Start Vim in a terminal - var buf = RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0}) - call TermWait(buf) + var buf = g:RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0}) + call g:TermWait(buf) # Despite the failure the functions are defined - RunDbgCmd(buf, ':function g:EarlyFunc', + g:RunDbgCmd(buf, ':function g:EarlyFunc', ['function EarlyFunc()', 'endfunction'], {match: 'pattern'}) - RunDbgCmd(buf, ':function g:LaterFunc', + g:RunDbgCmd(buf, ':function g:LaterFunc', ['function LaterFunc()', 'endfunction'], {match: 'pattern'}) - call StopVimInTerminal(buf) + call g:StopVimInTerminal(buf) call delete('Xtest.vim') enddef @@ -386,13 +386,13 @@ def Test_Debugger_break_at_return() writefile(lines, 'Xtest.vim') # Start Vim in a terminal - var buf = RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0}) - call TermWait(buf) + var buf = g:RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0}) + call g:TermWait(buf) - RunDbgCmd(buf, ':call GetNum()', + g:RunDbgCmd(buf, ':call GetNum()', ['line 1: return 1 + 2 + 3'], {match: 'pattern'}) - call StopVimInTerminal(buf) + call g:StopVimInTerminal(buf) call delete('Xtest.vim') enddef diff --git a/src/testdir/test_execute_func.vim b/src/testdir/test_execute_func.vim index 8cd5e7d27..3a8580e98 100644 --- a/src/testdir/test_execute_func.vim +++ b/src/testdir/test_execute_func.vim @@ -2,7 +2,7 @@ source view_util.vim source check.vim -source vim9.vim +import './vim9.vim' as v9 source term_util.vim func NestedEval() @@ -41,7 +41,7 @@ func Test_execute_string() if has('float') call assert_fails('call execute(3.4)', 'E492:') call assert_equal("\nx", execute("echo \"x\"", 3.4)) - call CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1174:']) + call v9.CheckDefExecAndScriptFailure(['execute("echo \"x\"", 3.4)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1174:']) endif endfunc diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 8a65a8990..4d085de1d 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -1,7 +1,7 @@ " Tests for expressions. source check.vim -source vim9.vim +import './vim9.vim' as v9 func Test_equal() let base = {} @@ -51,12 +51,12 @@ func Test_op_trinary() call assert_fails('echo [1] ? "yes" : "no"', 'E745:') call assert_fails('echo {} ? "yes" : "no"', 'E728:') END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_equal('no', 'x' ? 'yes' : 'no') - call CheckDefAndScriptFailure(["'x' ? 'yes' : 'no'"], 'E1135:') + call v9.CheckDefAndScriptFailure(["'x' ? 'yes' : 'no'"], 'E1135:') call assert_equal('yes', '1x' ? 'yes' : 'no') - call CheckDefAndScriptFailure(["'1x' ? 'yes' : 'no'"], 'E1135:') + call v9.CheckDefAndScriptFailure(["'1x' ? 'yes' : 'no'"], 'E1135:') endfunc func Test_op_falsy() @@ -81,7 +81,7 @@ func Test_op_falsy() call assert_equal(456, 0.0 ?? 456) endif END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_dict() @@ -101,9 +101,9 @@ func Test_dict() LET d[ 'b' ] = 'bbb' call assert_equal('bbb', d[ 'b' ]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(["VAR i = has_key([], 'a')"], ['E715:', 'E1013:', 'E1206:']) + call v9.CheckLegacyAndVim9Failure(["VAR i = has_key([], 'a')"], ['E715:', 'E1013:', 'E1206:']) endfunc func Test_strgetchar() @@ -116,10 +116,10 @@ func Test_strgetchar() call assert_equal(-1, strgetchar('axb', 3)) call assert_equal(-1, strgetchar('', 0)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(["VAR c = strgetchar([], 1)"], ['E730:', 'E1013:', 'E1174:']) - call CheckLegacyAndVim9Failure(["VAR c = strgetchar('axb', [])"], ['E745:', 'E1013:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(["VAR c = strgetchar([], 1)"], ['E730:', 'E1013:', 'E1174:']) + call v9.CheckLegacyAndVim9Failure(["VAR c = strgetchar('axb', [])"], ['E745:', 'E1013:', 'E1210:']) endfunc func Test_strcharpart() @@ -138,7 +138,7 @@ func Test_strcharpart() call assert_equal('edit', "editor"[-10 : 3]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_getreg_empty_list() @@ -150,9 +150,9 @@ func Test_getreg_empty_list() call add(x, 'foo') call assert_equal(['foo'], y) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(['call getreg([])'], ['E730:', 'E1013:', 'E1174:']) + call v9.CheckLegacyAndVim9Failure(['call getreg([])'], ['E730:', 'E1013:', 'E1174:']) endfunc func Test_loop_over_null_list() @@ -162,19 +162,19 @@ func Test_loop_over_null_list() call assert_report('should not get here') endfor END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_setreg_null_list() let lines =<< trim END call setreg('x', test_null_list()) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_special_char() " The failure is only visible using valgrind. - call CheckLegacyAndVim9Failure(['echo "\'], ['E15:', 'E1004:', 'E1004:']) + call v9.CheckLegacyAndVim9Failure(['echo "\'], ['E15:', 'E1004:', 'E1004:']) endfunc func Test_method_with_prefix() @@ -182,13 +182,13 @@ func Test_method_with_prefix() call assert_equal(TRUE, !range(5)->empty()) call assert_equal(FALSE, !-3) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_equal([0, 1, 2], --3->range()) - call CheckDefAndScriptFailure(['eval --3->range()'], 'E15') + call v9.CheckDefAndScriptFailure(['eval --3->range()'], 'E15') call assert_equal(1, !+-+0) - call CheckDefAndScriptFailure(['eval !+-+0'], 'E15') + call v9.CheckDefAndScriptFailure(['eval !+-+0'], 'E15') endfunc func Test_option_value() @@ -214,7 +214,7 @@ func Test_option_value() call assert_equal("abcdefgi", &cpo) set cpo&vim END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_printf_misc() @@ -407,9 +407,9 @@ func Test_printf_misc() call assert_equal('1%', printf('%d%%', 1)) call assert_notequal('', printf('%p', "abc")) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:") + call v9.CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:") endfunc func Test_printf_float() @@ -519,21 +519,21 @@ func Test_printf_float() call assert_equal('nan', printf('%S', 0.0 / 0.0)) call assert_equal('nan', printf('%S', -0.0 / 0.0)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:') endif endfunc func Test_printf_errors() - call CheckLegacyAndVim9Failure(['echo printf("%d", {})'], 'E728:') - call CheckLegacyAndVim9Failure(['echo printf("%d", [])'], 'E745:') - call CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:') - call CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:') - call CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%d", {})'], 'E728:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%d", [])'], 'E745:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:') if has('float') - call CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:') - call CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:') endif endfunc @@ -541,7 +541,7 @@ func Test_printf_64bit() let lines =<< trim END call assert_equal("123456789012345", printf('%d', 123456789012345)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_printf_spec_s() @@ -571,7 +571,7 @@ func Test_printf_spec_s() #" partial call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s']))) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_printf_spec_b() @@ -587,14 +587,14 @@ func Test_printf_spec_b() call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345)) call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_max_min_errors() - call CheckLegacyAndVim9Failure(['call max(v:true)'], ['E712:', 'E1013:', 'E1227:']) - call CheckLegacyAndVim9Failure(['call max(v:true)'], ['max()', 'E1013:', 'E1227:']) - call CheckLegacyAndVim9Failure(['call min(v:true)'], ['E712:', 'E1013:', 'E1227:']) - call CheckLegacyAndVim9Failure(['call min(v:true)'], ['min()', 'E1013:', 'E1227:']) + call v9.CheckLegacyAndVim9Failure(['call max(v:true)'], ['E712:', 'E1013:', 'E1227:']) + call v9.CheckLegacyAndVim9Failure(['call max(v:true)'], ['max()', 'E1013:', 'E1227:']) + call v9.CheckLegacyAndVim9Failure(['call min(v:true)'], ['E712:', 'E1013:', 'E1227:']) + call v9.CheckLegacyAndVim9Failure(['call min(v:true)'], ['min()', 'E1013:', 'E1227:']) endfunc func Test_function_with_funcref() @@ -615,9 +615,9 @@ func Test_function_with_funcref() call execute('VAR Ref = ' .. name) call assert_equal(4, Ref('text')) END - call CheckTransLegacySuccess(lines) + call v9.CheckTransLegacySuccess(lines) " cannot create s: variable in :def function - call CheckTransVim9Success(lines) + call v9.CheckTransVim9Success(lines) endfunc func Test_funcref() @@ -668,9 +668,9 @@ func Test_setmatches() eval set->setmatches() call assert_equal(exp, getmatches()) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(['VAR m = setmatches([], [])'], ['E745:', 'E1013:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(['VAR m = setmatches([], [])'], ['E745:', 'E1013:', 'E1210:']) endfunc func Test_empty_concatenate() @@ -678,19 +678,19 @@ func Test_empty_concatenate() call assert_equal('b', 'a'[4 : 0] .. 'b') call assert_equal('b', 'b' .. 'a'[4 : 0]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_broken_number() - call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 1X'], 'E15:') - call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0b1X'], 'E15:') - call CheckLegacyAndVim9Failure(['echo 0b12'], 'E15:') - call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0x1X'], 'E15:') - call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 011X'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 1X'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0b1X'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['echo 0b12'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0x1X'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 011X'], 'E15:') - call CheckLegacyAndVim9Success(['call assert_equal(2, str2nr("2a"))']) + call v9.CheckLegacyAndVim9Success(['call assert_equal(2, str2nr("2a"))']) - call CheckLegacyAndVim9Failure(['inoremap b'], 'E474:') + call v9.CheckLegacyAndVim9Failure(['inoremap b'], 'E474:') endfunc func Test_eval_after_if() @@ -783,11 +783,11 @@ endfunc " Test for errors in expression evaluation func Test_expr_eval_error() - call CheckLegacyAndVim9Failure(["VAR i = 'abc' .. []"], ['E730:', 'E1105:', 'E730:']) - call CheckLegacyAndVim9Failure(["VAR l = [] + 10"], ['E745:', 'E1051:', 'E745']) - call CheckLegacyAndVim9Failure(["VAR v = 10 + []"], ['E745:', 'E1051:', 'E745:']) - call CheckLegacyAndVim9Failure(["VAR v = 10 / []"], ['E745:', 'E1036:', 'E745:']) - call CheckLegacyAndVim9Failure(["VAR v = -{}"], ['E728:', 'E1012:', 'E728:']) + call v9.CheckLegacyAndVim9Failure(["VAR i = 'abc' .. []"], ['E730:', 'E1105:', 'E730:']) + call v9.CheckLegacyAndVim9Failure(["VAR l = [] + 10"], ['E745:', 'E1051:', 'E745']) + call v9.CheckLegacyAndVim9Failure(["VAR v = 10 + []"], ['E745:', 'E1051:', 'E745:']) + call v9.CheckLegacyAndVim9Failure(["VAR v = 10 / []"], ['E745:', 'E1036:', 'E745:']) + call v9.CheckLegacyAndVim9Failure(["VAR v = -{}"], ['E728:', 'E1012:', 'E728:']) endfunc func Test_white_in_function_call() @@ -795,13 +795,13 @@ func Test_white_in_function_call() VAR text = substitute ( 'some text' , 't' , 'T' , 'g' ) call assert_equal('some TexT', text) END - call CheckTransLegacySuccess(lines) + call v9.CheckTransLegacySuccess(lines) let lines =<< trim END var text = substitute ( 'some text' , 't' , 'T' , 'g' ) call assert_equal('some TexT', text) END - call CheckDefAndScriptFailure(lines, ['E1001:', 'E121:']) + call v9.CheckDefAndScriptFailure(lines, ['E1001:', 'E121:']) endfunc " Test for float value comparison @@ -825,7 +825,7 @@ func Test_float_compare() #" +infinity != -infinity call assert_true((1.0 / 0) != -(2.0 / 0)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_filter_map.vim b/src/testdir/test_filter_map.vim index 072e7cb7b..f06059b55 100644 --- a/src/testdir/test_filter_map.vim +++ b/src/testdir/test_filter_map.vim @@ -1,6 +1,6 @@ " Test filter() and map() -source vim9.vim +import './vim9.vim' as v9 " list with expression string func Test_filter_map_list_expr_string() @@ -166,7 +166,7 @@ func Test_filter_map_string() call assert_equal('', filter('', "v:val == 'a'")) call assert_equal('', filter(test_null_string(), "v:val == 'a'")) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " map() let lines =<< trim END @@ -185,7 +185,7 @@ func Test_filter_map_string() call assert_fails('echo map("abc", "10")', 'E928:') call assert_fails('echo map("abc", "a10")', 'E121:') END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " mapnew() let lines =<< trim END @@ -202,7 +202,7 @@ func Test_filter_map_string() call assert_equal('', mapnew('', "v:val == 'a'")) call assert_equal('', mapnew(test_null_string(), "v:val == 'a'")) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END #" map() and filter() @@ -228,7 +228,7 @@ func Test_filter_map_string() call assert_equal('@ström', map('Åström', LSTART i, x LMIDDLE x =~ nr2char(0xc5) .. '\%C' ? '@' : x LEND)) call assert_equal('Åstr@m', map('Åström', LSTART i, x LMIDDLE x =~ nr2char(0xf6) .. '\%C' ? '@' : x LEND)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_float_func.vim b/src/testdir/test_float_func.vim index 41ae815ba..8ef1b9d5e 100644 --- a/src/testdir/test_float_func.vim +++ b/src/testdir/test_float_func.vim @@ -2,7 +2,7 @@ source check.vim CheckFeature float -source vim9.vim +import './vim9.vim' as v9 func Test_abs() call assert_equal('1.23', string(abs(1.23))) @@ -246,7 +246,7 @@ func Test_str2float() call assert_equal('123456.7', string(str2float("123'456.7'89", 1))) call assert_equal(1.2, str2float(1.2, 0)) - call CheckDefAndScriptFailure(['str2float(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) + call v9.CheckDefAndScriptFailure(['str2float(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) call assert_fails("call str2float([])", 'E730:') call assert_fails("call str2float({})", 'E731:') call assert_fails("call str2float(function('string'))", 'E729:') diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index ff079168f..6baba9707 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -4,7 +4,7 @@ source shared.vim source check.vim source term_util.vim source screendump.vim -source vim9.vim +import './vim9.vim' as v9 " Must be done first, since the alternate buffer must be unset. func Test_00_bufexists() @@ -174,7 +174,7 @@ func Test_strwidth() if has('float') call assert_equal(3, strwidth(1.2)) - call CheckDefAndScriptFailure(['echo strwidth(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) + call v9.CheckDefAndScriptFailure(['echo strwidth(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) endif set ambiwidth& @@ -241,7 +241,7 @@ func Test_str2nr() call assert_fails('call str2nr({->2})', 'E729:') if has('float') call assert_equal(1, str2nr(1.2)) - call CheckDefAndScriptFailure(['echo str2nr(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) + call v9.CheckDefAndScriptFailure(['echo str2nr(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) endif call assert_fails('call str2nr(10, [])', 'E745:') endfunc @@ -503,7 +503,7 @@ func Test_simplify() call assert_fails('call simplify({})', 'E731:') if has('float') call assert_equal('1.2', simplify(1.2)) - call CheckDefAndScriptFailure(['echo simplify(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) + call v9.CheckDefAndScriptFailure(['echo simplify(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) endif endfunc @@ -2265,7 +2265,7 @@ func Test_call() let Time = 'localtime' call Time() END - call CheckScriptFailure(lines, 'E1085:') + call v9.CheckScriptFailure(lines, 'E1085:') endfunc func Test_char2nr() @@ -2800,7 +2800,7 @@ func Test_builtin_check() vim9script var s:trim = (x) => " " .. x END - call CheckScriptFailure(lines, 'E704:') + call v9.CheckScriptFailure(lines, 'E704:') call assert_fails('call extend(g:, #{foo: { -> "foo" }})', 'E704:') let g:bar = 123 diff --git a/src/testdir/test_glob2regpat.vim b/src/testdir/test_glob2regpat.vim index 824693dd5..17ae3fcf2 100644 --- a/src/testdir/test_glob2regpat.vim +++ b/src/testdir/test_glob2regpat.vim @@ -1,11 +1,11 @@ " Test glob2regpat() -source vim9.vim +import './vim9.vim' as v9 func Test_glob2regpat_invalid() if has('float') call assert_equal('^1\.33$', glob2regpat(1.33)) - call CheckDefAndScriptFailure(['echo glob2regpat(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) + call v9.CheckDefAndScriptFailure(['echo glob2regpat(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) endif call assert_fails('call glob2regpat("}")', 'E219:') call assert_fails('call glob2regpat("{")', 'E220:') diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim index 5476008c4..9870b2e6c 100644 --- a/src/testdir/test_highlight.vim +++ b/src/testdir/test_highlight.vim @@ -4,7 +4,7 @@ source view_util.vim source screendump.vim source check.vim source script_util.vim -source vim9.vim +import './vim9.vim' as v9 func ClearDict(d) for k in keys(a:d) @@ -1011,7 +1011,7 @@ func Test_hlget() call assert_equal([], hlget(test_null_string())) call assert_equal([], hlget("")) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for resolving highlight group links let lines =<< trim END @@ -1042,7 +1042,7 @@ func Test_hlget() call assert_equal([{'id': hlgCid, 'name': 'hlgC', \ 'term': {'bold': v:true}}], hlget('hlgC', v:true)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_fails('call hlget([])', 'E1174:') call assert_fails('call hlget("abc", "xyz")', 'E1212:') @@ -1098,7 +1098,7 @@ func Test_hlset() call assert_equal('Search', hlget('NewHLGroup')[0].linksto) highlight clear NewHLGroup END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for clearing the 'term', 'cterm' and 'gui' attributes of a highlight " group. @@ -1117,7 +1117,7 @@ func Test_hlset() \ hlget('myhlg1')) highlight clear myhlg1 END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for setting all the 'term', 'cterm' and 'gui' attributes of a " highlight group @@ -1134,7 +1134,7 @@ func Test_hlset() call assert_equal([{'id': id2, 'name': 'myhlg2', 'gui': attr, \ 'term': attr, 'cterm': attr}], hlget('myhlg2')) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for clearing some of the 'term', 'cterm' and 'gui' attributes of a " highlight group @@ -1150,7 +1150,7 @@ func Test_hlset() call assert_equal([{'id': id2, 'name': 'myhlg2', 'gui': attr, \ 'term': attr, 'cterm': attr}], hlget('myhlg2')) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for clearing the attributes and link of a highlight group let lines =<< trim END @@ -1162,7 +1162,7 @@ func Test_hlset() \ hlget('myhlg3')) highlight clear hlg3 END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for setting default attributes for a highlight group let lines =<< trim END @@ -1187,7 +1187,7 @@ func Test_hlset() \ hlget('hlg6')) highlight clear hlg6 END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for setting default links for a highlight group let lines =<< trim END @@ -1217,7 +1217,7 @@ func Test_hlset() \ 'linksto': 'ErrorMsg'}], hlget('hlg9dup')) highlight clear hlg9 END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for force creating a link to a highlight group let lines =<< trim END @@ -1231,7 +1231,7 @@ func Test_hlset() \ 'linksto': 'Search'}], hlget('hlg10')) highlight clear hlg10 END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for empty values of attributes call hlset([{'name': 'hlg11', 'cterm': {}}]) diff --git a/src/testdir/test_iminsert.vim b/src/testdir/test_iminsert.vim index db6152fb5..e5ded5866 100644 --- a/src/testdir/test_iminsert.vim +++ b/src/testdir/test_iminsert.vim @@ -2,7 +2,7 @@ source view_util.vim source check.vim -source vim9.vim +import './vim9.vim' as v9 let s:imactivatefunc_called = 0 let s:imstatusfunc_called = 0 @@ -165,28 +165,28 @@ func Test_imactivatefunc_imstatusfunc_callback() normal! i #" Test for using a lambda function - VAR optval = "LSTART a LMIDDLE IMactivatefunc1(a) LEND" + VAR optval = "LSTART a LMIDDLE g:IMactivatefunc1(a) LEND" LET optval = substitute(optval, ' ', '\\ ', 'g') exe "set imactivatefunc=" .. optval - LET optval = "LSTART LMIDDLE IMstatusfunc1() LEND" + LET optval = "LSTART LMIDDLE g:IMstatusfunc1() LEND" LET optval = substitute(optval, ' ', '\\ ', 'g') exe "set imstatusfunc=" .. optval normal! i #" Set 'imactivatefunc' and 'imstatusfunc' to a lambda expression - LET &imactivatefunc = LSTART a LMIDDLE IMactivatefunc1(a) LEND - LET &imstatusfunc = LSTART LMIDDLE IMstatusfunc1() LEND + LET &imactivatefunc = LSTART a LMIDDLE g:IMactivatefunc1(a) LEND + LET &imstatusfunc = LSTART LMIDDLE g:IMstatusfunc1() LEND normal! i #" Set 'imactivatefunc' and 'imstatusfunc' to a string(lambda expression) - LET &imactivatefunc = 'LSTART a LMIDDLE IMactivatefunc1(a) LEND' - LET &imstatusfunc = 'LSTART LMIDDLE IMstatusfunc1() LEND' + LET &imactivatefunc = 'LSTART a LMIDDLE g:IMactivatefunc1(a) LEND' + LET &imstatusfunc = 'LSTART LMIDDLE g:IMstatusfunc1() LEND' normal! i #" Set 'imactivatefunc' 'imstatusfunc' to a variable with a lambda #" expression - VAR Lambda1 = LSTART a LMIDDLE IMactivatefunc1(a) LEND - VAR Lambda2 = LSTART LMIDDLE IMstatusfunc1() LEND + VAR Lambda1 = LSTART a LMIDDLE g:IMactivatefunc1(a) LEND + VAR Lambda2 = LSTART LMIDDLE g:IMstatusfunc1() LEND LET &imactivatefunc = Lambda1 LET &imstatusfunc = Lambda2 normal! i @@ -223,7 +223,7 @@ func Test_imactivatefunc_imstatusfunc_callback() call assert_equal(14, g:IMactivatefunc_called) call assert_equal(28, g:IMstatusfunc_called) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Using Vim9 lambda expression in legacy context should fail set imactivatefunc=(a)\ =>\ IMactivatefunc1(a) @@ -285,7 +285,7 @@ func Test_imactivatefunc_imstatusfunc_callback() set imactivatefunc= set imstatusfunc= END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) " cleanup set iminsert=0 diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 5f7d0e328..5cfa462be 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -2,7 +2,7 @@ source screendump.vim source check.vim -source vim9.vim +import './vim9.vim' as v9 " Test for insert expansion func Test_ins_complete() @@ -1359,7 +1359,7 @@ func Test_completefunc_callback() bw! #" Test for using a lambda function with set - VAR optval = "LSTART a, b LMIDDLE CompleteFunc1(16, a, b) LEND" + VAR optval = "LSTART a, b LMIDDLE g:CompleteFunc1(16, a, b) LEND" LET optval = substitute(optval, ' ', '\\ ', 'g') exe "set completefunc=" .. optval new @@ -1370,7 +1370,7 @@ func Test_completefunc_callback() bw! #" Set 'completefunc' to a lambda expression - LET &completefunc = LSTART a, b LMIDDLE CompleteFunc1(17, a, b) LEND + LET &completefunc = LSTART a, b LMIDDLE g:CompleteFunc1(17, a, b) LEND new call setline(1, 'six') LET g:CompleteFunc1Args = [] @@ -1379,7 +1379,7 @@ func Test_completefunc_callback() bw! #" Set 'completefunc' to string(lambda_expression) - LET &completefunc = 'LSTART a, b LMIDDLE CompleteFunc1(18, a, b) LEND' + LET &completefunc = 'LSTART a, b LMIDDLE g:CompleteFunc1(18, a, b) LEND' new call setline(1, 'six') LET g:CompleteFunc1Args = [] @@ -1388,7 +1388,7 @@ func Test_completefunc_callback() bw! #" Set 'completefunc' to a variable with a lambda expression - VAR Lambda = LSTART a, b LMIDDLE CompleteFunc1(19, a, b) LEND + VAR Lambda = LSTART a, b LMIDDLE g:CompleteFunc1(19, a, b) LEND LET &completefunc = Lambda new call setline(1, 'seven') @@ -1398,7 +1398,7 @@ func Test_completefunc_callback() bw! #" Set 'completefunc' to a string(variable with a lambda expression) - LET Lambda = LSTART a, b LMIDDLE CompleteFunc1(20, a, b) LEND + LET Lambda = LSTART a, b LMIDDLE g:CompleteFunc1(20, a, b) LEND LET &completefunc = string(Lambda) new call setline(1, 'seven') @@ -1431,7 +1431,7 @@ func Test_completefunc_callback() call assert_equal([[1, ''], [0, 'five']], g:CompleteFunc2Args) bw! END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for using a script-local function name func s:CompleteFunc3(findstart, base) @@ -1460,7 +1460,7 @@ func Test_completefunc_callback() call feedkeys("A\\\", 'x') " Using Vim9 lambda expression in legacy context should fail - set completefunc=(a,\ b)\ =>\ CompleteFunc1(21,\ a,\ b) + set completefunc=(a,\ b)\ =>\ g:CompleteFunc1(21,\ a,\ b) new | only let g:CompleteFunc1Args = [] call assert_fails('call feedkeys("A\\\", "x")', 'E117:') @@ -1526,7 +1526,7 @@ func Test_completefunc_callback() assert_equal([[1, ''], [0, 'three']], g:LocalCompleteFuncArgs) bw! END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) " cleanup set completefunc& @@ -1616,7 +1616,7 @@ func Test_omnifunc_callback() bw! #" Test for using a lambda function with set - VAR optval = "LSTART a, b LMIDDLE OmniFunc1(16, a, b) LEND" + VAR optval = "LSTART a, b LMIDDLE g:OmniFunc1(16, a, b) LEND" LET optval = substitute(optval, ' ', '\\ ', 'g') exe "set omnifunc=" .. optval new @@ -1627,7 +1627,7 @@ func Test_omnifunc_callback() bw! #" Set 'omnifunc' to a lambda expression - LET &omnifunc = LSTART a, b LMIDDLE OmniFunc1(17, a, b) LEND + LET &omnifunc = LSTART a, b LMIDDLE g:OmniFunc1(17, a, b) LEND new call setline(1, 'six') LET g:OmniFunc1Args = [] @@ -1636,7 +1636,7 @@ func Test_omnifunc_callback() bw! #" Set 'omnifunc' to a string(lambda_expression) - LET &omnifunc = 'LSTART a, b LMIDDLE OmniFunc1(18, a, b) LEND' + LET &omnifunc = 'LSTART a, b LMIDDLE g:OmniFunc1(18, a, b) LEND' new call setline(1, 'six') LET g:OmniFunc1Args = [] @@ -1645,7 +1645,7 @@ func Test_omnifunc_callback() bw! #" Set 'omnifunc' to a variable with a lambda expression - VAR Lambda = LSTART a, b LMIDDLE OmniFunc1(19, a, b) LEND + VAR Lambda = LSTART a, b LMIDDLE g:OmniFunc1(19, a, b) LEND LET &omnifunc = Lambda new call setline(1, 'seven') @@ -1655,7 +1655,7 @@ func Test_omnifunc_callback() bw! #" Set 'omnifunc' to a string(variable with a lambda expression) - LET Lambda = LSTART a, b LMIDDLE OmniFunc1(20, a, b) LEND + LET Lambda = LSTART a, b LMIDDLE g:OmniFunc1(20, a, b) LEND LET &omnifunc = string(Lambda) new call setline(1, 'seven') @@ -1688,7 +1688,7 @@ func Test_omnifunc_callback() call assert_equal([[1, ''], [0, 'nine']], g:OmniFunc2Args) bw! END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for using a script-local function name func s:OmniFunc3(findstart, base) @@ -1783,7 +1783,7 @@ func Test_omnifunc_callback() assert_equal([[1, ''], [0, 'three']], g:LocalOmniFuncArgs) bw! END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) " cleanup set omnifunc& @@ -1873,7 +1873,7 @@ func Test_thesaurusfunc_callback() bw! #" Test for using a lambda function - VAR optval = "LSTART a, b LMIDDLE TsrFunc1(16, a, b) LEND" + VAR optval = "LSTART a, b LMIDDLE g:TsrFunc1(16, a, b) LEND" LET optval = substitute(optval, ' ', '\\ ', 'g') exe "set thesaurusfunc=" .. optval new @@ -1884,7 +1884,7 @@ func Test_thesaurusfunc_callback() bw! #" Test for using a lambda function with set - LET &thesaurusfunc = LSTART a, b LMIDDLE TsrFunc1(17, a, b) LEND + LET &thesaurusfunc = LSTART a, b LMIDDLE g:TsrFunc1(17, a, b) LEND new call setline(1, 'six') LET g:TsrFunc1Args = [] @@ -1893,7 +1893,7 @@ func Test_thesaurusfunc_callback() bw! #" Set 'thesaurusfunc' to a string(lambda expression) - LET &thesaurusfunc = 'LSTART a, b LMIDDLE TsrFunc1(18, a, b) LEND' + LET &thesaurusfunc = 'LSTART a, b LMIDDLE g:TsrFunc1(18, a, b) LEND' new call setline(1, 'six') LET g:TsrFunc1Args = [] @@ -1902,7 +1902,7 @@ func Test_thesaurusfunc_callback() bw! #" Set 'thesaurusfunc' to a variable with a lambda expression - VAR Lambda = LSTART a, b LMIDDLE TsrFunc1(19, a, b) LEND + VAR Lambda = LSTART a, b LMIDDLE g:TsrFunc1(19, a, b) LEND LET &thesaurusfunc = Lambda new call setline(1, 'seven') @@ -1912,7 +1912,7 @@ func Test_thesaurusfunc_callback() bw! #" Set 'thesaurusfunc' to a string(variable with a lambda expression) - LET Lambda = LSTART a, b LMIDDLE TsrFunc1(20, a, b) LEND + LET Lambda = LSTART a, b LMIDDLE g:TsrFunc1(20, a, b) LEND LET &thesaurusfunc = string(Lambda) new call setline(1, 'seven') @@ -1968,7 +1968,7 @@ func Test_thesaurusfunc_callback() call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:TsrFunc1Args) :%bw! END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for using a script-local function name func s:TsrFunc3(findstart, base) @@ -2076,7 +2076,7 @@ func Test_thesaurusfunc_callback() assert_equal([[1, ''], [0, 'three']], g:LocalTsrFuncArgs) bw! END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) " cleanup set thesaurusfunc& diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim index fbb917b9b..5337254fd 100644 --- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -1,7 +1,7 @@ " Tests for the List and Dict types scriptencoding utf-8 -source vim9.vim +import './vim9.vim' as v9 func TearDown() " Run garbage collection after every test @@ -50,7 +50,7 @@ func Test_list_slice() call assert_equal([2], l[-1 : -1]) call assert_equal([1, 2], l[-2 : -1]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let l = [1, 2] call assert_equal([], l[-3 : -1]) @@ -59,7 +59,7 @@ func Test_list_slice() var l = [1, 2] assert_equal([1, 2], l[-3 : -1]) END - call CheckDefAndScriptSuccess(lines) + call v9.CheckDefAndScriptSuccess(lines) endfunc " List identity @@ -75,7 +75,7 @@ func Test_list_identity() call assert_false(l is lx) call assert_true(l isnot lx) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " removing items with :unlet @@ -118,7 +118,7 @@ func Test_list_unlet() unlet l[-6 : 2] call assert_equal([3], l) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let l = [0, 1, 2, 3] unlet l[2:2] @@ -131,13 +131,13 @@ func Test_list_unlet() VAR l = [0, 1, 2, 3] unlet l[2 : 1] END - call CheckLegacyAndVim9Failure(lines, 'E684:') + call v9.CheckLegacyAndVim9Failure(lines, 'E684:') let lines =<< trim END VAR l = [0, 1, 2, 3] unlet l[-1 : 2] END - call CheckLegacyAndVim9Failure(lines, 'E684:') + call v9.CheckLegacyAndVim9Failure(lines, 'E684:') endfunc " assignment to a list @@ -149,35 +149,35 @@ func Test_list_assign() LET [va, vb] = l[2 : 3] call assert_equal([2, 3], [va, vb]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END let l = [0, 1, 2, 3] let [va, vb] = l END - call CheckScriptFailure(lines, 'E687:') + call v9.CheckScriptFailure(lines, 'E687:') let lines =<< trim END var l = [0, 1, 2, 3] var va = 0 var vb = 0 [va, vb] = l END - call CheckScriptFailure(['vim9script'] + lines, 'E687:') - call CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 4') + call v9.CheckScriptFailure(['vim9script'] + lines, 'E687:') + call v9.CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 4') let lines =<< trim END let l = [0, 1, 2, 3] let [va, vb] = l[1:1] END - call CheckScriptFailure(lines, 'E688:') + call v9.CheckScriptFailure(lines, 'E688:') let lines =<< trim END var l = [0, 1, 2, 3] var va = 0 var vb = 0 [va, vb] = l[1 : 1] END - call CheckScriptFailure(['vim9script'] + lines, 'E688:') - call CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 1') + call v9.CheckScriptFailure(['vim9script'] + lines, 'E688:') + call v9.CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 1') endfunc " test for range assign @@ -189,13 +189,13 @@ func Test_list_range_assign() LET l[-4 : -1] = [5, 6] call assert_equal([5, 6], l) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END var l = [7] l[:] = ['text'] END - call CheckDefAndScriptFailure(lines, 'E1012:', 2) + call v9.CheckDefAndScriptFailure(lines, 'E1012:', 2) endfunc " Test removing items in list @@ -227,7 +227,7 @@ func Test_list_func_remove() call assert_equal([2, 3], remove(l, -3, -2)) call assert_equal([1, 4], l) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test invalid cases let l = [1, 2, 3, 4] @@ -251,7 +251,7 @@ func Test_list_add() call add(l, test_null_dict()) call assert_equal([1, [2, 3], [], [], {'k': 3}, {}, {}], l) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " weird legacy behavior call assert_equal(1, add(test_null_list(), 4)) @@ -271,7 +271,7 @@ func Test_dict() call extend(d, {'b': 'bbb', 'c': 'ccc'}, "keep") call assert_equal({'c': 'ccc', '1': 99, 'b': [1, 2, function('strlen')], '3': 33, '-1': {'a': 1}}, d) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},} call assert_equal("{'1': 'asd', 'b': [1, 2, function('strlen')], '-1': {'a': 1}}", string(d)) @@ -320,7 +320,7 @@ func Test_dict_identity() call assert_false(d is dx) call assert_true(d isnot dx) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " removing items with :unlet @@ -331,7 +331,7 @@ func Test_dict_unlet() unlet d[-1] call assert_equal({'1': 99, '3': 33}, d) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " manipulating a big Dictionary (hashtable.c has a border of 1000 entries) @@ -405,24 +405,24 @@ func Test_dict_assign() LET d._ = 2 call assert_equal({'a': 1, '_': 2}, d) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END let n = 0 let n.key = 3 END - call CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3') + call v9.CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3') let lines =<< trim END vim9script var n = 0 n.key = 3 END - call CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3') + call v9.CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3') let lines =<< trim END var n = 0 n.key = 3 END - call CheckDefFailure(lines, 'E1141:') + call v9.CheckDefFailure(lines, 'E1141:') endfunc " Function in script-local List or Dict @@ -444,55 +444,55 @@ func Test_dict_func_remove() call assert_equal('b', remove(d, 2)) call assert_equal({1: 'a', 3: 'c'}, d) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let lines =<< trim END VAR d = {1: 'a', 3: 'c'} call remove(d, 1, 2) END - call CheckLegacyAndVim9Failure(lines, 'E118:') + call v9.CheckLegacyAndVim9Failure(lines, 'E118:') let lines =<< trim END VAR d = {1: 'a', 3: 'c'} call remove(d, 'a') END - call CheckLegacyAndVim9Failure(lines, 'E716:') + call v9.CheckLegacyAndVim9Failure(lines, 'E716:') let lines =<< trim END let d = {'a-b': 55} echo d.a-b END - call CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"') + call v9.CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"') let lines =<< trim END vim9script var d = {'a-b': 55} echo d.a-b END - call CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"') + call v9.CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"') let lines =<< trim END var d = {'a-b': 55} echo d.a-b END - call CheckDefFailure(lines, 'E1004: White space required before and after ''-''') + call v9.CheckDefFailure(lines, 'E1004: White space required before and after ''-''') let lines =<< trim END let d = {1: 'a', 3: 'c'} call remove(d, []) END - call CheckScriptFailure(lines, 'E730:') + call v9.CheckScriptFailure(lines, 'E730:') let lines =<< trim END vim9script var d = {1: 'a', 3: 'c'} call remove(d, []) END - call CheckScriptFailure(lines, 'E1220: String or Number required for argument 2') + call v9.CheckScriptFailure(lines, 'E1220: String or Number required for argument 2') let lines =<< trim END var d = {1: 'a', 3: 'c'} call remove(d, []) END - call CheckDefExecFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got list') + call v9.CheckDefExecFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got list') endfunc " Nasty: remove func from Dict that's being called (works) @@ -514,8 +514,8 @@ func Test_dict_func_remove_in_use() VAR expected = 'a:' .. string(get(d, 'func')) call assert_equal(expected, d.func(string(remove(d, 'func')))) END - call CheckTransLegacySuccess(lines) - call CheckTransVim9Success(lines) + call v9.CheckTransLegacySuccess(lines) + call v9.CheckTransVim9Success(lines) endfunc func Test_dict_literal_keys() @@ -535,7 +535,7 @@ func Test_dict_deepcopy() VAR dc = deepcopy(d) call deepcopy(d, 1) END - call CheckLegacyAndVim9Failure(lines, 'E698:') + call v9.CheckLegacyAndVim9Failure(lines, 'E698:') let lines =<< trim END VAR d = {1: 1, 2: '2'} @@ -546,7 +546,7 @@ func Test_dict_deepcopy() VAR l3 = deepcopy(l2) call assert_true(l3[1] is l3[2]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_fails("call deepcopy([1, 2], 2)", 'E1023:') endfunc @@ -631,8 +631,8 @@ func Test_list_locked_var() endfor endfor END - call CheckTransLegacySuccess(lines) - call CheckTransVim9Success(lines) + call v9.CheckTransLegacySuccess(lines) + call v9.CheckTransVim9Success(lines) call assert_fails("let x=islocked('a b')", 'E488:') let mylist = [1, 2, 3] @@ -745,7 +745,7 @@ func Test_dict_item_lock_unlet() unlet d.a call assert_equal({'b': 100}, d) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " filter() after lock on dict item @@ -756,7 +756,7 @@ func Test_dict_lock_filter() call filter(d, 'v:key != "a"') call assert_equal({'b': 100}, d) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " map() after lock on dict @@ -768,8 +768,8 @@ func Test_dict_lock_map() call assert_equal({'a': 299, 'b': 300}, d) END " This won't work in a :def function - call CheckTransLegacySuccess(lines) - call CheckTransVim9Success(lines) + call v9.CheckTransLegacySuccess(lines) + call v9.CheckTransVim9Success(lines) " For a :def function use a global dict. let lines =<< trim END @@ -780,7 +780,7 @@ func Test_dict_lock_map() enddef call Delkey() END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') endfunc " Lock one item in a list @@ -792,8 +792,8 @@ func Test_list_item_lock_map() call assert_equal([299, 100, 101], l) END " This won't work in a :def function - call CheckTransLegacySuccess(lines) - call CheckTransVim9Success(lines) + call v9.CheckTransLegacySuccess(lines) + call v9.CheckTransVim9Success(lines) endfunc " Lock one item in a dict @@ -805,8 +805,8 @@ func Test_dict_item_lock_map() call assert_equal({'a': 299, 'b': 100, 'c': 101}, d) END " This won't work in a :def function - call CheckTransLegacySuccess(lines) - call CheckTransVim9Success(lines) + call v9.CheckTransLegacySuccess(lines) + call v9.CheckTransVim9Success(lines) endfunc " No extend() after lock on dict item @@ -885,7 +885,7 @@ func Test_let_lock_list() lockvar! l call TryUnletListItem(l) END - call CheckScriptFailure(lines, 'E741:') + call v9.CheckScriptFailure(lines, 'E741:') unlet g:l endfunc @@ -954,7 +954,7 @@ func Test_reverse_sort_uniq() call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l))) endif END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_fails('call reverse("")', 'E899:') call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:') @@ -997,7 +997,7 @@ func Test_reduce() call assert_equal('Å,s,t,r,ö,m', reduce('Åström', LSTART acc, val LMIDDLE acc .. ',' .. val LEND)) call assert_equal(',a,b,c', reduce('abc', LSTART acc, val LMIDDLE acc .. ',' .. val LEND, test_null_string())) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_equal({'x': 1, 'y': 1, 'z': 1 }, ['x', 'y', 'z']->reduce({ acc, val -> extend(acc, { val: 1 }) }, {})) vim9 assert_equal({'x': 1, 'y': 1, 'z': 1 }, ['x', 'y', 'z']->reduce((acc, val) => extend(acc, {[val]: 1 }), {})) @@ -1055,7 +1055,7 @@ func Test_str_split() call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1)) call assert_equal(['abc'], split('abc', '\\%(')) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_fails("call split('abc', [])", 'E730:') call assert_fails("call split('abc', 'b', [])", 'E745:') @@ -1072,7 +1072,7 @@ func Test_listdict_compare() call assert_false(l != deepcopy(l)) call assert_false(d != deepcopy(d)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " comparison errors call assert_fails('echo [1, 2] =~ {}', 'E691:') @@ -1093,7 +1093,7 @@ func Test_listdict_compare_complex() call assert_true(l == lcopy) call assert_true(dict4 == dict4copy) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " Test for extending lists and dictionaries @@ -1130,7 +1130,7 @@ func Test_listdict_extend() call extend(l, [4, 5, 6], -3) call assert_equal([4, 5, 6, 1, 2, 3], l) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let l = [1, 2, 3] call assert_fails("call extend(l, [4, 5, 6], 4)", 'E684:') @@ -1159,7 +1159,7 @@ func Test_listdict_extend() call extend(d, {'b': 0, 'c': 'C'}, "keep") call assert_equal({'a': 'A', 'b': 9, 'c': 'C'}, d) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let d = {'a': 'A', 'b': 'B'} call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:') @@ -1191,7 +1191,7 @@ func Test_listdict_extend() call extend(l, l, 3) call assert_equal([1, 5, 7, 1, 5, 7], l) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_listdict_extendnew() @@ -1318,30 +1318,30 @@ endfunc " List and dict indexing tests func Test_listdict_index() - call CheckLegacyAndVim9Failure(['echo function("min")[0]'], 'E695:') - call CheckLegacyAndVim9Failure(['echo v:true[0]'], 'E909:') - call CheckLegacyAndVim9Failure(['echo v:null[0]'], 'E909:') - call CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d.'], ['E15:', 'E1127:', 'E15:']) - call CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d[1 : 2]'], 'E719:') + call v9.CheckLegacyAndVim9Failure(['echo function("min")[0]'], 'E695:') + call v9.CheckLegacyAndVim9Failure(['echo v:true[0]'], 'E909:') + call v9.CheckLegacyAndVim9Failure(['echo v:null[0]'], 'E909:') + call v9.CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d.'], ['E15:', 'E1127:', 'E15:']) + call v9.CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d[1 : 2]'], 'E719:') call assert_fails("let v = [4, 6][{-> 1}]", 'E729:') - call CheckDefAndScriptFailure(['var v = [4, 6][() => 1]'], ['E1012', 'E703:']) + call v9.CheckDefAndScriptFailure(['var v = [4, 6][() => 1]'], ['E1012', 'E703:']) - call CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : []]'], ['E730:', 'E1012:', 'E730:']) + call v9.CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : []]'], ['E730:', 'E1012:', 'E730:']) call assert_fails("let v = range(5)[2:{-> 2}(]", ['E15:', 'E116:']) - call CheckDefAndScriptFailure(['var v = range(5)[2 : () => 2(]'], 'E15:') - - call CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : 3'], ['E111:', 'E1097:', 'E111:']) - call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, 10)'], 'E684:') - call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, -10)'], 'E684:') - call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, [])'], ['E745:', 'E1013:', 'E1210:']) - - call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[i] = 3'], ['E121:', 'E1001:', 'E121:']) - call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[1.1] = 4'], ['E805:', 'E1012:', 'E805:']) - call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: i] = [4, 5]'], ['E121:', 'E1001:', 'E121:']) - call CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: 3.2] = [4, 5]'], ['E805:', 'E1012:', 'E805:']) - call CheckLegacyAndVim9Failure(['VAR t = test_unknown()', 'echo t[0]'], 'E685:') + call v9.CheckDefAndScriptFailure(['var v = range(5)[2 : () => 2(]'], 'E15:') + + call v9.CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : 3'], ['E111:', 'E1097:', 'E111:']) + call v9.CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, 10)'], 'E684:') + call v9.CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, -10)'], 'E684:') + call v9.CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, [])'], ['E745:', 'E1013:', 'E1210:']) + + call v9.CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[i] = 3'], ['E121:', 'E1001:', 'E121:']) + call v9.CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[1.1] = 4'], ['E805:', 'E1012:', 'E805:']) + call v9.CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: i] = [4, 5]'], ['E121:', 'E1001:', 'E121:']) + call v9.CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: 3.2] = [4, 5]'], ['E805:', 'E1012:', 'E805:']) + call v9.CheckLegacyAndVim9Failure(['VAR t = test_unknown()', 'echo t[0]'], 'E685:') endfunc " Test for a null list @@ -1379,7 +1379,7 @@ func Test_null_list() call assert_equal([], sort(l)) call assert_equal('[]', string(l)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let l = test_null_list() call assert_equal([], extend(l, l, 0)) @@ -1420,7 +1420,7 @@ func Test_null_dict() call assert_equal(0, remove(test_null_dict(), 'k')) call assert_equal('{}', string(d)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) let d = test_null_dict() call assert_equal({}, extend(d, d, 'keep')) diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim index aae3444b2..b9c9fa528 100644 --- a/src/testdir/test_mapping.vim +++ b/src/testdir/test_mapping.vim @@ -4,7 +4,7 @@ source shared.vim source check.vim source screendump.vim source term_util.vim -source vim9.vim +import './vim9.vim' as v9 func Test_abbreviation() " abbreviation with 0x80 should work @@ -1415,7 +1415,7 @@ func Test_map_script_cmd_restore() vim9script nnoremap eval 1 + 2 END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) call feedkeys("\:let g:result = 3+4\", 'xtc') call assert_equal(7, g:result) @@ -1431,7 +1431,7 @@ func Test_map_script_cmd_finds_func() g:func_called = 'yes' enddef END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) call feedkeys("y\\", 'xtc') call assert_equal('yes', g:func_called) @@ -1449,7 +1449,7 @@ func Test_map_script_cmd_survives_unmap() feedkeys("\\", 'xct') assert_equal(123, b:result) END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) nunmap unlet b:result diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 9fcc9fda7..2ed6a80df 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -3,7 +3,7 @@ source shared.vim source check.vim source view_util.vim -source vim9.vim +import './vim9.vim' as v9 func Setup_NewWindow() 10new @@ -626,7 +626,7 @@ func Test_opfunc_callback() normal! g@l call assert_equal([23, 'char'], g:OpFunc1Args) END - call CheckTransLegacySuccess(lines) + call v9.CheckTransLegacySuccess(lines) " Test for using a script-local function name func s:OpFunc3(type) @@ -693,7 +693,7 @@ func Test_opfunc_callback() assert_equal(['char'], g:LocalOpFuncArgs) bw! END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) " setting 'opfunc' to a script local function outside of a script context " should fail diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 45883b1e8..5a088b4a1 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -2801,7 +2801,7 @@ def Popupwin_close_prevwin() assert_equal(2, winnr()) var buf = term_start(&shell, {hidden: 1}) popup_create(buf, {}) - TermWait(buf, 100) + g:TermWait(buf, 100) popup_clear(true) assert_equal(2, winnr()) diff --git a/src/testdir/test_profile.vim b/src/testdir/test_profile.vim index 13f5fae56..1c7ef9387 100644 --- a/src/testdir/test_profile.vim +++ b/src/testdir/test_profile.vim @@ -5,7 +5,6 @@ CheckFeature profile source shared.vim source screendump.vim -source vim9.vim func Test_profile_func() call RunProfileFunc('func', 'let', 'let') diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index 511896e18..fb6d21fc5 100644 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -1,7 +1,7 @@ " Test for the quickfix feature. source check.vim -source vim9.vim +import './vim9.vim' as v9 CheckFeature quickfix source screendump.vim @@ -5347,7 +5347,7 @@ func Test_qftextfunc_callback() cclose #" Test for using a lambda function with set - VAR optval = "LSTART a LMIDDLE Tqfexpr(a) LEND" + VAR optval = "LSTART a LMIDDLE g:Tqfexpr(a) LEND" LET optval = substitute(optval, ' ', '\\ ', 'g') exe "set qftf=" .. optval cexpr "F6:6:6:L6" @@ -5356,21 +5356,21 @@ func Test_qftextfunc_callback() cclose #" Set 'quickfixtextfunc' to a lambda expression - LET &qftf = LSTART a LMIDDLE Tqfexpr(a) LEND + LET &qftf = LSTART a LMIDDLE g:Tqfexpr(a) LEND cexpr "F7:7:7:L7" copen call assert_equal('F7-L7C7-L7', getline(1)) cclose #" Set 'quickfixtextfunc' to string(lambda_expression) - LET &qftf = "LSTART a LMIDDLE Tqfexpr(a) LEND" + LET &qftf = "LSTART a LMIDDLE g:Tqfexpr(a) LEND" cexpr "F8:8:8:L8" copen call assert_equal('F8-L8C8-L8', getline(1)) cclose #" Set 'quickfixtextfunc' to a variable with a lambda expression - VAR Lambda = LSTART a LMIDDLE Tqfexpr(a) LEND + VAR Lambda = LSTART a LMIDDLE g:Tqfexpr(a) LEND LET &qftf = Lambda cexpr "F9:9:9:L9" copen @@ -5378,14 +5378,14 @@ func Test_qftextfunc_callback() cclose #" Set 'quickfixtextfunc' to a string(variable with a lambda expression) - LET Lambda = LSTART a LMIDDLE Tqfexpr(a) LEND + LET Lambda = LSTART a LMIDDLE g:Tqfexpr(a) LEND LET &qftf = string(Lambda) cexpr "F9:9:9:L9" copen call assert_equal('F9-L9C9-L9', getline(1)) cclose END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for using a script-local function name func s:TqfFunc2(info) diff --git a/src/testdir/test_tagfunc.vim b/src/testdir/test_tagfunc.vim index 03394acb8..66a58ec47 100644 --- a/src/testdir/test_tagfunc.vim +++ b/src/testdir/test_tagfunc.vim @@ -1,6 +1,6 @@ " Test 'tagfunc' -source vim9.vim +import './vim9.vim' as v9 source check.vim source screendump.vim @@ -200,7 +200,7 @@ func Test_tagfunc_callback() bw! #" Test for using a lambda function - VAR optval = "LSTART a, b, c LMIDDLE TagFunc1(16, a, b, c) LEND" + VAR optval = "LSTART a, b, c LMIDDLE g:TagFunc1(16, a, b, c) LEND" LET optval = substitute(optval, ' ', '\\ ', 'g') exe "set tagfunc=" .. optval new @@ -210,7 +210,7 @@ func Test_tagfunc_callback() bw! #" Set 'tagfunc' to a lambda expression - LET &tagfunc = LSTART a, b, c LMIDDLE TagFunc1(17, a, b, c) LEND + LET &tagfunc = LSTART a, b, c LMIDDLE g:TagFunc1(17, a, b, c) LEND new LET g:TagFunc1Args = [] call assert_fails('tag a18', 'E433:') @@ -218,7 +218,7 @@ func Test_tagfunc_callback() bw! #" Set 'tagfunc' to a string(lambda expression) - LET &tagfunc = 'LSTART a, b, c LMIDDLE TagFunc1(18, a, b, c) LEND' + LET &tagfunc = 'LSTART a, b, c LMIDDLE g:TagFunc1(18, a, b, c) LEND' new LET g:TagFunc1Args = [] call assert_fails('tag a18', 'E433:') @@ -226,7 +226,7 @@ func Test_tagfunc_callback() bw! #" Set 'tagfunc' to a variable with a lambda expression - VAR Lambda = LSTART a, b, c LMIDDLE TagFunc1(19, a, b, c) LEND + VAR Lambda = LSTART a, b, c LMIDDLE g:TagFunc1(19, a, b, c) LEND LET &tagfunc = Lambda new LET g:TagFunc1Args = [] @@ -235,7 +235,7 @@ func Test_tagfunc_callback() bw! #" Set 'tagfunc' to a string(variable with a lambda expression) - LET Lambda = LSTART a, b, c LMIDDLE TagFunc1(20, a, b, c) LEND + LET Lambda = LSTART a, b, c LMIDDLE g:TagFunc1(20, a, b, c) LEND LET &tagfunc = string(Lambda) new LET g:TagFunc1Args = [] @@ -265,7 +265,7 @@ func Test_tagfunc_callback() call assert_equal([], g:TagFunc2Args) bw! END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) " Test for using a script-local function name func s:TagFunc3(pat, flags, info) @@ -380,7 +380,7 @@ func Test_tagfunc_callback() assert_equal(['a12', '', {}], g:LocalTagFuncArgs) bw! END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) " cleanup delfunc TagFunc1 diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 036dd7132..ed2856f9b 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -5,7 +5,7 @@ source check.vim CheckFeature textprop source screendump.vim -source vim9.vim +import './vim9.vim' as v9 func Test_proptype_global() call prop_type_add('comment', {'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1}) @@ -429,10 +429,10 @@ enddef def Test_prop_remove_vim9() new - AddPropTypes() - SetupPropsInFirstLine() + g:AddPropTypes() + g:SetupPropsInFirstLine() assert_equal(1, prop_remove({type: 'three', id: 13, both: true, all: true})) - DeletePropTypes() + g:DeletePropTypes() bwipe! enddef @@ -1704,7 +1704,7 @@ enddef func Test_prop_list() let lines =<< trim END new - call AddPropTypes() + call g:AddPropTypes() call setline(1, repeat([repeat('a', 60)], 10)) call prop_add(1, 4, {'type': 'one', 'id': 5, 'end_col': 6}) call prop_add(1, 5, {'type': 'two', 'id': 10, 'end_col': 7}) @@ -1844,10 +1844,10 @@ func Test_prop_list() bunload! Xaaa call assert_equal([], prop_list(1, {'bufnr': bnr, 'end_lnum': -1})) - call DeletePropTypes() + call g:DeletePropTypes() :%bw! END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim index b3ba62069..331e55f01 100644 --- a/src/testdir/test_usercommands.vim +++ b/src/testdir/test_usercommands.vim @@ -1,6 +1,6 @@ " Tests for user defined commands -source vim9.vim +import './vim9.vim' as v9 " Test for in user defined commands function Test_cmdmods() @@ -287,13 +287,13 @@ func Test_CmdErrors() vim9script com! -complete=file DoCmd : END - call CheckScriptFailure(lines, 'E1208', 2) + call v9.CheckScriptFailure(lines, 'E1208', 2) let lines =<< trim END vim9script com! -nargs=0 -complete=file DoCmd : END - call CheckScriptFailure(lines, 'E1208', 2) + call v9.CheckScriptFailure(lines, 'E1208', 2) com! -nargs=0 DoCmd : call assert_fails('DoCmd x', 'E488:') @@ -645,7 +645,7 @@ func Test_usercmd_with_block() command DoesNotEnd { echo 'hello' END - call CheckScriptFailure(lines, 'E1026:') + call v9.CheckScriptFailure(lines, 'E1026:') let lines =<< trim END command HelloThere { @@ -653,7 +653,7 @@ func Test_usercmd_with_block() } HelloThere END - call CheckScriptSuccess(lines) + call v9.CheckScriptSuccess(lines) delcommand HelloThere let lines =<< trim END @@ -664,7 +664,7 @@ func Test_usercmd_with_block() } BadCommand END - call CheckScriptFailure(lines, 'E1128:') + call v9.CheckScriptFailure(lines, 'E1128:') endfunc func Test_delcommand_buffer() diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index 0af1d5bb0..7eb7eaed9 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -1,7 +1,7 @@ " Test Vim9 assignments source check.vim -source vim9.vim +import './vim9.vim' as v9 source term_util.vim let s:appendToMe = 'xxx' @@ -51,14 +51,14 @@ def Test_assignment_bool() var cp: bool = &cp var fen: bool = &l:fen END - CheckScriptSuccess(lines) - CheckDefAndScriptFailure(['var x: bool = 2'], 'E1012:') - CheckDefAndScriptFailure(['var x: bool = -1'], 'E1012:') - CheckDefAndScriptFailure(['var x: bool = [1]'], 'E1012:') - CheckDefAndScriptFailure(['var x: bool = {}'], 'E1012:') - CheckDefAndScriptFailure(['var x: bool = "x"'], 'E1012:') + v9.CheckScriptSuccess(lines) + v9.CheckDefAndScriptFailure(['var x: bool = 2'], 'E1012:') + v9.CheckDefAndScriptFailure(['var x: bool = -1'], 'E1012:') + v9.CheckDefAndScriptFailure(['var x: bool = [1]'], 'E1012:') + v9.CheckDefAndScriptFailure(['var x: bool = {}'], 'E1012:') + v9.CheckDefAndScriptFailure(['var x: bool = "x"'], 'E1012:') - CheckDefAndScriptFailure(['var x: bool = "x"', '', 'eval 0'], 'E1012:', 1) + v9.CheckDefAndScriptFailure(['var x: bool = "x"', '', 'eval 0'], 'E1012:', 1) enddef def Test_syntax() @@ -67,21 +67,21 @@ def Test_syntax() enddef def Test_assignment() - CheckDefFailure(['var x:string'], 'E1069:') - CheckDefFailure(['var x:string = "x"'], 'E1069:') - CheckDefFailure(['var a:string = "x"'], 'E1069:') - CheckDefFailure(['var lambda = () => "lambda"'], 'E704:') - CheckScriptFailure(['var x = "x"'], 'E1124:') + v9.CheckDefFailure(['var x:string'], 'E1069:') + v9.CheckDefFailure(['var x:string = "x"'], 'E1069:') + v9.CheckDefFailure(['var a:string = "x"'], 'E1069:') + v9.CheckDefFailure(['var lambda = () => "lambda"'], 'E704:') + v9.CheckScriptFailure(['var x = "x"'], 'E1124:') # lower case name is OK for a list var lambdaLines =<< trim END var lambdaList: list = [Test_syntax] lambdaList[0] = () => "lambda" END - CheckDefAndScriptSuccess(lambdaLines) + v9.CheckDefAndScriptSuccess(lambdaLines) var nr: number = 1234 - CheckDefFailure(['var nr: number = "asdf"'], 'E1012:') + v9.CheckDefFailure(['var nr: number = "asdf"'], 'E1012:') var a: number = 6 #comment assert_equal(6, a) @@ -122,7 +122,7 @@ def Test_assignment() assert_equal('barfoo', $ENVVAR) $ENVVAR = '' END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) s:appendToMe ..= 'yyy' assert_equal('xxxyyy', s:appendToMe) @@ -155,7 +155,7 @@ def Test_assignment() f200 /= 5.0 assert_equal(40.0, f200) - CheckDefFailure(['var nr: number = 200', 'nr /= 5.0'], 'E1012:') + v9.CheckDefFailure(['var nr: number = 200', 'nr /= 5.0'], 'E1012:') endif lines =<< trim END @@ -182,18 +182,18 @@ def Test_assignment() &number = false assert_equal(false, &number) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefFailure(['¬ex += 3'], 'E113:') - CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') - CheckDefFailure(['&ts = [7]'], 'E1012:') - CheckDefExecFailure(['&ts = g:alist'], 'E1012: Type mismatch; expected number but got list') - CheckDefFailure(['&ts = "xx"'], 'E1012:') - CheckDefExecFailure(['&ts = g:astring'], 'E1012: Type mismatch; expected number but got string') - CheckDefFailure(['&path += 3'], 'E1012:') - CheckDefExecFailure(['&bs = "asdf"'], 'E474:') + v9.CheckDefFailure(['¬ex += 3'], 'E113:') + v9.CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') + v9.CheckDefFailure(['&ts = [7]'], 'E1012:') + v9.CheckDefExecFailure(['&ts = g:alist'], 'E1012: Type mismatch; expected number but got list') + v9.CheckDefFailure(['&ts = "xx"'], 'E1012:') + v9.CheckDefExecFailure(['&ts = g:astring'], 'E1012: Type mismatch; expected number but got string') + v9.CheckDefFailure(['&path += 3'], 'E1012:') + v9.CheckDefExecFailure(['&bs = "asdf"'], 'E474:') # test freeing ISN_STOREOPT - CheckDefFailure(['&ts = 3', 'var asdf'], 'E1022:') + v9.CheckDefFailure(['&ts = 3', 'var asdf'], 'E1022:') &ts = 8 lines =<< trim END @@ -204,13 +204,13 @@ def Test_assignment() assert_equal('xxx', &t_TI) &t_TI = save_TI END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefFailure(['&t_TI = 123'], 'E1012:') - CheckScriptFailure(['vim9script', '&t_TI = 123'], 'E928:') + v9.CheckDefFailure(['&t_TI = 123'], 'E1012:') + v9.CheckScriptFailure(['vim9script', '&t_TI = 123'], 'E928:') - CheckDefFailure(['var s:var = 123'], 'E1101:') - CheckDefFailure(['var s:var: number'], 'E1101:') + v9.CheckDefFailure(['var s:var = 123'], 'E1101:') + v9.CheckDefFailure(['var s:var: number'], 'E1101:') lines =<< trim END vim9script @@ -219,7 +219,7 @@ def Test_assignment() enddef defcompile END - CheckScriptFailure(lines, 'E1089:') + v9.CheckScriptFailure(lines, 'E1089:') g:inc_counter += 1 assert_equal(2, g:inc_counter) @@ -232,14 +232,14 @@ def Test_assignment() $SOME_ENV_VAR ..= 'more' assert_equal('somemore', $SOME_ENV_VAR) - CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:') - CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:') + v9.CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:') + v9.CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:') v:errmsg = 'none' v:errmsg ..= 'again' assert_equal('noneagain', v:errmsg) - CheckDefFailure(['v:errmsg += "more"'], 'E1051:') - CheckDefFailure(['v:errmsg += 123'], 'E1012:') + v9.CheckDefFailure(['v:errmsg += "more"'], 'E1051:') + v9.CheckDefFailure(['v:errmsg += 123'], 'E1012:') var text =<< trim END some text @@ -259,7 +259,7 @@ def Test_float_and_number() --f assert_equal(1.0, f) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) endif enddef @@ -275,18 +275,18 @@ def Test_assign_concat() s ..= g:someNumber assert_equal('-99true-null43', s) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var s = '-' s ..= [1, 2] END - CheckDefAndScriptFailure(lines, ['E1105: Cannot convert list to string', 'E734: Wrong variable type for .='], 2) + v9.CheckDefAndScriptFailure(lines, ['E1105: Cannot convert list to string', 'E734: Wrong variable type for .='], 2) lines =<< trim END var s = '-' s ..= {a: 2} END - CheckDefAndScriptFailure(lines, ['E1105: Cannot convert dict to string', 'E734: Wrong variable type for .='], 2) + v9.CheckDefAndScriptFailure(lines, ['E1105: Cannot convert dict to string', 'E734: Wrong variable type for .='], 2) enddef def Test_assign_register() @@ -298,16 +298,16 @@ def Test_assign_register() @@ = 'some text' assert_equal('some text', getreg('"')) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefFailure(['@a += "more"'], 'E1051:') - CheckDefFailure(['@a += 123'], 'E1012:') + v9.CheckDefFailure(['@a += "more"'], 'E1051:') + v9.CheckDefFailure(['@a += 123'], 'E1012:') enddef def Test_reserved_name() for name in ['true', 'false', 'null'] - CheckDefExecAndScriptFailure(['var ' .. name .. ' = 0'], 'E1034:') - CheckDefExecAndScriptFailure(['var ' .. name .. ': bool'], 'E1034:') + v9.CheckDefExecAndScriptFailure(['var ' .. name .. ' = 0'], 'E1034:') + v9.CheckDefExecAndScriptFailure(['var ' .. name .. ': bool'], 'E1034:') endfor enddef @@ -320,7 +320,7 @@ def Test_skipped_assignment() endwhile endfor END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_assign_keep_type() @@ -330,7 +330,7 @@ def Test_assign_keep_type() l = [123] l->add('string') END - CheckScriptFailure(lines, 'E1012:', 4) + v9.CheckScriptFailure(lines, 'E1012:', 4) enddef def Test_assign_unpack() @@ -382,62 +382,62 @@ def Test_assign_unpack() assert_equal(2, a) assert_equal(0, b) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var v1: number var v2: number [v1, v2] = [1, 2, 3] END - CheckDefFailure(lines, 'E1093: Expected 2 items but got 3', 3) + v9.CheckDefFailure(lines, 'E1093: Expected 2 items but got 3', 3) lines =<< trim END var v1: number var v2: number [v1, v2] = [1] END - CheckDefFailure(lines, 'E1093: Expected 2 items but got 1', 3) + v9.CheckDefFailure(lines, 'E1093: Expected 2 items but got 1', 3) lines =<< trim END var v1: number var v2: number [v1, v2; _] = [1] END - CheckDefFailure(lines, 'E1093: Expected 2 items but got 1', 3) + v9.CheckDefFailure(lines, 'E1093: Expected 2 items but got 1', 3) lines =<< trim END var v1: number var v2: number [v1, v2] = END - CheckDefFailure(lines, 'E1097:', 5) + v9.CheckDefFailure(lines, 'E1097:', 5) lines =<< trim END var v1: number var v2: number [v1, v2] = xxx END - CheckDefFailure(lines, 'E1001:', 3) + v9.CheckDefFailure(lines, 'E1001:', 3) lines =<< trim END var v1: number var v2: number [v1, v2] = popup_clear() END - CheckDefFailure(lines, 'E1031:', 3) + v9.CheckDefFailure(lines, 'E1031:', 3) lines =<< trim END [v1, v2] = [1, 2] END - CheckDefFailure(lines, 'E1089', 1) - CheckScriptFailure(['vim9script'] + lines, 'E1089', 2) + v9.CheckDefFailure(lines, 'E1089', 1) + v9.CheckScriptFailure(['vim9script'] + lines, 'E1089', 2) lines =<< trim END var v1: number var v2: number [v1, v2] = '' END - CheckDefFailure(lines, 'E1012: Type mismatch; expected list but got string', 3) + v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected list but got string', 3) lines =<< trim END g:values = [false, 0] @@ -445,7 +445,7 @@ def Test_assign_unpack() var y: string [x, y] = g:values END - CheckDefExecAndScriptFailure(lines, 'E1163: Variable 2: type mismatch, expected string but got number') + v9.CheckDefExecAndScriptFailure(lines, 'E1163: Variable 2: type mismatch, expected string but got number') lines =<< trim END var x: number @@ -453,7 +453,7 @@ def Test_assign_unpack() var z: string [x, y, z] = [1, 2, 3] END - CheckDefAndScriptFailure(lines, 'E1163: Variable 3: type mismatch, expected string but got number') + v9.CheckDefAndScriptFailure(lines, 'E1163: Variable 3: type mismatch, expected string but got number') lines =<< trim END var x: number @@ -461,7 +461,7 @@ def Test_assign_unpack() var z: string [x, y, z] = [1, '2', 3] END - CheckDefExecAndScriptFailure(lines, 'E1163: Variable 3: type mismatch, expected string but got number') + v9.CheckDefExecAndScriptFailure(lines, 'E1163: Variable 3: type mismatch, expected string but got number') enddef def Test_assign_linebreak() @@ -476,7 +476,7 @@ def Test_assign_linebreak() assert_equal(12, nr) assert_equal(34, n2) - CheckDefFailure(["var x = #"], 'E1097:', 3) + v9.CheckDefFailure(["var x = #"], 'E1097:', 3) var lines =<< trim END var x: list = ['a'] @@ -484,7 +484,7 @@ def Test_assign_linebreak() ->copy() ->copy() END - CheckDefFailure(lines, 'E1012:', 2) + v9.CheckDefFailure(lines, 'E1012:', 2) lines =<< trim END var x: any @@ -494,7 +494,7 @@ def Test_assign_linebreak() + 4 + 5 END - CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203:'], 2) + v9.CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203:'], 2) enddef def Test_assign_index() @@ -519,7 +519,7 @@ def Test_assign_index() l3[0] = [] l3[0][0] = [] END - CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got list', 3) + v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got list', 3) # dict of dict var d1: dict @@ -548,19 +548,19 @@ def Test_assign_index() d3.one = {} d3.one.two = {} END - CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got dict', 3) + v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got dict', 3) lines =<< trim END var lines: list lines['a'] = 'asdf' END - CheckDefFailure(lines, 'E1012:', 2) + v9.CheckDefFailure(lines, 'E1012:', 2) lines =<< trim END var lines: string lines[9] = 'asdf' END - CheckDefFailure(lines, 'E1141:', 2) + v9.CheckDefFailure(lines, 'E1141:', 2) # list of dict var ld: list> @@ -572,7 +572,7 @@ def Test_assign_index() var ld: list> ld[0] = [] END - CheckDefFailure(lines, 'E1012: Type mismatch; expected dict but got list', 2) + v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected dict but got list', 2) # dict of list var dl: dict> @@ -584,7 +584,7 @@ def Test_assign_index() var dl: dict> dl.one = {} END - CheckDefFailure(lines, 'E1012: Type mismatch; expected list but got dict', 2) + v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected list but got dict', 2) enddef def Test_init_in_for_loop() @@ -597,7 +597,7 @@ def Test_init_in_for_loop() endfor assert_equal([0, 0], l) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var l: list = [] @@ -608,7 +608,7 @@ def Test_init_in_for_loop() endfor assert_equal([0, 0], l) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var l: list = [] @@ -619,7 +619,7 @@ def Test_init_in_for_loop() endfor assert_equal([3, 3], l) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_extend_list() @@ -631,14 +631,14 @@ def Test_extend_list() assert_equal([123], l1) assert_true(l1 is l2) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var list: list extend(list, ['x']) assert_equal(['x'], list) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # appending to NULL list from a function lines =<< trim END @@ -650,7 +650,7 @@ def Test_extend_list() Func() assert_equal(['a', 'b'], list) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script var list: list @@ -660,7 +660,7 @@ def Test_extend_list() Func() assert_equal(['x', 'b'], list) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -668,13 +668,13 @@ def Test_extend_list() extend(l, ['x']) assert_equal(['x'], l) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script extend(test_null_list(), ['x']) END - CheckScriptFailure(lines, 'E1134:', 2) + v9.CheckScriptFailure(lines, 'E1134:', 2) # using global var has no declared type g:myList = [] @@ -690,7 +690,7 @@ def Test_extend_list() g:myList->extend([1]) g:myList->extend(['x']) END - CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list but got list', 4) + v9.CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list but got list', 4) unlet g:myList enddef @@ -705,7 +705,7 @@ def Test_extend_dict() d2['one'] = 1 assert_equal({one: 1}, d2) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -713,13 +713,13 @@ def Test_extend_dict() extend(d, {a: 'x'}) assert_equal({a: 'x'}, d) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script extend(test_null_dict(), {a: 'x'}) END - CheckScriptFailure(lines, 'E1133:', 2) + v9.CheckScriptFailure(lines, 'E1133:', 2) enddef def Test_single_letter_vars() @@ -805,7 +805,7 @@ def Test_assignment_list() list3 += ['end'] assert_equal(['sdf', 'asdf', 'end'], list3) - CheckDefExecFailure(['var ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:') + v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:') # type becomes list var somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] @@ -818,7 +818,7 @@ def Test_assignment_list() var d = {dd: test_null_list()} d.dd[0] = 0 END - CheckDefExecFailure(lines, 'E1147:', 2) + v9.CheckDefExecFailure(lines, 'E1147:', 2) lines =<< trim END def OneArg(x: bool) @@ -827,7 +827,7 @@ def Test_assignment_list() enddef var fl: list = [OneArg, TwoArgs] END - CheckDefExecAndScriptFailure(lines, 'E1012:', 5) + v9.CheckDefExecAndScriptFailure(lines, 'E1012:', 5) enddef def Test_list_declaration() @@ -840,21 +840,21 @@ def Test_list_declaration() var lines =<< trim END var [v1, v2] = [1] END - CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 1', 'E688:']) + v9.CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 1', 'E688:']) lines =<< trim END var testlist = [1] var [v1, v2] = testlist END - CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 1', 'E688:']) + v9.CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 1', 'E688:']) lines =<< trim END var [v1, v2] = [1, 2, 3] END - CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 3', 'E687:']) + v9.CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 3', 'E687:']) lines =<< trim END var testlist = [1, 2, 3] var [v1, v2] = testlist END - CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 3', 'E687:']) + v9.CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 3', 'E687:']) var [vnr, vstr] = [123, 'text'] vnr += 3 @@ -876,12 +876,12 @@ def Test_list_declaration() lines =<< trim END var [vnr2: number, vstr2: number] = [123, 'text'] END - CheckDefExecAndScriptFailure(lines, ['E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string']) + v9.CheckDefExecAndScriptFailure(lines, ['E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string']) lines =<< trim END var testlist = [234, 'text'] var [vnr2: number, vstr2: number] = testlist END - CheckDefExecAndScriptFailure(lines, ['E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string']) + v9.CheckDefExecAndScriptFailure(lines, ['E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string']) enddef def PartFuncBool(b: bool): string @@ -893,7 +893,7 @@ def Test_assignment_partial() var Partial: func(): string = function(PartFuncBool, [true]) assert_equal('done', Partial()) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END vim9script @@ -903,7 +903,7 @@ def Test_assignment_partial() assert_equal('func()', typename(Ref)) Ref() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -921,7 +921,7 @@ def Test_assignment_partial() assert_equal(0, nres) assert_equal('x', sres) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -933,7 +933,7 @@ def Test_assignment_partial() var Ref = function(Func, [n]) Ref(0) END - CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got number') + v9.CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got number') enddef def Test_assignment_list_any_index() @@ -954,7 +954,7 @@ def Test_assignment_list_vim9script() [v1, v2, v3] = [1, 2, 3] assert_equal([1, 2, 3], [v1, v2, v3]) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_assignment_dict() @@ -981,7 +981,7 @@ def Test_assignment_dict() dd.two = 2 assert_equal({two: 2}, dd) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var d = {dd: {}} @@ -990,19 +990,19 @@ def Test_assignment_dict() d.dd.y = 4 assert_equal({dd: {0: 2, x: 3, y: 4}}, d) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var dd = {one: 1} dd.one) = 2 END - CheckDefFailure(lines, 'E488:', 2) + v9.CheckDefFailure(lines, 'E488:', 2) lines =<< trim END var dd = {one: 1} var dd.one = 2 END - CheckDefAndScriptFailure(lines, 'E1017:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1017:', 2) # empty key can be used var dd = {} @@ -1030,7 +1030,7 @@ def Test_assignment_dict() g:myDict->extend({a: 1}) g:myDict->extend({b: 'x'}) END - CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict but got dict', 4) + v9.CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict but got dict', 4) unlet g:myDict # assignment to script-local dict @@ -1043,7 +1043,7 @@ def Test_assignment_dict() enddef assert_equal({a: 43}, FillDict()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1055,7 +1055,7 @@ def Test_assignment_dict() FillDict() assert_equal({a: 43}, test) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # assignment to global dict lines =<< trim END @@ -1067,7 +1067,7 @@ def Test_assignment_dict() enddef assert_equal({a: 43}, FillDict()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # assignment to buffer dict lines =<< trim END @@ -1079,25 +1079,25 @@ def Test_assignment_dict() enddef assert_equal({a: 43}, FillDict()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END var d = {dd: test_null_dict()} d.dd[0] = 0 END - CheckDefExecFailure(lines, 'E1103:', 2) + v9.CheckDefExecFailure(lines, 'E1103:', 2) lines =<< trim END var d = {dd: 'string'} d.dd[0] = 0 END - CheckDefExecFailure(lines, 'E1148:', 2) + v9.CheckDefExecFailure(lines, 'E1148:', 2) lines =<< trim END var n: any n.key = 5 END - CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203: Dot can only be used on a dictionary: n.key = 5'], 2) + v9.CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203: Dot can only be used on a dictionary: n.key = 5'], 2) enddef def Test_assignment_local() @@ -1135,7 +1135,7 @@ def Test_assignment_local() enddef call Test_assignment_local_internal() END - CheckScriptSuccess(script_lines) + v9.CheckScriptSuccess(script_lines) enddef def Test_assignment_default() @@ -1231,7 +1231,7 @@ def Test_assignment_var_list() assert_equal('error', v:errmsg) unlet g:globalvar END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) [g:globalvar, s:scriptvar, b:bufvar] = ['global', 'script', 'buf'] assert_equal('global', g:globalvar) @@ -1246,7 +1246,7 @@ def Test_assignment_var_list() assert_equal('script', s:scriptvar) assert_equal('win', w:winvar) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_assignment_vim9script() @@ -1297,7 +1297,7 @@ def Test_assignment_vim9script() to_var = 3 assert_equal(3, to_var) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1307,7 +1307,7 @@ def Test_assignment_vim9script() enddef defcompile END - CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got string') + v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got string') enddef def Mess(): string @@ -1316,93 +1316,93 @@ def Mess(): string enddef def Test_assignment_failure() - CheckDefFailure(['var name=234'], 'E1004:') - CheckDefFailure(['var name =234'], 'E1004:') - CheckDefFailure(['var name= 234'], 'E1004:') - - CheckScriptFailure(['vim9script', 'var name=234'], 'E1004:') - CheckScriptFailure(['vim9script', 'var name=234'], "before and after '='") - CheckScriptFailure(['vim9script', 'var name =234'], 'E1004:') - CheckScriptFailure(['vim9script', 'var name= 234'], 'E1004:') - CheckScriptFailure(['vim9script', 'var name = 234', 'name+=234'], 'E1004:') - CheckScriptFailure(['vim9script', 'var name = 234', 'name+=234'], "before and after '+='") - CheckScriptFailure(['vim9script', 'var name = "x"', 'name..="y"'], 'E1004:') - CheckScriptFailure(['vim9script', 'var name = "x"', 'name..="y"'], "before and after '..='") - - CheckDefFailure(['var true = 1'], 'E1034:') - CheckDefFailure(['var false = 1'], 'E1034:') - CheckDefFailure(['var null = 1'], 'E1034:') - CheckDefFailure(['var this = 1'], 'E1034:') - - CheckDefFailure(['[a; b; c] = g:list'], 'E452:') - CheckDefExecFailure(['var a: number', + v9.CheckDefFailure(['var name=234'], 'E1004:') + v9.CheckDefFailure(['var name =234'], 'E1004:') + v9.CheckDefFailure(['var name= 234'], 'E1004:') + + v9.CheckScriptFailure(['vim9script', 'var name=234'], 'E1004:') + v9.CheckScriptFailure(['vim9script', 'var name=234'], "before and after '='") + v9.CheckScriptFailure(['vim9script', 'var name =234'], 'E1004:') + v9.CheckScriptFailure(['vim9script', 'var name= 234'], 'E1004:') + v9.CheckScriptFailure(['vim9script', 'var name = 234', 'name+=234'], 'E1004:') + v9.CheckScriptFailure(['vim9script', 'var name = 234', 'name+=234'], "before and after '+='") + v9.CheckScriptFailure(['vim9script', 'var name = "x"', 'name..="y"'], 'E1004:') + v9.CheckScriptFailure(['vim9script', 'var name = "x"', 'name..="y"'], "before and after '..='") + + v9.CheckDefFailure(['var true = 1'], 'E1034:') + v9.CheckDefFailure(['var false = 1'], 'E1034:') + v9.CheckDefFailure(['var null = 1'], 'E1034:') + v9.CheckDefFailure(['var this = 1'], 'E1034:') + + v9.CheckDefFailure(['[a; b; c] = g:list'], 'E452:') + v9.CheckDefExecFailure(['var a: number', '[a] = test_null_list()'], 'E1093:') - CheckDefExecFailure(['var a: number', + v9.CheckDefExecFailure(['var a: number', '[a] = []'], 'E1093:') - CheckDefExecFailure(['var x: number', + v9.CheckDefExecFailure(['var x: number', 'var y: number', '[x, y] = [1]'], 'E1093:') - CheckDefExecFailure(['var x: string', + v9.CheckDefExecFailure(['var x: string', 'var y: string', '[x, y] = ["x"]'], 'E1093:') - CheckDefExecFailure(['var x: number', + v9.CheckDefExecFailure(['var x: number', 'var y: number', 'var z: list', '[x, y; z] = [1]'], 'E1093:') - CheckDefFailure(['var somevar'], "E1022:") - CheckDefFailure(['var &tabstop = 4'], 'E1052:') - CheckDefFailure(['&g:option = 5'], 'E113:') - CheckScriptFailure(['vim9script', 'var &tabstop = 4'], 'E1052:') + v9.CheckDefFailure(['var somevar'], "E1022:") + v9.CheckDefFailure(['var &tabstop = 4'], 'E1052:') + v9.CheckDefFailure(['&g:option = 5'], 'E113:') + v9.CheckScriptFailure(['vim9script', 'var &tabstop = 4'], 'E1052:') - CheckDefFailure(['var $VAR = 5'], 'E1016: Cannot declare an environment variable:') - CheckScriptFailure(['vim9script', 'var $ENV = "xxx"'], 'E1016:') + v9.CheckDefFailure(['var $VAR = 5'], 'E1016: Cannot declare an environment variable:') + v9.CheckScriptFailure(['vim9script', 'var $ENV = "xxx"'], 'E1016:') if has('dnd') - CheckDefFailure(['var @~ = 5'], 'E1066:') + v9.CheckDefFailure(['var @~ = 5'], 'E1066:') else - CheckDefFailure(['var @~ = 5'], 'E354:') - CheckDefFailure(['@~ = 5'], 'E354:') + v9.CheckDefFailure(['var @~ = 5'], 'E354:') + v9.CheckDefFailure(['@~ = 5'], 'E354:') endif - CheckDefFailure(['var @a = 5'], 'E1066:') - CheckDefFailure(['var @/ = "x"'], 'E1066:') - CheckScriptFailure(['vim9script', 'var @a = "abc"'], 'E1066:') + v9.CheckDefFailure(['var @a = 5'], 'E1066:') + v9.CheckDefFailure(['var @/ = "x"'], 'E1066:') + v9.CheckScriptFailure(['vim9script', 'var @a = "abc"'], 'E1066:') - CheckDefFailure(['var g:var = 5'], 'E1016: Cannot declare a global variable:') - CheckDefFailure(['var w:var = 5'], 'E1016: Cannot declare a window variable:') - CheckDefFailure(['var b:var = 5'], 'E1016: Cannot declare a buffer variable:') - CheckDefFailure(['var t:var = 5'], 'E1016: Cannot declare a tab variable:') + v9.CheckDefFailure(['var g:var = 5'], 'E1016: Cannot declare a global variable:') + v9.CheckDefFailure(['var w:var = 5'], 'E1016: Cannot declare a window variable:') + v9.CheckDefFailure(['var b:var = 5'], 'E1016: Cannot declare a buffer variable:') + v9.CheckDefFailure(['var t:var = 5'], 'E1016: Cannot declare a tab variable:') - CheckDefFailure(['var anr = 4', 'anr ..= "text"'], 'E1019:') - CheckDefFailure(['var xnr += 4'], 'E1020:', 1) - CheckScriptFailure(['vim9script', 'var xnr += 4'], 'E1020:') - CheckDefFailure(["var xnr = xnr + 1"], 'E1001:', 1) - CheckScriptFailure(['vim9script', 'var xnr = xnr + 4'], 'E121:') + v9.CheckDefFailure(['var anr = 4', 'anr ..= "text"'], 'E1019:') + v9.CheckDefFailure(['var xnr += 4'], 'E1020:', 1) + v9.CheckScriptFailure(['vim9script', 'var xnr += 4'], 'E1020:') + v9.CheckDefFailure(["var xnr = xnr + 1"], 'E1001:', 1) + v9.CheckScriptFailure(['vim9script', 'var xnr = xnr + 4'], 'E121:') - CheckScriptFailure(['vim9script', 'def Func()', 'var dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:') + v9.CheckScriptFailure(['vim9script', 'def Func()', 'var dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:') - CheckDefFailure(['var name: list = [123]'], 'expected list but got list') - CheckDefFailure(['var name: list = ["xx"]'], 'expected list but got list') + v9.CheckDefFailure(['var name: list = [123]'], 'expected list but got list') + v9.CheckDefFailure(['var name: list = ["xx"]'], 'expected list but got list') - CheckDefFailure(['var name: dict = {key: 123}'], 'expected dict but got dict') - CheckDefFailure(['var name: dict = {key: "xx"}'], 'expected dict but got dict') + v9.CheckDefFailure(['var name: dict = {key: 123}'], 'expected dict but got dict') + v9.CheckDefFailure(['var name: dict = {key: "xx"}'], 'expected dict but got dict') - CheckDefFailure(['var name = feedkeys("0")'], 'E1031:') - CheckDefFailure(['var name: number = feedkeys("0")'], 'expected number but got void') + v9.CheckDefFailure(['var name = feedkeys("0")'], 'E1031:') + v9.CheckDefFailure(['var name: number = feedkeys("0")'], 'expected number but got void') - CheckDefFailure(['var name: dict '], 'E1068:') - CheckDefFailure(['var name: dict'], 'E1068:') + v9.CheckDefFailure(['var name: dict = ['', true]"], 'E1012: Type mismatch; expected list but got list', 1) - CheckDefFailure(["var l: list> = [['', true]]"], 'E1012: Type mismatch; expected list> but got list>', 1) + v9.CheckDefFailure(["var l: list = ['', true]"], 'E1012: Type mismatch; expected list but got list', 1) + v9.CheckDefFailure(["var l: list> = [['', true]]"], 'E1012: Type mismatch; expected list> but got list>', 1) enddef def Test_assign_dict() @@ -1457,10 +1457,10 @@ def Test_assign_dict() unlet d.somekey assert_equal({key: 'value', '123': 'qwerty'}, d) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefFailure(["var d: dict = {a: '', b: true}"], 'E1012: Type mismatch; expected dict but got dict', 1) - CheckDefFailure(["var d: dict> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict> but got dict>', 1) + v9.CheckDefFailure(["var d: dict = {a: '', b: true}"], 'E1012: Type mismatch; expected dict but got dict', 1) + v9.CheckDefFailure(["var d: dict> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict> but got dict>', 1) enddef def Test_assign_dict_unknown_type() @@ -1474,7 +1474,7 @@ def Test_assign_dict_unknown_type() enddef Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1486,7 +1486,7 @@ def Test_assign_dict_unknown_type() enddef Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_assign_dict_with_op() @@ -1532,7 +1532,7 @@ def Test_assign_dict_with_op() dab.a[0] ..= 'c' assert_equal({a: ['bc']}, dab) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_assign_list_with_op() @@ -1557,7 +1557,7 @@ def Test_assign_list_with_op() ln[0] %= 3 assert_equal(2, ln[0]) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_assign_with_op_fails() @@ -1565,20 +1565,20 @@ def Test_assign_with_op_fails() var s = 'abc' s[1] += 'x' END - CheckDefAndScriptFailure(lines, ['E1141:', 'E689:'], 2) + v9.CheckDefAndScriptFailure(lines, ['E1141:', 'E689:'], 2) lines =<< trim END var s = 'abc' s[1] ..= 'x' END - CheckDefAndScriptFailure(lines, ['E1141:', 'E689:'], 2) + v9.CheckDefAndScriptFailure(lines, ['E1141:', 'E689:'], 2) lines =<< trim END var dd: dict>> dd.a = {} dd.a.b += [1] END - CheckDefExecAndScriptFailure(lines, 'E716:', 3) + v9.CheckDefExecAndScriptFailure(lines, 'E716:', 3) enddef def Test_assign_lambda() @@ -1594,18 +1594,18 @@ def Test_assign_lambda() var FuncRef_Number: func(): number = () => 321 assert_equal(321, FuncRef_Number()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END var Ref: func(number) Ref = (j) => !j END - CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(any): bool') + v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(any): bool') lines =<< trim END echo filter([1, 2, 3], (_, v: string) => v + 1) END - CheckDefAndScriptFailure(lines, 'E1051:') + v9.CheckDefAndScriptFailure(lines, 'E1051:') enddef def Test_heredoc() @@ -1614,8 +1614,8 @@ def Test_heredoc() END assert_equal(['text'], lines) - CheckDefFailure(['var lines =<< trim END X', 'END'], 'E488:') - CheckDefFailure(['var lines =<< trim END " comment', 'END'], 'E488:') + v9.CheckDefFailure(['var lines =<< trim END X', 'END'], 'E488:') + v9.CheckDefFailure(['var lines =<< trim END " comment', 'END'], 'E488:') lines =<< trim [END] def Func() @@ -1625,7 +1625,7 @@ def Test_heredoc() enddef defcompile [END] - CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END') + v9.CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END') delfunc! g:Func lines =<< trim [END] @@ -1642,7 +1642,7 @@ def Test_heredoc() enddef call Func() [END] - CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END') + v9.CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END') delfunc! g:Func lines =<< trim END @@ -1651,7 +1651,7 @@ def Test_heredoc() bbb STOP END - CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list', 1) enddef def Test_var_func_call() @@ -1683,14 +1683,14 @@ def Test_var_missing_type() vim9script var name = g:unknown END - CheckScriptFailure(lines, 'E121:') + v9.CheckScriptFailure(lines, 'E121:') lines =<< trim END vim9script var nr: number = 123 var name = nr END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_var_declaration() @@ -1757,7 +1757,7 @@ def Test_var_declaration() enddef ChangeAdict() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_equal('', g:var_uninit) assert_equal('text', g:var_test) assert_equal('prefixed', g:var_prefixed) @@ -1782,14 +1782,14 @@ def Test_var_declaration_fails() vim9script final var: string END - CheckScriptFailure(lines, 'E1125:') + v9.CheckScriptFailure(lines, 'E1125:') lines =<< trim END vim9script const g:constvar = 'string' g:constvar = 'xx' END - CheckScriptFailure(lines, 'E741:') + v9.CheckScriptFailure(lines, 'E741:') unlet g:constvar lines =<< trim END @@ -1801,7 +1801,7 @@ def Test_var_declaration_fails() enddef SetLocked() END - CheckScriptFailure(lines, 'E741: Value is locked: name', 1) + v9.CheckScriptFailure(lines, 'E741: Value is locked: name', 1) lines =<< trim END let s:legacy = 'one' @@ -1811,7 +1811,7 @@ def Test_var_declaration_fails() enddef call SetLocked() END - CheckScriptFailure(lines, 'E741: Value is locked: s:legacy', 1) + v9.CheckScriptFailure(lines, 'E741: Value is locked: s:legacy', 1) lines =<< trim END vim9script @@ -1821,7 +1821,7 @@ def Test_var_declaration_fails() SetGlobalConst() g:globConst = 234 END - CheckScriptFailure(lines, 'E741: Value is locked: g:globConst', 6) + v9.CheckScriptFailure(lines, 'E741: Value is locked: g:globConst', 6) unlet g:globConst lines =<< trim END @@ -1832,31 +1832,31 @@ def Test_var_declaration_fails() enddef defcompile END - CheckScriptFailure(lines, 'E46:') + v9.CheckScriptFailure(lines, 'E46:') lines =<< trim END vim9script final w:finalvar = [9] w:finalvar = [8] END - CheckScriptFailure(lines, 'E1122:') + v9.CheckScriptFailure(lines, 'E1122:') unlet w:finalvar lines =<< trim END vim9script const var: string END - CheckScriptFailure(lines, 'E1021:') + v9.CheckScriptFailure(lines, 'E1021:') lines =<< trim END vim9script var 9var: string END - CheckScriptFailure(lines, 'E488:') + v9.CheckScriptFailure(lines, 'E488:') - CheckDefFailure(['var foo.bar = 2'], 'E1087:') - CheckDefFailure(['var foo[3] = 2'], 'E1087:') - CheckDefFailure(['const foo: number'], 'E1021:') + v9.CheckDefFailure(['var foo.bar = 2'], 'E1087:') + v9.CheckDefFailure(['var foo[3] = 2'], 'E1087:') + v9.CheckDefFailure(['const foo: number'], 'E1021:') enddef def Test_script_local_in_legacy() @@ -1870,7 +1870,7 @@ def Test_script_local_in_legacy() call SetLater() call assert_equal('two', s:legvar) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # OK to leave out s: prefix when script-local already defined lines =<< trim END @@ -1881,7 +1881,7 @@ def Test_script_local_in_legacy() call SetNoPrefix() call assert_equal('two', s:legvar) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # Not OK to leave out s: prefix when script-local defined later lines =<< trim END @@ -1891,14 +1891,14 @@ def Test_script_local_in_legacy() defcompile let s:legvar = 'one' END - CheckScriptFailure(lines, 'E476:', 1) + v9.CheckScriptFailure(lines, 'E476:', 1) edit! Xfile lines =<< trim END var edit: bool legacy edit END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_var_type_check() @@ -1907,35 +1907,35 @@ def Test_var_type_check() var name: string name = 1234 END - CheckScriptFailure(lines, 'E1012:') + v9.CheckScriptFailure(lines, 'E1012:') lines =<< trim END vim9script var name:string END - CheckScriptFailure(lines, 'E1069:') + v9.CheckScriptFailure(lines, 'E1069:') - CheckDefAndScriptFailure(['var n:number = 42'], 'E1069:') + v9.CheckDefAndScriptFailure(['var n:number = 42'], 'E1069:') lines =<< trim END vim9script var name: asdf END - CheckScriptFailure(lines, 'E1010:') + v9.CheckScriptFailure(lines, 'E1010:') lines =<< trim END vim9script var s:l: list s:l = [] END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script var s:d: dict s:d = {} END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1945,7 +1945,7 @@ def Test_var_type_check() enddef defcompile END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef let g:dict_number = #{one: 1, two: 2} @@ -1963,11 +1963,11 @@ def Test_var_list_dict_type() var ll: list ll = [1, 2, 3]->map('"one"') END - CheckDefExecFailure(lines, 'E1012: Type mismatch; expected list but got list') + v9.CheckDefExecFailure(lines, 'E1012: Type mismatch; expected list but got list') enddef def Test_cannot_use_let() - CheckDefAndScriptFailure(['let a = 34'], 'E1126:', 1) + v9.CheckDefAndScriptFailure(['let a = 34'], 'E1126:', 1) enddef def Test_unlet() @@ -1984,7 +1984,7 @@ def Test_unlet() assert_false(exists('s:somevar')) unlet! s:somevar - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var dd = 111', 'unlet dd', ], 'E1081:', 2) @@ -2013,41 +2013,41 @@ def Test_unlet() unlet ll[-2 : -1] assert_equal([1, 2], ll) - CheckDefFailure([ + v9.CheckDefFailure([ 'var ll = [1, 2]', 'll[1 : 2] = 7', ], 'E1012: Type mismatch; expected list but got number', 2) - CheckDefFailure([ + v9.CheckDefFailure([ 'var dd = {a: 1}', 'unlet dd["a" : "a"]', ], 'E1166:', 2) - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'unlet g:adict[0 : 1]', ], 'E1148:', 1) - CheckDefFailure([ + v9.CheckDefFailure([ 'var ll = [1, 2]', 'unlet ll[0:1]', ], 'E1004:', 2) - CheckDefFailure([ + v9.CheckDefFailure([ 'var ll = [1, 2]', 'unlet ll[0 :1]', ], 'E1004:', 2) - CheckDefFailure([ + v9.CheckDefFailure([ 'var ll = [1, 2]', 'unlet ll[0: 1]', ], 'E1004:', 2) # command recognized as assignment when skipping, should not give an error - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'for i in []', " put =''", 'endfor']) - CheckDefFailure([ + v9.CheckDefFailure([ 'var ll = [1, 2]', 'unlet ll["x" : 1]', ], 'E1012:', 2) - CheckDefFailure([ + v9.CheckDefFailure([ 'var ll = [1, 2]', 'unlet ll[0 : "x"]', ], 'E1012:', 2) @@ -2057,27 +2057,27 @@ def Test_unlet() unlet dl[0]['b'] assert_equal([{a: 1}, {c: 3}], dl) - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var ll = test_null_list()', 'unlet ll[0]', ], 'E684:', 2) - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var ll = [1]', 'unlet ll[2]', ], 'E684:', 2) - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var ll = [1]', 'unlet ll[g:astring]', ], 'E1012:', 2) - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var dd = test_null_dict()', 'unlet dd["a"]', ], 'E716:', 2) - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var dd = {a: 1}', 'unlet dd["b"]', ], 'E716:', 2) - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var dd = {a: 1}', 'unlet dd[g:alist]', ], 'E1105:', 2) @@ -2090,17 +2090,17 @@ def Test_unlet() unlet g:someDict assert_false(exists('g:someDict')) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var svar = 123', 'unlet svar', ], 'E1081:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var svar = 123', 'unlet s:svar', ], 'E1081:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var svar = 123', 'def Func()', @@ -2108,7 +2108,7 @@ def Test_unlet() 'enddef', 'defcompile', ], 'E1081:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var svar = 123', 'func Func()', @@ -2116,7 +2116,7 @@ def Test_unlet() 'endfunc', 'Func()', ], 'E1081:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var svar = 123', 'def Func()', @@ -2125,7 +2125,7 @@ def Test_unlet() 'defcompile', ], 'E1081:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'def Delcount(dict: dict)', ' unlet dict.count', @@ -2133,7 +2133,7 @@ def Test_unlet() 'Delcount(v:)', ], 'E742:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'def DelChangedtick(dict: dict)', ' unlet dict.changedtick', @@ -2150,7 +2150,7 @@ def Test_unlet() enddef defcompile END - CheckScriptFailure(lines, 'E1260:', 1) + v9.CheckScriptFailure(lines, 'E1260:', 1) delete('XunletExport.vim') $ENVVAR = 'foobar' @@ -2165,26 +2165,26 @@ def Test_expr_error_no_assign() var x = invalid echo x END - CheckScriptFailureList(lines, ['E121:', 'E121:']) + v9.CheckScriptFailureList(lines, ['E121:', 'E121:']) lines =<< trim END vim9script var x = 1 / 0 echo x END - CheckScriptFailure(lines, 'E1154:') + v9.CheckScriptFailure(lines, 'E1154:') lines =<< trim END vim9script var x = 1 % 0 echo x END - CheckScriptFailure(lines, 'E1154:') + v9.CheckScriptFailure(lines, 'E1154:') lines =<< trim END var x: string 'string' END - CheckDefAndScriptFailure(lines, 'E488:') + v9.CheckDefAndScriptFailure(lines, 'E488:') enddef @@ -2212,7 +2212,7 @@ def Test_assign_command_modifier() assert_equal(1, x) assert_equal(2, y) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_assign_alt_buf_register() @@ -2225,7 +2225,7 @@ def Test_assign_alt_buf_register() @# = b2 assert_equal(b2, bufnr('#')) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_script_funcref_case() @@ -2233,25 +2233,25 @@ def Test_script_funcref_case() var Len = (s: string): number => len(s) + 1 assert_equal(5, Len('asdf')) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var len = (s: string): number => len(s) + 1 END - CheckDefAndScriptFailure(lines, 'E704:') + v9.CheckDefAndScriptFailure(lines, 'E704:') lines =<< trim END vim9script var s:Len = (s: string): number => len(s) + 2 assert_equal(6, Len('asdf')) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script var s:len = (s: string): number => len(s) + 1 END - CheckScriptFailure(lines, 'E704:') + v9.CheckScriptFailure(lines, 'E704:') enddef def Test_script_funcref_runtime_type_check() @@ -2265,10 +2265,10 @@ def Test_script_funcref_runtime_type_check() defcompile END # OK at compile time - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # Type check fails at runtime - CheckScriptFailure(lines + ['Test()'], 'E1012: Type mismatch; expected func(string) but got func(number)') + v9.CheckScriptFailure(lines + ['Test()'], 'E1012: Type mismatch; expected func(string) but got func(number)') enddef def Test_inc_dec() @@ -2294,13 +2294,13 @@ def Test_inc_dec() assert_equal(1, g:count) unlet g:count END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var nr = 7 ++ nr END - CheckDefAndScriptFailure(lines, "E1202: No white space allowed after '++': ++ nr") + v9.CheckDefAndScriptFailure(lines, "E1202: No white space allowed after '++': ++ nr") enddef def Test_abort_after_error() @@ -2325,13 +2325,13 @@ endfunc def Run_Test_declare_command_line() # On the command line the type is parsed but not used. # To get rid of the script context have to run this in another Vim instance. - var buf = RunVimInTerminal('', {'rows': 6}) + var buf = g:RunVimInTerminal('', {'rows': 6}) term_sendkeys(buf, ":vim9 var abc: list> = [ [1, 2, 3], [4, 5, 6] ]\") - TermWait(buf) + g:TermWait(buf) term_sendkeys(buf, ":echo abc\") - TermWait(buf) - WaitForAssert(() => assert_match('\[\[1, 2, 3\], \[4, 5, 6\]\]', term_getline(buf, 6))) - StopVimInTerminal(buf) + g:TermWait(buf) + g:WaitForAssert(() => assert_match('\[\[1, 2, 3\], \[4, 5, 6\]\]', term_getline(buf, 6))) + g:StopVimInTerminal(buf) enddef diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 32467b472..b3c4dd077 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -1,7 +1,7 @@ " Test using builtin functions in the Vim9 script language. source check.vim -source vim9.vim +import './vim9.vim' as v9 " Test for passing too many or too few arguments to builtin functions func Test_internalfunc_arg_error() @@ -67,7 +67,7 @@ def Test_abs() assert_equal(0, abs(0)) assert_equal(2, abs(-2)) assert_equal(3, abs(3)) - CheckDefAndScriptFailure(['abs("text")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['abs("text")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) if has('float') assert_equal(0, abs(0)) assert_equal(2.0, abs(-2.0)) @@ -76,8 +76,8 @@ def Test_abs() enddef def Test_add() - CheckDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1226: List or Blob required for argument 1']) - CheckDefFailure(['add([1], "a")'], 'E1012: Type mismatch; expected number but got string') + v9.CheckDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1226: List or Blob required for argument 1']) + v9.CheckDefFailure(['add([1], "a")'], 'E1012: Type mismatch; expected number but got string') var lines =<< trim END vim9script @@ -88,7 +88,7 @@ def Test_add() enddef TryChange() END - CheckScriptFailure(lines, 'E741:') + v9.CheckScriptFailure(lines, 'E741:') enddef def Test_add_blob() @@ -104,18 +104,18 @@ def Test_add_blob() var b: blob add(b, "x") END - CheckDefFailure(lines, 'E1012:', 2) + v9.CheckDefFailure(lines, 'E1012:', 2) lines =<< trim END add(test_null_blob(), 123) END - CheckDefExecAndScriptFailure(lines, 'E1131:', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E1131:', 1) lines =<< trim END var b: blob = test_null_blob() add(b, 123) END - CheckDefExecFailure(lines, 'E1131:', 2) + v9.CheckDefExecFailure(lines, 'E1131:', 2) # Getting variable with NULL blob allocates a new blob at script level lines =<< trim END @@ -123,7 +123,7 @@ def Test_add_blob() var b: blob = test_null_blob() add(b, 123) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_add_list() @@ -135,18 +135,18 @@ def Test_add_list() var l: list add(l, "x") END - CheckDefFailure(lines, 'E1012:', 2) + v9.CheckDefFailure(lines, 'E1012:', 2) lines =<< trim END add(test_null_list(), 123) END - CheckDefExecAndScriptFailure(lines, 'E1130:', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E1130:', 1) lines =<< trim END var l: list = test_null_list() add(l, 123) END - CheckDefExecFailure(lines, 'E1130:', 2) + v9.CheckDefExecFailure(lines, 'E1130:', 2) # Getting variable with NULL list allocates a new list at script level lines =<< trim END @@ -154,26 +154,26 @@ def Test_add_list() var l: list = test_null_list() add(l, 123) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script var l: list = ['a'] l->add(123) END - CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3) + v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3) lines =<< trim END vim9script var l: list l->add(123) END - CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3) + v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3) enddef def Test_and() - CheckDefAndScriptFailure(['and("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['and(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['and("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['and(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_append() @@ -191,12 +191,12 @@ def Test_append() assert_equal("{'a': 10}", getline(1)) append(0, function('min')) assert_equal("function('min')", getline(1)) - CheckDefAndScriptFailure(['append([1], "x")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['append("", "x")'], 'E1209: Invalid value for a line number') - CheckDefExecAndScriptFailure(['append(".a", "x")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['append([1], "x")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['append("", "x")'], 'E1209: Invalid value for a line number') + v9.CheckDefExecAndScriptFailure(['append(".a", "x")'], 'E1209: Invalid value for a line number') # only get one error assert_fails('append("''aa", "x")', ['E1209: Invalid value for a line number: "''aa"', 'E1209:']) - CheckDefExecAndScriptFailure(['append(-1, "x")'], 'E966: Invalid line number: -1') + v9.CheckDefExecAndScriptFailure(['append(-1, "x")'], 'E966: Invalid line number: -1') bwipe! enddef @@ -212,12 +212,12 @@ def Test_appendbufline() assert_equal(['0', 'one', '1', 'two', '2', ''], getbufline(bnum, 1, '$')) appendbufline(bnum, 0, 'zero') assert_equal(['zero'], getbufline(bnum, 1)) - CheckDefAndScriptFailure(['appendbufline([1], 1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['appendbufline(1, [1], "x")'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) - CheckDefExecAndScriptFailure(['appendbufline(' .. bnum .. ', -1, "x")'], 'E966: Invalid line number: -1') - CheckDefExecAndScriptFailure(['appendbufline(' .. bnum .. ', "$a", "x")'], 'E1030: Using a String as a Number: "$a"') + v9.CheckDefAndScriptFailure(['appendbufline([1], 1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['appendbufline(1, [1], "x")'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) + v9.CheckDefExecAndScriptFailure(['appendbufline(' .. bnum .. ', -1, "x")'], 'E966: Invalid line number: -1') + v9.CheckDefExecAndScriptFailure(['appendbufline(' .. bnum .. ', "$a", "x")'], 'E1030: Using a String as a Number: "$a"') assert_fails('appendbufline(' .. bnum .. ', "$a", "x")', ['E1030: Using a String as a Number: "$a"', 'E1030:']) - CheckDefAndScriptFailure(['appendbufline(1, 1, {"a": 10})'], ['E1013: Argument 3: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 3']) + v9.CheckDefAndScriptFailure(['appendbufline(1, 1, {"a": 10})'], ['E1013: Argument 3: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 3']) bnum->bufwinid()->win_gotoid() appendbufline('', 0, 'numbers') getline(1)->assert_equal('numbers') @@ -225,68 +225,68 @@ def Test_appendbufline() enddef def Test_argc() - CheckDefAndScriptFailure(['argc("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['argc("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_arglistid() - CheckDefAndScriptFailure(['arglistid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['arglistid(1, "y")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['arglistid("x", "y")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['arglistid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['arglistid(1, "y")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['arglistid("x", "y")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_argv() - CheckDefAndScriptFailure(['argv("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['argv(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['argv("x", "y")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['argv("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['argv(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['argv("x", "y")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_assert_beeps() - CheckDefAndScriptFailure(['assert_beeps(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['assert_beeps(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) enddef def Test_assert_equalfile() - CheckDefAndScriptFailure(['assert_equalfile(1, "f2")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['assert_equalfile("f1", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['assert_equalfile("f1", "f2", ["a"])'], ['E1013: Argument 3: type mismatch, expected string but got list', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['assert_equalfile(1, "f2")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['assert_equalfile("f1", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['assert_equalfile("f1", "f2", ["a"])'], ['E1013: Argument 3: type mismatch, expected string but got list', 'E1174: String required for argument 3']) enddef def Test_assert_exception() - CheckDefAndScriptFailure(['assert_exception({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['assert_exception("E1:", v:null)'], ['E1013: Argument 2: type mismatch, expected string but got special', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['assert_exception({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['assert_exception("E1:", v:null)'], ['E1013: Argument 2: type mismatch, expected string but got special', 'E1174: String required for argument 2']) enddef def Test_assert_fails() - CheckDefAndScriptFailure(['assert_fails([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['assert_fails("a", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1222: String or List required for argument 2']) - CheckDefAndScriptFailure(['assert_fails("a", "b", "c", "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) - CheckDefAndScriptFailure(['assert_fails("a", "b", "c", 4, 5)'], ['E1013: Argument 5: type mismatch, expected string but got number', 'E1174: String required for argument 5']) + v9.CheckDefAndScriptFailure(['assert_fails([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['assert_fails("a", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1222: String or List required for argument 2']) + v9.CheckDefAndScriptFailure(['assert_fails("a", "b", "c", "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['assert_fails("a", "b", "c", 4, 5)'], ['E1013: Argument 5: type mismatch, expected string but got number', 'E1174: String required for argument 5']) enddef def Test_assert_inrange() - CheckDefAndScriptFailure(['assert_inrange("a", 2, 3)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) - CheckDefAndScriptFailure(['assert_inrange(1, "b", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2']) - CheckDefAndScriptFailure(['assert_inrange(1, 2, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 3']) - CheckDefAndScriptFailure(['assert_inrange(1, 2, 3, 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']) + v9.CheckDefAndScriptFailure(['assert_inrange("a", 2, 3)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['assert_inrange(1, "b", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['assert_inrange(1, 2, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 3']) + v9.CheckDefAndScriptFailure(['assert_inrange(1, 2, 3, 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']) enddef def Test_assert_match() - CheckDefAndScriptFailure(['assert_match({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', '']) - CheckDefAndScriptFailure(['assert_match("a", 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', '']) - CheckDefAndScriptFailure(['assert_match("a", "b", null)'], ['E1013: Argument 3: type mismatch, expected string but got special', '']) + v9.CheckDefAndScriptFailure(['assert_match({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', '']) + v9.CheckDefAndScriptFailure(['assert_match("a", 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', '']) + v9.CheckDefAndScriptFailure(['assert_match("a", "b", null)'], ['E1013: Argument 3: type mismatch, expected string but got special', '']) enddef def Test_assert_nobeep() - CheckDefAndScriptFailure(['assert_nobeep(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['assert_nobeep(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) enddef def Test_assert_notmatch() - CheckDefAndScriptFailure(['assert_notmatch({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', '']) - CheckDefAndScriptFailure(['assert_notmatch("a", 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', '']) - CheckDefAndScriptFailure(['assert_notmatch("a", "b", null)'], ['E1013: Argument 3: type mismatch, expected string but got special', '']) + v9.CheckDefAndScriptFailure(['assert_notmatch({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', '']) + v9.CheckDefAndScriptFailure(['assert_notmatch("a", 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', '']) + v9.CheckDefAndScriptFailure(['assert_notmatch("a", "b", null)'], ['E1013: Argument 3: type mismatch, expected string but got special', '']) enddef def Test_assert_report() - CheckDefAndScriptFailure(['assert_report([1, 2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['assert_report([1, 2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_balloon_show() @@ -296,8 +296,8 @@ def Test_balloon_show() assert_fails('balloon_show(10)', 'E1222:') assert_fails('balloon_show(true)', 'E1222:') - CheckDefAndScriptFailure(['balloon_show(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['balloon_show({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['balloon_show(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['balloon_show({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) enddef def Test_balloon_split() @@ -308,22 +308,22 @@ def Test_balloon_split() enddef def Test_blob2list() - CheckDefAndScriptFailure(['blob2list(10)'], ['E1013: Argument 1: type mismatch, expected blob but got number', 'E1238: Blob required for argument 1']) + v9.CheckDefAndScriptFailure(['blob2list(10)'], ['E1013: Argument 1: type mismatch, expected blob but got number', 'E1238: Blob required for argument 1']) enddef def Test_browse() CheckFeature browse - CheckDefAndScriptFailure(['browse(2, "title", "dir", "file")'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) - CheckDefAndScriptFailure(['browse(true, 2, "dir", "file")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['browse(true, "title", 3, "file")'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) - CheckDefAndScriptFailure(['browse(true, "title", "dir", 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']) + v9.CheckDefAndScriptFailure(['browse(2, "title", "dir", "file")'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['browse(true, 2, "dir", "file")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['browse(true, "title", 3, "file")'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['browse(true, "title", "dir", 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']) enddef def Test_browsedir() if has('browse') - CheckDefAndScriptFailure(['browsedir({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['browsedir("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['browsedir({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['browsedir("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) endif enddef @@ -372,8 +372,8 @@ def Test_bufnr() buf = bufnr('Xdummy', true) buf->assert_notequal(-1) exe 'bwipe! ' .. buf - CheckDefAndScriptFailure(['bufnr([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['bufnr(1, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['bufnr([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['bufnr(1, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) enddef def Test_bufwinid() @@ -399,21 +399,21 @@ def Test_bufwinnr() enddef def Test_byte2line() - CheckDefAndScriptFailure(['byte2line("1")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['byte2line([])'], ['E1013: Argument 1: type mismatch, expected number but got list', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['byte2line("1")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['byte2line([])'], ['E1013: Argument 1: type mismatch, expected number but got list', 'E1210: Number required for argument 1']) byte2line(0)->assert_equal(-1) enddef def Test_byteidx() - CheckDefAndScriptFailure(['byteidx(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['byteidx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['byteidx(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['byteidx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) byteidx('', 0)->assert_equal(0) byteidx('', 1)->assert_equal(-1) enddef def Test_byteidxcomp() - CheckDefAndScriptFailure(['byteidxcomp(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['byteidxcomp("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['byteidxcomp(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['byteidxcomp("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_call_call() @@ -421,17 +421,17 @@ def Test_call_call() call('reverse', [l]) l->assert_equal([1, 2, 3]) - CheckDefExecAndScriptFailure(['call(123, [2])'], 'E1256: String or function required for argument 1') - CheckDefExecAndScriptFailure(['call(true, [2])'], 'E1256: String or function required for argument 1') - CheckDefAndScriptFailure(['call("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) - CheckDefAndScriptFailure(['call("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefExecAndScriptFailure(['call(123, [2])'], 'E1256: String or function required for argument 1') + v9.CheckDefExecAndScriptFailure(['call(true, [2])'], 'E1256: String or function required for argument 1') + v9.CheckDefAndScriptFailure(['call("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) + v9.CheckDefAndScriptFailure(['call("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef def Test_ch_canread() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_canread(10)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_canread(10)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) endif enddef @@ -439,7 +439,7 @@ def Test_ch_close() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_close("c")'], ['E1013: Argument 1: type mismatch, expected channel but got string', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_close("c")'], ['E1013: Argument 1: type mismatch, expected channel but got string', 'E1217: Channel or Job required for argument 1']) endif enddef @@ -447,7 +447,7 @@ def Test_ch_close_in() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_close_in(true)'], ['E1013: Argument 1: type mismatch, expected channel but got bool', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_close_in(true)'], ['E1013: Argument 1: type mismatch, expected channel but got bool', 'E1217: Channel or Job required for argument 1']) endif enddef @@ -455,8 +455,8 @@ def Test_ch_evalexpr() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_evalexpr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_evalexpr(test_null_channel(), 1, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['ch_evalexpr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_evalexpr(test_null_channel(), 1, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) endif enddef @@ -464,9 +464,9 @@ def Test_ch_evalraw() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_evalraw(1, "")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_evalraw(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1221: String or Blob required for argument 2']) - CheckDefAndScriptFailure(['ch_evalraw(test_null_channel(), "", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['ch_evalraw(1, "")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_evalraw(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1221: String or Blob required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_evalraw(test_null_channel(), "", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) endif enddef @@ -474,8 +474,8 @@ def Test_ch_getbufnr() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_getbufnr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_getbufnr(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_getbufnr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_getbufnr(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) # test empty string argument for ch_getbufnr() var job: job = job_start(&shell) job->ch_getbufnr('')->assert_equal(-1) @@ -487,8 +487,8 @@ def Test_ch_getjob() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_getjob(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_getjob({"a": 10})'], ['E1013: Argument 1: type mismatch, expected channel but got dict', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_getjob(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_getjob({"a": 10})'], ['E1013: Argument 1: type mismatch, expected channel but got dict', 'E1217: Channel or Job required for argument 1']) assert_equal(0, ch_getjob(test_null_channel())) endif enddef @@ -497,7 +497,7 @@ def Test_ch_info() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_info([1])'], ['E1013: Argument 1: type mismatch, expected channel but got list', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_info([1])'], ['E1013: Argument 1: type mismatch, expected channel but got list', 'E1217: Channel or Job required for argument 1']) endif enddef @@ -505,8 +505,8 @@ def Test_ch_log() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_log(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['ch_log("a", 1)'], ['E1013: Argument 2: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_log(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_log("a", 1)'], ['E1013: Argument 2: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 2']) endif enddef @@ -518,8 +518,8 @@ def Test_ch_logfile() assert_fails('ch_logfile("foo", true)', 'E1174:') ch_logfile('', '')->assert_equal(0) - CheckDefAndScriptFailure(['ch_logfile(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['ch_logfile("a", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_logfile(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_logfile("a", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2']) endif enddef @@ -527,9 +527,9 @@ def Test_ch_open() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_open({"a": 10}, "a")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['ch_open("a", [1])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) - CheckDefExecAndScriptFailure(['ch_open("")'], 'E475: Invalid argument') + v9.CheckDefAndScriptFailure(['ch_open({"a": 10}, "a")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_open("a", [1])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefExecAndScriptFailure(['ch_open("")'], 'E475: Invalid argument') endif enddef @@ -537,8 +537,8 @@ def Test_ch_read() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_read(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_read(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_read(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_read(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) endif enddef @@ -546,8 +546,8 @@ def Test_ch_readblob() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_readblob(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_readblob(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_readblob(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_readblob(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) endif enddef @@ -555,8 +555,8 @@ def Test_ch_readraw() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_readraw(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_readraw(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_readraw(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_readraw(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) endif enddef @@ -564,8 +564,8 @@ def Test_ch_sendexpr() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_sendexpr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_sendexpr(test_null_channel(), 1, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['ch_sendexpr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_sendexpr(test_null_channel(), 1, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) endif enddef @@ -573,9 +573,9 @@ def Test_ch_sendraw() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_sendraw(1, "")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_sendraw(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1221: String or Blob required for argument 2']) - CheckDefAndScriptFailure(['ch_sendraw(test_null_channel(), "", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['ch_sendraw(1, "")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_sendraw(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1221: String or Blob required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_sendraw(test_null_channel(), "", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) endif enddef @@ -583,8 +583,8 @@ def Test_ch_setoptions() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_setoptions(1, {})'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_setoptions(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_setoptions(1, {})'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_setoptions(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) endif enddef @@ -592,8 +592,8 @@ def Test_ch_status() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['ch_status(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) - CheckDefAndScriptFailure(['ch_status(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['ch_status(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1']) + v9.CheckDefAndScriptFailure(['ch_status(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) endif enddef @@ -601,8 +601,8 @@ def Test_char2nr() char2nr('あ', true)->assert_equal(12354) assert_fails('char2nr(true)', 'E1174:') - CheckDefAndScriptFailure(['char2nr(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['char2nr("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['char2nr(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['char2nr("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) assert_equal(97, char2nr('a', 1)) assert_equal(97, char2nr('a', 0)) assert_equal(97, char2nr('a', true)) @@ -616,9 +616,9 @@ def Test_charclass() enddef def Test_charcol() - CheckDefAndScriptFailure(['charcol(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['charcol({a: 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) - CheckDefExecAndScriptFailure(['charcol("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['charcol(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['charcol({a: 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) + v9.CheckDefExecAndScriptFailure(['charcol("")'], 'E1209: Invalid value for a line number') new setline(1, ['abcdefgh']) cursor(1, 4) @@ -629,9 +629,9 @@ def Test_charcol() enddef def Test_charidx() - CheckDefAndScriptFailure(['charidx(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['charidx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['charidx("a", 1, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['charidx(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['charidx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['charidx("a", 1, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) charidx('', 0)->assert_equal(-1) charidx('', 1)->assert_equal(-1) enddef @@ -641,15 +641,15 @@ def Test_chdir() enddef def Test_cindent() - CheckDefAndScriptFailure(['cindent([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['cindent(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['cindent("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['cindent([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['cindent(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['cindent("")'], 'E1209: Invalid value for a line number') assert_equal(-1, cindent(0)) assert_equal(0, cindent('.')) enddef def Test_clearmatches() - CheckDefAndScriptFailure(['clearmatches("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['clearmatches("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_col() @@ -662,25 +662,25 @@ def Test_col() assert_fails('col(true)', 'E1222:') - CheckDefAndScriptFailure(['col(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['col({a: 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['col(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1222: String or List required for argument 1']) - CheckDefExecAndScriptFailure(['col("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['col(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['col({a: 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['col(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1222: String or List required for argument 1']) + v9.CheckDefExecAndScriptFailure(['col("")'], 'E1209: Invalid value for a line number') bw! enddef def Test_complete() - CheckDefAndScriptFailure(['complete("1", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['complete(1, {})'], ['E1013: Argument 2: type mismatch, expected list but got dict', 'E1211: List required for argument 2']) + v9.CheckDefAndScriptFailure(['complete("1", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['complete(1, {})'], ['E1013: Argument 2: type mismatch, expected list but got dict', 'E1211: List required for argument 2']) enddef def Test_complete_add() - CheckDefAndScriptFailure(['complete_add([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1223: String or Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['complete_add([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1223: String or Dictionary required for argument 1']) enddef def Test_complete_info() - CheckDefAndScriptFailure(['complete_info("")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['complete_info({})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['complete_info("")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['complete_info({})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) assert_equal({'pum_visible': 0, 'mode': '', 'selected': -1, 'items': []}, complete_info()) assert_equal({'mode': '', 'items': []}, complete_info(['mode', 'items'])) enddef @@ -693,10 +693,10 @@ def Test_confirm() assert_fails('confirm(true)', 'E1174:') assert_fails('confirm("yes", true)', 'E1174:') assert_fails('confirm("yes", "maybe", 2, true)', 'E1174:') - CheckDefAndScriptFailure(['confirm(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['confirm("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['confirm("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['confirm("a", "b", 3, 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']) + v9.CheckDefAndScriptFailure(['confirm(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['confirm("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['confirm("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['confirm("a", "b", 3, 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']) enddef def Test_copy_return_type() @@ -720,9 +720,9 @@ enddef def Test_count() count('ABC ABC ABC', 'b', true)->assert_equal(3) count('ABC ABC ABC', 'b', false)->assert_equal(0) - CheckDefAndScriptFailure(['count(10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1225: String, List or Dictionary required for argument 1']) - CheckDefAndScriptFailure(['count("a", [1], 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) - CheckDefAndScriptFailure(['count("a", [1], 0, "b")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['count(10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1225: String, List or Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['count("a", [1], 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['count("a", [1], 0, "b")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) count([1, 2, 2, 3], 2)->assert_equal(2) count([1, 2, 2, 3], 2, false, 2)->assert_equal(1) count({a: 1.1, b: 2.2, c: 1.1}, 1.1)->assert_equal(2) @@ -731,9 +731,9 @@ enddef def Test_cscope_connection() CheckFeature cscope assert_equal(0, cscope_connection()) - CheckDefAndScriptFailure(['cscope_connection("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['cscope_connection(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['cscope_connection(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['cscope_connection("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['cscope_connection(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['cscope_connection(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) enddef def Test_cursor() @@ -749,35 +749,35 @@ def Test_cursor() var lines =<< trim END cursor('2', 1) END - CheckDefExecAndScriptFailure(lines, 'E1209:') - CheckDefAndScriptFailure(['cursor(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected number but got blob', 'E1224: String, Number or List required for argument 1']) - CheckDefAndScriptFailure(['cursor(1, "2")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['cursor(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefExecAndScriptFailure(['cursor("", 2)'], 'E1209: Invalid value for a line number') + v9.CheckDefExecAndScriptFailure(lines, 'E1209:') + v9.CheckDefAndScriptFailure(['cursor(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected number but got blob', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['cursor(1, "2")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['cursor(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefExecAndScriptFailure(['cursor("", 2)'], 'E1209: Invalid value for a line number') enddef def Test_debugbreak() CheckMSWindows - CheckDefAndScriptFailure(['debugbreak("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['debugbreak("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_deepcopy() - CheckDefAndScriptFailure(['deepcopy({}, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['deepcopy({}, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) enddef def Test_delete() var res: bool = delete('doesnotexist') assert_equal(true, res) - CheckDefAndScriptFailure(['delete(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['delete("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefExecAndScriptFailure(['delete("")'], 'E474: Invalid argument') + v9.CheckDefAndScriptFailure(['delete(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['delete("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefExecAndScriptFailure(['delete("")'], 'E474: Invalid argument') enddef def Test_deletebufline() - CheckDefAndScriptFailure(['deletebufline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['deletebufline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) - CheckDefAndScriptFailure(['deletebufline("a", 2, 0z10)'], ['E1013: Argument 3: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 3']) + v9.CheckDefAndScriptFailure(['deletebufline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['deletebufline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['deletebufline("a", 2, 0z10)'], ['E1013: Argument 3: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 3']) new setline(1, ['one', 'two']) deletebufline('', 1) @@ -790,58 +790,58 @@ def Test_deletebufline() enddef def Test_diff_filler() - CheckDefAndScriptFailure(['diff_filler([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['diff_filler(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['diff_filler("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['diff_filler([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['diff_filler(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['diff_filler("")'], 'E1209: Invalid value for a line number') assert_equal(0, diff_filler(1)) assert_equal(0, diff_filler('.')) enddef def Test_diff_hlID() - CheckDefAndScriptFailure(['diff_hlID(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['diff_hlID(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefExecAndScriptFailure(['diff_hlID("", 10)'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['diff_hlID(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['diff_hlID(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefExecAndScriptFailure(['diff_hlID("", 10)'], 'E1209: Invalid value for a line number') enddef def Test_digraph_get() - CheckDefAndScriptFailure(['digraph_get(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefExecAndScriptFailure(['digraph_get("")'], 'E1214: Digraph must be just two characters') + v9.CheckDefAndScriptFailure(['digraph_get(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefExecAndScriptFailure(['digraph_get("")'], 'E1214: Digraph must be just two characters') enddef def Test_digraph_getlist() - CheckDefAndScriptFailure(['digraph_getlist(10)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) - CheckDefAndScriptFailure(['digraph_getlist("")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['digraph_getlist(10)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['digraph_getlist("")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) enddef def Test_digraph_set() - CheckDefAndScriptFailure(['digraph_set(10, "a")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['digraph_set("ab", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2']) - CheckDefExecAndScriptFailure(['digraph_set("", "a")'], 'E1214: Digraph must be just two characters') + v9.CheckDefAndScriptFailure(['digraph_set(10, "a")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['digraph_set("ab", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2']) + v9.CheckDefExecAndScriptFailure(['digraph_set("", "a")'], 'E1214: Digraph must be just two characters') enddef def Test_digraph_setlist() - CheckDefAndScriptFailure(['digraph_setlist("a")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1216: digraph_setlist() argument must be a list of lists with two items']) - CheckDefAndScriptFailure(['digraph_setlist({})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1216: digraph_setlist() argument must be a list of lists with two items']) + v9.CheckDefAndScriptFailure(['digraph_setlist("a")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1216: digraph_setlist() argument must be a list of lists with two items']) + v9.CheckDefAndScriptFailure(['digraph_setlist({})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1216: digraph_setlist() argument must be a list of lists with two items']) enddef def Test_echoraw() - CheckDefAndScriptFailure(['echoraw(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['echoraw(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['echoraw(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['echoraw(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_escape() - CheckDefAndScriptFailure(['escape(10, " ")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['escape(true, false)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['escape("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['escape(10, " ")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['escape(true, false)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['escape("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) assert_equal('a\:b', escape("a:b", ":")) escape('abc', '')->assert_equal('abc') escape('', ':')->assert_equal('') enddef def Test_eval() - CheckDefAndScriptFailure(['eval(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['eval(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1']) - CheckDefExecAndScriptFailure(['eval("")'], 'E15: Invalid expression') + v9.CheckDefAndScriptFailure(['eval(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['eval(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1']) + v9.CheckDefExecAndScriptFailure(['eval("")'], 'E15: Invalid expression') assert_equal(2, eval('1 + 1')) enddef @@ -849,8 +849,8 @@ def Test_executable() assert_false(executable("")) assert_false(executable(test_null_string())) - CheckDefExecFailure(['echo executable(123)'], 'E1013:') - CheckDefExecFailure(['echo executable(true)'], 'E1013:') + v9.CheckDefExecFailure(['echo executable(123)'], 'E1013:') + v9.CheckDefExecFailure(['echo executable(true)'], 'E1013:') enddef def Test_execute() @@ -859,22 +859,22 @@ def Test_execute() res = execute(["echo 'here'", "echo 'there'"]) assert_equal("\nhere\nthere", res) - CheckDefAndScriptFailure(['execute(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1']) - CheckDefFailure(['execute([123])'], 'E1013: Argument 1: type mismatch, expected list but got list') - CheckDefExecFailure(['echo execute(["xx", 123])'], 'E492') - CheckDefAndScriptFailure(['execute("xx", 123)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['execute(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1']) + v9.CheckDefFailure(['execute([123])'], 'E1013: Argument 1: type mismatch, expected list but got list') + v9.CheckDefExecFailure(['echo execute(["xx", 123])'], 'E492') + v9.CheckDefAndScriptFailure(['execute("xx", 123)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) enddef def Test_exepath() - CheckDefExecFailure(['echo exepath(true)'], 'E1013:') - CheckDefExecFailure(['echo exepath(v:null)'], 'E1013:') - CheckDefExecFailure(['echo exepath("")'], 'E1175:') + v9.CheckDefExecFailure(['echo exepath(true)'], 'E1013:') + v9.CheckDefExecFailure(['echo exepath(v:null)'], 'E1013:') + v9.CheckDefExecFailure(['echo exepath("")'], 'E1175:') enddef command DoSomeCommand let g:didSomeCommand = 4 def Test_exists() - CheckDefAndScriptFailure(['exists(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['exists(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) call assert_equal(1, exists('&tabstop')) var lines =<< trim END @@ -883,14 +883,14 @@ def Test_exists() endif endif END - CheckDefFailure(lines, 'E113:') - CheckScriptSuccess(lines) + v9.CheckDefFailure(lines, 'E113:') + v9.CheckScriptSuccess(lines) enddef def Test_exists_compiled() call assert_equal(1, exists_compiled('&tabstop')) - CheckDefAndScriptFailure(['exists_compiled(10)'], ['E1232:', 'E1233:']) - CheckDefAndScriptFailure(['exists_compiled(v:progname)'], ['E1232:', 'E1233:']) + v9.CheckDefAndScriptFailure(['exists_compiled(10)'], ['E1232:', 'E1233:']) + v9.CheckDefAndScriptFailure(['exists_compiled(v:progname)'], ['E1232:', 'E1233:']) if exists_compiled('+newoption') if &newoption == 'ok' @@ -920,10 +920,16 @@ def Test_exists_compiled() endif var found = false - if exists_compiled('*CheckScriptSuccess') + if exists_compiled('*CheckFeature') + found = true + endif + assert_false(found) + found = false + if exists_compiled('*g:CheckFeature') found = true endif assert_true(found) + if exists_compiled('*NoSuchFunction') NoSuchFunction() endif @@ -936,9 +942,9 @@ def Test_expand() split SomeFile expand('%', true, true)->assert_equal(['SomeFile']) close - CheckDefAndScriptFailure(['expand(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['expand("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) - CheckDefAndScriptFailure(['expand("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['expand(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['expand("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['expand("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) expand('')->assert_equal('') var caught = false @@ -957,7 +963,7 @@ def Test_expandcmd() assert_equal("yes", expandcmd("`={a: 'yes'}['a']`")) expandcmd('')->assert_equal('') - CheckDefAndScriptFailure(['expandcmd([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['expandcmd([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_extend_arg_types() @@ -984,7 +990,7 @@ def Test_extend_arg_types() dany->extend({b: 'x'}) assert_equal({a: 0, b: 'x'}, dany) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END assert_equal([1, 2, "x"], extend([1, 2], ["x"])) @@ -992,17 +998,17 @@ def Test_extend_arg_types() assert_equal({a: 1, b: "x"}, extend({a: 1}, {b: "x"})) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(['extend("a", 1)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E712: Argument of extend() must be a List or Dictionary']) - CheckDefAndScriptFailure(['extend([1, 2], 3)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E712: Argument of extend() must be a List or Dictionary']) - CheckDefAndScriptFailure(['var ll = [1, 2]', 'extend(ll, ["x"])'], ['E1013: Argument 2: type mismatch, expected list but got list', 'E1013: Argument 2: type mismatch, expected list but got list']) - CheckDefFailure(['extend([1, 2], [3], "x")'], 'E1013: Argument 3: type mismatch, expected number but got string') + v9.CheckDefAndScriptFailure(['extend("a", 1)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E712: Argument of extend() must be a List or Dictionary']) + v9.CheckDefAndScriptFailure(['extend([1, 2], 3)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E712: Argument of extend() must be a List or Dictionary']) + v9.CheckDefAndScriptFailure(['var ll = [1, 2]', 'extend(ll, ["x"])'], ['E1013: Argument 2: type mismatch, expected list but got list', 'E1013: Argument 2: type mismatch, expected list but got list']) + v9.CheckDefFailure(['extend([1, 2], [3], "x")'], 'E1013: Argument 3: type mismatch, expected number but got string') - CheckDefFailure(['extend({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict but got number') - CheckDefFailure(['extend({a: 1}, {b: 2}, 1)'], 'E1013: Argument 3: type mismatch, expected string but got number') + v9.CheckDefFailure(['extend({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict but got number') + v9.CheckDefFailure(['extend({a: 1}, {b: 2}, 1)'], 'E1013: Argument 3: type mismatch, expected string but got number') - CheckScriptFailure(['vim9script', 'var l = [1]', 'extend(l, ["b", 1])'], 'E1013: Argument 2: type mismatch, expected list but got list in extend()') + v9.CheckScriptFailure(['vim9script', 'var l = [1]', 'extend(l, ["b", 1])'], 'E1013: Argument 2: type mismatch, expected list but got list in extend()') enddef func g:ExtendDict(d) @@ -1014,26 +1020,26 @@ def Test_extend_dict_item_type() var d: dict = {a: 1} extend(d, {b: 2}) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var d: dict = {a: 1} extend(d, {b: 'x'}) END - CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict but got dict', 2) + v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict but got dict', 2) lines =<< trim END var d: dict = {a: 1} g:ExtendDict(d) END - CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0) - CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) + v9.CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0) + v9.CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) lines =<< trim END var d: dict extend(d, {b: 0}) END - CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict but got dict', 2) + v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict but got dict', 2) enddef func g:ExtendList(l) @@ -1045,26 +1051,26 @@ def Test_extend_list_item_type() var l: list = [1] extend(l, [2]) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var l: list = [1] extend(l, ['x']) END - CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list but got list', 2) + v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list but got list', 2) lines =<< trim END var l: list = [1] g:ExtendList(l) END - CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0) - CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) + v9.CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0) + v9.CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) lines =<< trim END var l: list extend(l, [0]) END - CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list but got list', 2) + v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list but got list', 2) enddef def Test_extend_return_type() @@ -1093,23 +1099,23 @@ def Test_extend_with_error_function() Test() END - CheckScriptFailure(lines, 'E1001: Variable not found: m') + v9.CheckScriptFailure(lines, 'E1001: Variable not found: m') enddef def Test_extendnew() assert_equal([1, 2, 'a'], extendnew([1, 2], ['a'])) assert_equal({one: 1, two: 'a'}, extendnew({one: 1}, {two: 'a'})) - CheckDefAndScriptFailure(['extendnew({a: 1}, 42)'], ['E1013: Argument 2: type mismatch, expected dict but got number', 'E712: Argument of extendnew() must be a List or Dictionary']) - CheckDefAndScriptFailure(['extendnew({a: 1}, [42])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E712: Argument of extendnew() must be a List or Dictionary']) - CheckDefAndScriptFailure(['extendnew([1, 2], "x")'], ['E1013: Argument 2: type mismatch, expected list but got string', 'E712: Argument of extendnew() must be a List or Dictionary']) - CheckDefAndScriptFailure(['extendnew([1, 2], {x: 1})'], ['E1013: Argument 2: type mismatch, expected list but got dict', 'E712: Argument of extendnew() must be a List or Dictionary']) + v9.CheckDefAndScriptFailure(['extendnew({a: 1}, 42)'], ['E1013: Argument 2: type mismatch, expected dict but got number', 'E712: Argument of extendnew() must be a List or Dictionary']) + v9.CheckDefAndScriptFailure(['extendnew({a: 1}, [42])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E712: Argument of extendnew() must be a List or Dictionary']) + v9.CheckDefAndScriptFailure(['extendnew([1, 2], "x")'], ['E1013: Argument 2: type mismatch, expected list but got string', 'E712: Argument of extendnew() must be a List or Dictionary']) + v9.CheckDefAndScriptFailure(['extendnew([1, 2], {x: 1})'], ['E1013: Argument 2: type mismatch, expected list but got dict', 'E712: Argument of extendnew() must be a List or Dictionary']) enddef def Test_feedkeys() - CheckDefAndScriptFailure(['feedkeys(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['feedkeys("x", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['feedkeys([], {})'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['feedkeys(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['feedkeys("x", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['feedkeys([], {})'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) g:TestVar = 1 feedkeys(":g:TestVar = 789\n", 'xt') assert_equal(789, g:TestVar) @@ -1120,16 +1126,16 @@ def Test_filereadable() assert_false(filereadable("")) assert_false(filereadable(test_null_string())) - CheckDefExecFailure(['echo filereadable(123)'], 'E1013:') - CheckDefExecFailure(['echo filereadable(true)'], 'E1013:') + v9.CheckDefExecFailure(['echo filereadable(123)'], 'E1013:') + v9.CheckDefExecFailure(['echo filereadable(true)'], 'E1013:') enddef def Test_filewritable() assert_false(filewritable("")) assert_false(filewritable(test_null_string())) - CheckDefExecFailure(['echo filewritable(123)'], 'E1013:') - CheckDefExecFailure(['echo filewritable(true)'], 'E1013:') + v9.CheckDefExecFailure(['echo filewritable(123)'], 'E1013:') + v9.CheckDefExecFailure(['echo filewritable(true)'], 'E1013:') enddef def Test_finddir() @@ -1138,20 +1144,20 @@ def Test_finddir() var lines =<< trim END var l: list = finddir('nothing', '*;', -1) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) delete('Xtestdir', 'rf') - CheckDefAndScriptFailure(['finddir(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['finddir(v:null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1']) - CheckDefExecFailure(['echo finddir("")'], 'E1175:') - CheckDefAndScriptFailure(['finddir("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['finddir("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['finddir(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['finddir(v:null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1']) + v9.CheckDefExecFailure(['echo finddir("")'], 'E1175:') + v9.CheckDefAndScriptFailure(['finddir("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['finddir("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) finddir('abc', '')->assert_equal('') - CheckDefFailure(['var s: list = finddir("foo")'], 'E1012: Type mismatch; expected list but got string') - CheckDefFailure(['var s: list = finddir("foo", "path")'], 'E1012: Type mismatch; expected list but got string') + v9.CheckDefFailure(['var s: list = finddir("foo")'], 'E1012: Type mismatch; expected list but got string') + v9.CheckDefFailure(['var s: list = finddir("foo", "path")'], 'E1012: Type mismatch; expected list but got string') # with third argument only runtime type checking - CheckDefCompileSuccess(['var s: list = finddir("foo", "path", 1)']) + v9.CheckDefCompileSuccess(['var s: list = finddir("foo", "path", 1)']) enddef def Test_findfile() @@ -1159,13 +1165,13 @@ def Test_findfile() var lines =<< trim END var l: list = findfile('nothing', '*;', -1) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefExecFailure(['findfile(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool') - CheckDefExecFailure(['findfile(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special') - CheckDefExecFailure(['findfile("")'], 'E1175:') - CheckDefAndScriptFailure(['findfile("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['findfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefExecFailure(['findfile(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool') + v9.CheckDefExecFailure(['findfile(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special') + v9.CheckDefExecFailure(['findfile("")'], 'E1175:') + v9.CheckDefAndScriptFailure(['findfile("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['findfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) findfile('abc', '')->assert_equal('') enddef @@ -1173,7 +1179,7 @@ def Test_flatten() var lines =<< trim END echo flatten([1, 2, 3]) END - CheckDefAndScriptFailure(lines, 'E1158:') + v9.CheckDefAndScriptFailure(lines, 'E1158:') enddef def Test_flattennew() @@ -1188,10 +1194,10 @@ def Test_flattennew() var ll: list> = [['a', 'b', 'c']] assert_equal(['a', 'b', 'c'], ll->flattennew()) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(['flattennew({})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['flattennew([], "1")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['flattennew({})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['flattennew([], "1")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef " Test for float functions argument type @@ -1199,74 +1205,74 @@ def Test_float_funcs_args() CheckFeature float # acos() - CheckDefAndScriptFailure(['acos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['acos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # asin() - CheckDefAndScriptFailure(['asin("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['asin("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # atan() - CheckDefAndScriptFailure(['atan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['atan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # atan2() - CheckDefAndScriptFailure(['atan2("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) - CheckDefAndScriptFailure(['atan2(1.2, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2']) - CheckDefAndScriptFailure(['atan2(1.2)'], ['E119:', 'E119:']) + v9.CheckDefAndScriptFailure(['atan2("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['atan2(1.2, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['atan2(1.2)'], ['E119:', 'E119:']) # ceil() - CheckDefAndScriptFailure(['ceil("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['ceil("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # cos() - CheckDefAndScriptFailure(['cos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['cos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # cosh() - CheckDefAndScriptFailure(['cosh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['cosh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # exp() - CheckDefAndScriptFailure(['exp("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['exp("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # float2nr() - CheckDefAndScriptFailure(['float2nr("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['float2nr("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # floor() - CheckDefAndScriptFailure(['floor("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['floor("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # fmod() - CheckDefAndScriptFailure(['fmod(1.1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2']) - CheckDefAndScriptFailure(['fmod("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) - CheckDefAndScriptFailure(['fmod(1.1)'], ['E119:', 'E119:']) + v9.CheckDefAndScriptFailure(['fmod(1.1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['fmod("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['fmod(1.1)'], ['E119:', 'E119:']) # isinf() - CheckDefAndScriptFailure(['isinf("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['isinf("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # isnan() - CheckDefAndScriptFailure(['isnan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['isnan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # log() - CheckDefAndScriptFailure(['log("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['log("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # log10() - CheckDefAndScriptFailure(['log10("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['log10("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # pow() - CheckDefAndScriptFailure(['pow("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) - CheckDefAndScriptFailure(['pow(1.1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2']) - CheckDefAndScriptFailure(['pow(1.1)'], ['E119:', 'E119:']) + v9.CheckDefAndScriptFailure(['pow("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['pow(1.1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['pow(1.1)'], ['E119:', 'E119:']) # round() - CheckDefAndScriptFailure(['round("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['round("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # sin() - CheckDefAndScriptFailure(['sin("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['sin("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # sinh() - CheckDefAndScriptFailure(['sinh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['sinh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # sqrt() - CheckDefAndScriptFailure(['sqrt("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['sqrt("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # tan() - CheckDefAndScriptFailure(['tan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['tan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # tanh() - CheckDefAndScriptFailure(['tanh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['tanh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) # trunc() - CheckDefAndScriptFailure(['trunc("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['trunc("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1']) enddef def Test_fnameescape() - CheckDefAndScriptFailure(['fnameescape(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['fnameescape(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal('\+a\%b\|', fnameescape('+a%b|')) fnameescape('')->assert_equal('') enddef def Test_fnamemodify() - CheckDefSuccess(['echo fnamemodify(test_null_string(), ":p")']) - CheckDefSuccess(['echo fnamemodify("", ":p")']) - CheckDefSuccess(['echo fnamemodify("file", test_null_string())']) - CheckDefSuccess(['echo fnamemodify("file", "")']) + v9.CheckDefSuccess(['echo fnamemodify(test_null_string(), ":p")']) + v9.CheckDefSuccess(['echo fnamemodify("", ":p")']) + v9.CheckDefSuccess(['echo fnamemodify("file", test_null_string())']) + v9.CheckDefSuccess(['echo fnamemodify("file", "")']) - CheckDefExecFailure(['echo fnamemodify(true, ":p")'], 'E1013: Argument 1: type mismatch, expected string but got bool') - CheckDefExecFailure(['echo fnamemodify(v:null, ":p")'], 'E1013: Argument 1: type mismatch, expected string but got special') - CheckDefExecFailure(['echo fnamemodify("file", true)'], 'E1013: Argument 2: type mismatch, expected string but got bool') + v9.CheckDefExecFailure(['echo fnamemodify(true, ":p")'], 'E1013: Argument 1: type mismatch, expected string but got bool') + v9.CheckDefExecFailure(['echo fnamemodify(v:null, ":p")'], 'E1013: Argument 1: type mismatch, expected string but got special') + v9.CheckDefExecFailure(['echo fnamemodify("file", true)'], 'E1013: Argument 2: type mismatch, expected string but got bool') enddef def Wrong_dict_key_type(items: list): list @@ -1274,8 +1280,8 @@ def Wrong_dict_key_type(items: list): list enddef def Test_filter() - CheckDefAndScriptFailure(['filter(1.1, "1")'], ['E1013: Argument 1: type mismatch, expected list but got float', 'E1251: List, Dictionary, Blob or String required for argument 1']) - CheckDefAndScriptFailure(['filter([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String']) + v9.CheckDefAndScriptFailure(['filter(1.1, "1")'], ['E1013: Argument 1: type mismatch, expected list but got float', 'E1251: List, Dictionary, Blob or String required for argument 1']) + v9.CheckDefAndScriptFailure(['filter([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String']) var lines =<< trim END def F(i: number, v: any): string @@ -1283,7 +1289,7 @@ def Test_filter() enddef echo filter([1, 2, 3], F) END - CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): bool', 'E1135: Using a String as a Bool:']) + v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): bool', 'E1135: Using a String as a Bool:']) assert_equal([], filter([1, 2, 3], '0')) assert_equal([1, 2, 3], filter([1, 2, 3], '1')) @@ -1316,29 +1322,29 @@ def Test_filter_missing_argument() enddef def Test_foldclosed() - CheckDefAndScriptFailure(['foldclosed(function("min"))'], ['E1013: Argument 1: type mismatch, expected string but got func(...): unknown', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['foldclosed("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['foldclosed(function("min"))'], ['E1013: Argument 1: type mismatch, expected string but got func(...): unknown', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['foldclosed("")'], 'E1209: Invalid value for a line number') assert_equal(-1, foldclosed(1)) assert_equal(-1, foldclosed('$')) enddef def Test_foldclosedend() - CheckDefAndScriptFailure(['foldclosedend(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['foldclosedend("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['foldclosedend(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['foldclosedend("")'], 'E1209: Invalid value for a line number') assert_equal(-1, foldclosedend(1)) assert_equal(-1, foldclosedend('w0')) enddef def Test_foldlevel() - CheckDefAndScriptFailure(['foldlevel(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['foldlevel("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['foldlevel(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['foldlevel("")'], 'E1209: Invalid value for a line number') assert_equal(0, foldlevel(1)) assert_equal(0, foldlevel('.')) enddef def Test_foldtextresult() - CheckDefAndScriptFailure(['foldtextresult(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['foldtextresult("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['foldtextresult(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['foldtextresult("")'], 'E1209: Invalid value for a line number') assert_equal('', foldtextresult(1)) assert_equal('', foldtextresult('.')) enddef @@ -1368,8 +1374,8 @@ def Test_fullcommand() enddef def Test_funcref() - CheckDefAndScriptFailure(['funcref("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) - CheckDefAndScriptFailure(['funcref("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['funcref("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) + v9.CheckDefAndScriptFailure(['funcref("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) var lines =<< trim END vim9script @@ -1386,7 +1392,7 @@ def Test_funcref() defcompile GetRefOk() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1398,14 +1404,14 @@ def Test_funcref() enddef GetRefBad() END - CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(bool)') + v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(bool)') enddef def Test_function() - CheckDefExecAndScriptFailure(['function(123)'], 'E1256: String or function required for argument 1') + v9.CheckDefExecAndScriptFailure(['function(123)'], 'E1256: String or function required for argument 1') - CheckDefAndScriptFailure(['function("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) - CheckDefAndScriptFailure(['function("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['function("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) + v9.CheckDefAndScriptFailure(['function("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) var lines =<< trim END vim9script @@ -1422,7 +1428,7 @@ def Test_function() defcompile GetRefOk() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1434,17 +1440,17 @@ def Test_function() enddef GetRefBad() END - CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(bool)') + v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(bool)') enddef def Test_garbagecollect() garbagecollect(true) - CheckDefAndScriptFailure(['garbagecollect("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) - CheckDefAndScriptFailure(['garbagecollect(20)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['garbagecollect("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['garbagecollect(20)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) enddef def Test_get() - CheckDefAndScriptFailure(['get("a", 1)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E896: Argument of get() must be a List, Dictionary or Blob']) + v9.CheckDefAndScriptFailure(['get("a", 1)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E896: Argument of get() must be a List, Dictionary or Blob']) [3, 5, 2]->get(1)->assert_equal(5) [3, 5, 2]->get(3)->assert_equal(0) [3, 5, 2]->get(3, 9)->assert_equal(9) @@ -1464,7 +1470,7 @@ def Test_get() enddef assert_equal(0, DoThat()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_getbufinfo() @@ -1477,7 +1483,7 @@ def Test_getbufinfo() getbufinfo({bufloaded: true, buflisted: true, bufmodified: false}) ->len()->assert_equal(3) bwipe Xtestfile1 Xtestfile2 - CheckDefAndScriptFailure(['getbufinfo(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['getbufinfo(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) enddef def Test_getbufline() @@ -1494,14 +1500,14 @@ def Test_getbufline() assert_fails('getbufline("", "$", "$b")', ['E1030: Using a String as a Number: "$b"', 'E1030: Using a String as a Number: "$b"']) bwipe! - CheckDefAndScriptFailure(['getbufline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['getbufline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) - CheckDefAndScriptFailure(['getbufline("a", 2, 0z10)'], ['E1013: Argument 3: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 3']) + v9.CheckDefAndScriptFailure(['getbufline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getbufline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['getbufline("a", 2, 0z10)'], ['E1013: Argument 3: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 3']) enddef def Test_getbufvar() - CheckDefAndScriptFailure(['getbufvar(true, "v")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['getbufvar(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['getbufvar(true, "v")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getbufvar(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) enddef def Test_getchangelist() @@ -1517,19 +1523,19 @@ def Test_getchar() endwhile getchar(true)->assert_equal(0) getchar(1)->assert_equal(0) - CheckDefAndScriptFailure(['getchar(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) - CheckDefAndScriptFailure(['getchar("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['getchar(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['getchar("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) enddef def Test_getcharpos() - CheckDefAndScriptFailure(['getcharpos(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['getcharpos(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefExecAndScriptFailure(['getcharpos("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['getcharpos(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['getcharpos(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefExecAndScriptFailure(['getcharpos("")'], 'E1209: Invalid value for a line number') enddef def Test_getcharstr() - CheckDefAndScriptFailure(['getcharstr(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) - CheckDefAndScriptFailure(['getcharstr("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['getcharstr(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['getcharstr("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) enddef def Test_getcompletion() @@ -1537,25 +1543,25 @@ def Test_getcompletion() var l = getcompletion('run', 'file', true) l->assert_equal([]) set wildignore& - CheckDefAndScriptFailure(['getcompletion(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['getcompletion("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['getcompletion("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) - CheckDefExecAndScriptFailure(['getcompletion("a", "")'], 'E475: Invalid argument') + v9.CheckDefAndScriptFailure(['getcompletion(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['getcompletion("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['getcompletion("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefExecAndScriptFailure(['getcompletion("a", "")'], 'E475: Invalid argument') getcompletion('', 'messages')->assert_equal(['clear']) enddef def Test_getcurpos() - CheckDefAndScriptFailure(['getcurpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getcurpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_getcursorcharpos() - CheckDefAndScriptFailure(['getcursorcharpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getcursorcharpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_getcwd() - CheckDefAndScriptFailure(['getcwd("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['getcwd("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['getcwd(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['getcwd("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getcwd("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getcwd(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_getenv() @@ -1573,7 +1579,7 @@ def Test_getenv() enddef def Test_getfontname() - CheckDefAndScriptFailure(['getfontname(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['getfontname(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) #getfontname('')->assert_equal('') enddef @@ -1581,38 +1587,38 @@ def Test_getfperm() assert_equal('', getfperm("")) assert_equal('', getfperm(test_null_string())) - CheckDefExecFailure(['echo getfperm(true)'], 'E1013:') - CheckDefExecFailure(['echo getfperm(v:null)'], 'E1013:') + v9.CheckDefExecFailure(['echo getfperm(true)'], 'E1013:') + v9.CheckDefExecFailure(['echo getfperm(v:null)'], 'E1013:') enddef def Test_getfsize() assert_equal(-1, getfsize("")) assert_equal(-1, getfsize(test_null_string())) - CheckDefExecFailure(['echo getfsize(true)'], 'E1013:') - CheckDefExecFailure(['echo getfsize(v:null)'], 'E1013:') + v9.CheckDefExecFailure(['echo getfsize(true)'], 'E1013:') + v9.CheckDefExecFailure(['echo getfsize(v:null)'], 'E1013:') enddef def Test_getftime() assert_equal(-1, getftime("")) assert_equal(-1, getftime(test_null_string())) - CheckDefExecFailure(['echo getftime(true)'], 'E1013:') - CheckDefExecFailure(['echo getftime(v:null)'], 'E1013:') + v9.CheckDefExecFailure(['echo getftime(true)'], 'E1013:') + v9.CheckDefExecFailure(['echo getftime(v:null)'], 'E1013:') enddef def Test_getftype() assert_equal('', getftype("")) assert_equal('', getftype(test_null_string())) - CheckDefExecFailure(['echo getftype(true)'], 'E1013:') - CheckDefExecFailure(['echo getftype(v:null)'], 'E1013:') + v9.CheckDefExecFailure(['echo getftype(true)'], 'E1013:') + v9.CheckDefExecFailure(['echo getftype(v:null)'], 'E1013:') enddef def Test_getjumplist() - CheckDefAndScriptFailure(['getjumplist("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['getjumplist("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['getjumplist(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['getjumplist("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getjumplist("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getjumplist(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_getline() @@ -1626,20 +1632,20 @@ def Test_getline() assert_equal('there', getline("'<")) assert_equal('again', getline("'>")) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END echo getline('1') END - CheckDefExecAndScriptFailure(lines, 'E1209:') - CheckDefAndScriptFailure(['getline(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['getline(1, true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2']) - CheckDefExecAndScriptFailure(['getline("")'], 'E1209: Invalid value for a line number') + v9.CheckDefExecAndScriptFailure(lines, 'E1209:') + v9.CheckDefAndScriptFailure(['getline(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getline(1, true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2']) + v9.CheckDefExecAndScriptFailure(['getline("")'], 'E1209: Invalid value for a line number') enddef def Test_getloclist() - CheckDefAndScriptFailure(['getloclist("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['getloclist(1, [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['getloclist("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getloclist(1, [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_getloclist_return_type() @@ -1651,24 +1657,24 @@ def Test_getloclist_return_type() enddef def Test_getmarklist() - CheckDefAndScriptFailure(['getmarklist([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getmarklist([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) assert_equal([], getmarklist(10000)) assert_fails('getmarklist("a%b@#")', 'E94:') enddef def Test_getmatches() - CheckDefAndScriptFailure(['getmatches("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getmatches("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_getpos() - CheckDefAndScriptFailure(['getpos(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['getpos(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal([0, 1, 1, 0], getpos('.')) - CheckDefExecFailure(['getpos("a")'], 'E1209:') - CheckDefExecAndScriptFailure(['getpos("")'], 'E1209: Invalid value for a line number') + v9.CheckDefExecFailure(['getpos("a")'], 'E1209:') + v9.CheckDefExecAndScriptFailure(['getpos("")'], 'E1209: Invalid value for a line number') enddef def Test_getqflist() - CheckDefAndScriptFailure(['getqflist([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['getqflist([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) call assert_equal({}, getqflist({})) enddef @@ -1685,9 +1691,9 @@ def Test_getreg() setreg('a', lines) getreg('a', true, true)->assert_equal(lines) assert_fails('getreg("ab")', 'E1162:') - CheckDefAndScriptFailure(['getreg(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['getreg(".", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) - CheckDefAndScriptFailure(['getreg(".", 1, "b")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['getreg(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['getreg(".", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['getreg(".", 1, "b")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) @" = 'A1B2C3' getreg('')->assert_equal('A1B2C3') enddef @@ -1717,72 +1723,72 @@ def Test_getregtype() enddef def Test_gettabinfo() - CheckDefAndScriptFailure(['gettabinfo("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['gettabinfo("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_gettabvar() - CheckDefAndScriptFailure(['gettabvar("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['gettabvar(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['gettabvar("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['gettabvar(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) enddef def Test_gettabwinvar() - CheckDefAndScriptFailure(['gettabwinvar("a", 2, "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['gettabwinvar(1, "b", "c", [])'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['gettabwinvar(1, 1, 3, {})'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['gettabwinvar("a", 2, "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['gettabwinvar(1, "b", "c", [])'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['gettabwinvar(1, 1, 3, {})'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) enddef def Test_gettagstack() - CheckDefAndScriptFailure(['gettagstack("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['gettagstack("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_gettext() - CheckDefAndScriptFailure(['gettext(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefExecAndScriptFailure(['gettext("")'], 'E475: Invalid argument') + v9.CheckDefAndScriptFailure(['gettext(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefExecAndScriptFailure(['gettext("")'], 'E475: Invalid argument') assert_equal('abc', gettext("abc")) assert_fails('gettext("")', 'E475:') enddef def Test_getwininfo() - CheckDefAndScriptFailure(['getwininfo("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getwininfo("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_getwinpos() - CheckDefAndScriptFailure(['getwinpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getwinpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_getwinvar() - CheckDefAndScriptFailure(['getwinvar("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['getwinvar(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['getwinvar("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['getwinvar(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) enddef def Test_glob() glob('runtest.vim', true, true, true)->assert_equal(['runtest.vim']) - CheckDefAndScriptFailure(['glob(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['glob("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) - CheckDefAndScriptFailure(['glob("a", 1, "b")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) - CheckDefAndScriptFailure(['glob("a", 1, true, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) + v9.CheckDefAndScriptFailure(['glob(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['glob("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['glob("a", 1, "b")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['glob("a", 1, true, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) glob('')->assert_equal('') enddef def Test_glob2regpat() - CheckDefAndScriptFailure(['glob2regpat(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['glob2regpat(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1']) glob2regpat('')->assert_equal('^$') enddef def Test_globpath() globpath('.', 'runtest.vim', true, true, true)->assert_equal(['./runtest.vim']) - CheckDefAndScriptFailure(['globpath(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['globpath("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['globpath("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) - CheckDefAndScriptFailure(['globpath("a", "b", true, "d")'], ['E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4']) - CheckDefAndScriptFailure(['globpath("a", "b", true, false, "e")'], ['E1013: Argument 5: type mismatch, expected bool but got string', 'E1212: Bool required for argument 5']) + v9.CheckDefAndScriptFailure(['globpath(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['globpath("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['globpath("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['globpath("a", "b", true, "d")'], ['E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4']) + v9.CheckDefAndScriptFailure(['globpath("a", "b", true, false, "e")'], ['E1013: Argument 5: type mismatch, expected bool but got string', 'E1212: Bool required for argument 5']) globpath('', '')->assert_equal('') enddef def Test_has() has('eval', true)->assert_equal(1) - CheckDefAndScriptFailure(['has(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['has("a", "b")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['has(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['has("a", "b")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2']) has('')->assert_equal(0) enddef @@ -1793,14 +1799,14 @@ def Test_has_key() assert_false(has_key(d, 'x')) assert_false(has_key(d, 99)) - CheckDefAndScriptFailure(['has_key([1, 2], "k")'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) - CheckDefAndScriptFailure(['has_key({"a": 10}, ["a"])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['has_key([1, 2], "k")'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['has_key({"a": 10}, ["a"])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) enddef def Test_haslocaldir() - CheckDefAndScriptFailure(['haslocaldir("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['haslocaldir("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['haslocaldir(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['haslocaldir("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['haslocaldir("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['haslocaldir(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_hasmapto() @@ -1808,109 +1814,109 @@ def Test_hasmapto() iabbrev foo foobar hasmapto('foobar', 'i', true)->assert_equal(1) iunabbrev foo - CheckDefAndScriptFailure(['hasmapto(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['hasmapto("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['hasmapto("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['hasmapto(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['hasmapto("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['hasmapto("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) hasmapto('', '')->assert_equal(0) enddef def Test_histadd() - CheckDefAndScriptFailure(['histadd(1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['histadd(":", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['histadd(1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['histadd(":", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) histadd("search", 'skyblue') assert_equal('skyblue', histget('/', -1)) histadd("search", '')->assert_equal(0) enddef def Test_histdel() - CheckDefAndScriptFailure(['histdel(1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['histdel(":", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['histdel(1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['histdel(":", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2']) histdel('search', '')->assert_equal(0) enddef def Test_histget() - CheckDefAndScriptFailure(['histget(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['histget("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['histget(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['histget("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_histnr() - CheckDefAndScriptFailure(['histnr(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['histnr(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal(-1, histnr('abc')) enddef def Test_hlID() - CheckDefAndScriptFailure(['hlID(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['hlID(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal(0, hlID('NonExistingHighlight')) hlID('')->assert_equal(0) enddef def Test_hlexists() - CheckDefAndScriptFailure(['hlexists([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['hlexists([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) assert_equal(0, hlexists('NonExistingHighlight')) hlexists('')->assert_equal(0) enddef def Test_hlget() - CheckDefAndScriptFailure(['hlget([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['hlget([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) hlget('')->assert_equal([]) enddef def Test_hlset() - CheckDefAndScriptFailure(['hlset("id")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['hlset("id")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) hlset([])->assert_equal(0) enddef def Test_iconv() - CheckDefAndScriptFailure(['iconv(1, "from", "to")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['iconv("abc", 10, "to")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['iconv("abc", "from", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['iconv(1, "from", "to")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['iconv("abc", 10, "to")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['iconv("abc", "from", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) assert_equal('abc', iconv('abc', 'fromenc', 'toenc')) iconv('', '', '')->assert_equal('') enddef def Test_indent() - CheckDefAndScriptFailure(['indent([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['indent(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['indent("")'], 'E1209: Invalid value for a line number') - CheckDefExecAndScriptFailure(['indent(-1)'], 'E966: Invalid line number: -1') + v9.CheckDefAndScriptFailure(['indent([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['indent(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['indent("")'], 'E1209: Invalid value for a line number') + v9.CheckDefExecAndScriptFailure(['indent(-1)'], 'E966: Invalid line number: -1') assert_equal(0, indent(1)) enddef def Test_index() index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3) - CheckDefAndScriptFailure(['index("a", "a")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1226: List or Blob required for argument 1']) - CheckDefFailure(['index(["1"], 1)'], 'E1013: Argument 2: type mismatch, expected string but got number') - CheckDefAndScriptFailure(['index(0z10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['index([1], 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['index(0z1020, 10, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) + v9.CheckDefAndScriptFailure(['index("a", "a")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1226: List or Blob required for argument 1']) + v9.CheckDefFailure(['index(["1"], 1)'], 'E1013: Argument 2: type mismatch, expected string but got number') + v9.CheckDefAndScriptFailure(['index(0z10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['index([1], 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['index(0z1020, 10, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) enddef def Test_input() - CheckDefAndScriptFailure(['input(5)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['input(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['input("p", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['input("p", "q", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['input(5)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['input(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['input("p", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['input("p", "q", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) enddef def Test_inputdialog() - CheckDefAndScriptFailure(['inputdialog(5)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['inputdialog(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['inputdialog("p", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['inputdialog("p", "q", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['inputdialog(5)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['inputdialog(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['inputdialog("p", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['inputdialog("p", "q", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) enddef def Test_inputlist() - CheckDefAndScriptFailure(['inputlist(10)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['inputlist("abc")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefFailure(['inputlist([1, 2, 3])'], 'E1013: Argument 1: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['inputlist(10)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['inputlist("abc")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefFailure(['inputlist([1, 2, 3])'], 'E1013: Argument 1: type mismatch, expected list but got list') feedkeys("2\", 't') var r: number = inputlist(['a', 'b', 'c']) assert_equal(2, r) enddef def Test_inputsecret() - CheckDefAndScriptFailure(['inputsecret(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['inputsecret("Pass:", 20)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['inputsecret(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['inputsecret("Pass:", 20)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) feedkeys("\", 't') var ans: string = inputsecret('Pass:', '123') assert_equal('123', ans) @@ -1937,12 +1943,12 @@ def Test_insert() var lines =<< trim END insert(test_null_list(), 123) END - CheckDefExecAndScriptFailure(lines, 'E1130:', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E1130:', 1) lines =<< trim END insert(test_null_blob(), 123) END - CheckDefExecAndScriptFailure(lines, 'E1131:', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E1131:', 1) assert_equal([1, 2, 3], insert([2, 3], 1)) assert_equal([1, 2, 3], insert([2, 3], s:number_one)) @@ -1951,24 +1957,24 @@ def Test_insert() assert_equal(['a', 'b', 'c'], insert(['b', 'c'], 'a')) assert_equal(0z1234, insert(0z34, 0x12)) - CheckDefAndScriptFailure(['insert("a", 1)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1226: List or Blob required for argument 1']) - CheckDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string') - CheckDefAndScriptFailure(['insert([2, 3], 1, "x")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['insert("a", 1)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1226: List or Blob required for argument 1']) + v9.CheckDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string') + v9.CheckDefAndScriptFailure(['insert([2, 3], 1, "x")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) enddef def Test_invert() - CheckDefAndScriptFailure(['invert("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['invert("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_isdirectory() - CheckDefAndScriptFailure(['isdirectory(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['isdirectory(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) assert_false(isdirectory('NonExistingDir')) assert_false(isdirectory('')) enddef def Test_islocked() - CheckDefAndScriptFailure(['islocked(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['var n1: number = 10', 'islocked(n1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['islocked(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['var n1: number = 10', 'islocked(n1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) g:v1 = 10 assert_false(islocked('g:v1')) lockvar g:v1 @@ -1978,7 +1984,7 @@ def Test_islocked() enddef def Test_items() - CheckDefFailure(['[]->items()'], 'E1013: Argument 1: type mismatch, expected dict but got list') + v9.CheckDefFailure(['[]->items()'], 'E1013: Argument 1: type mismatch, expected dict but got list') assert_equal([['a', 10], ['b', 20]], {'a': 10, 'b': 20}->items()) assert_equal([], {}->items()) enddef @@ -1987,7 +1993,7 @@ def Test_job_getchannel() if !has('job') CheckFeature job else - CheckDefAndScriptFailure(['job_getchannel("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1']) + v9.CheckDefAndScriptFailure(['job_getchannel("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1']) assert_fails('job_getchannel(test_null_job())', 'E916: not a valid job') endif enddef @@ -1996,7 +2002,7 @@ def Test_job_info() if !has('job') CheckFeature job else - CheckDefAndScriptFailure(['job_info("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1']) + v9.CheckDefAndScriptFailure(['job_info("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1']) assert_fails('job_info(test_null_job())', 'E916: not a valid job') endif enddef @@ -2007,8 +2013,8 @@ def Test_job_setoptions() if !has('job') CheckFeature job else - CheckDefAndScriptFailure(['job_setoptions(test_null_channel(), {})'], ['E1013: Argument 1: type mismatch, expected job but got channel', 'E1218: Job required for argument 1']) - CheckDefAndScriptFailure(['job_setoptions(test_null_job(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['job_setoptions(test_null_channel(), {})'], ['E1013: Argument 1: type mismatch, expected job but got channel', 'E1218: Job required for argument 1']) + v9.CheckDefAndScriptFailure(['job_setoptions(test_null_job(), [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) assert_equal('fail', job_status(test_null_job())) endif enddef @@ -2017,7 +2023,7 @@ def Test_job_status() if !has('job') CheckFeature job else - CheckDefAndScriptFailure(['job_status("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1']) + v9.CheckDefAndScriptFailure(['job_status("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1']) assert_equal('fail', job_status(test_null_job())) endif enddef @@ -2026,31 +2032,31 @@ def Test_job_stop() if !has('job') CheckFeature job else - CheckDefAndScriptFailure(['job_stop("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1']) - CheckDefAndScriptFailure(['job_stop(test_null_job(), true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['job_stop("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1']) + v9.CheckDefAndScriptFailure(['job_stop(test_null_job(), true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2']) endif enddef def Test_join() - CheckDefAndScriptFailure(['join("abc")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['join([], 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['join("abc")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['join([], 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) join([''], '')->assert_equal('') enddef def Test_js_decode() - CheckDefAndScriptFailure(['js_decode(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['js_decode(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal([1, 2], js_decode('[1,2]')) js_decode('')->assert_equal(v:none) enddef def Test_json_decode() - CheckDefAndScriptFailure(['json_decode(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['json_decode(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1']) assert_equal(1.0, json_decode('1.0')) json_decode('')->assert_equal(v:none) enddef def Test_keys() - CheckDefAndScriptFailure(['keys([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['keys([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) assert_equal(['a'], {a: 'v'}->keys()) assert_equal([], {}->keys()) enddef @@ -2061,7 +2067,7 @@ def Test_keys_return_type() enddef def Test_len() - CheckDefAndScriptFailure(['len(true)'], ['E1013: Argument 1: type mismatch, expected list but got bool', 'E701: Invalid type for len()']) + v9.CheckDefAndScriptFailure(['len(true)'], ['E1013: Argument 1: type mismatch, expected list but got bool', 'E701: Invalid type for len()']) assert_equal(2, "ab"->len()) assert_equal(3, 456->len()) assert_equal(0, []->len()) @@ -2071,42 +2077,42 @@ enddef def Test_libcall() CheckFeature libcall - CheckDefAndScriptFailure(['libcall(1, "b", 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['libcall("a", 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['libcall("a", "b", 1.1)'], ['E1013: Argument 3: type mismatch, expected string but got float', 'E1220: String or Number required for argument 3']) + v9.CheckDefAndScriptFailure(['libcall(1, "b", 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['libcall("a", 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['libcall("a", "b", 1.1)'], ['E1013: Argument 3: type mismatch, expected string but got float', 'E1220: String or Number required for argument 3']) enddef def Test_libcallnr() CheckFeature libcall - CheckDefAndScriptFailure(['libcallnr(1, "b", 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['libcallnr("a", 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['libcallnr("a", "b", 1.1)'], ['E1013: Argument 3: type mismatch, expected string but got float', 'E1220: String or Number required for argument 3']) + v9.CheckDefAndScriptFailure(['libcallnr(1, "b", 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['libcallnr("a", 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['libcallnr("a", "b", 1.1)'], ['E1013: Argument 3: type mismatch, expected string but got float', 'E1220: String or Number required for argument 3']) enddef def Test_line() assert_fails('line(true)', 'E1174:') - CheckDefAndScriptFailure(['line(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['line(".", "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefExecAndScriptFailure(['line("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['line(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['line(".", "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefExecAndScriptFailure(['line("")'], 'E1209: Invalid value for a line number') enddef def Test_line2byte() - CheckDefAndScriptFailure(['line2byte(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['line2byte("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['line2byte(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['line2byte("")'], 'E1209: Invalid value for a line number') assert_equal(-1, line2byte(1)) assert_equal(-1, line2byte(10000)) enddef def Test_lispindent() - CheckDefAndScriptFailure(['lispindent({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['lispindent("")'], 'E1209: Invalid value for a line number') - CheckDefExecAndScriptFailure(['lispindent(-1)'], 'E966: Invalid line number: -1') + v9.CheckDefAndScriptFailure(['lispindent({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['lispindent("")'], 'E1209: Invalid value for a line number') + v9.CheckDefExecAndScriptFailure(['lispindent(-1)'], 'E966: Invalid line number: -1') assert_equal(0, lispindent(1)) enddef def Test_list2blob() - CheckDefAndScriptFailure(['list2blob(10)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) - CheckDefFailure(['list2blob([0z10, 0z02])'], 'E1013: Argument 1: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['list2blob(10)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) + v9.CheckDefFailure(['list2blob([0z10, 0z02])'], 'E1013: Argument 1: type mismatch, expected list but got list') enddef def Test_list2str_str2list_utf8() @@ -2117,33 +2123,33 @@ def Test_list2str_str2list_utf8() enddef def Test_list2str() - CheckDefAndScriptFailure(['list2str(".", true)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['list2str([1], 0z10)'], ['E1013: Argument 2: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['list2str(".", true)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['list2str([1], 0z10)'], ['E1013: Argument 2: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 2']) enddef -def SID(): number +def s:SID(): number return expand('') ->matchstr('\zs\d\+\ze_$') ->str2nr() enddef def Test_listener_add() - CheckDefAndScriptFailure(['listener_add("1", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['listener_add("1", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2']) enddef def Test_listener_flush() - CheckDefAndScriptFailure(['listener_flush([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['listener_flush([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) enddef def Test_listener_remove() - CheckDefAndScriptFailure(['listener_remove("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['listener_remove("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_luaeval() if !has('lua') CheckFeature lua endif - CheckDefAndScriptFailure(['luaeval(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['luaeval(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) if exists_compiled('*luaeval') luaeval('')->assert_equal(v:null) endif @@ -2151,10 +2157,10 @@ enddef def Test_map() if has('channel') - CheckDefAndScriptFailure(['map(test_null_channel(), "1")'], ['E1013: Argument 1: type mismatch, expected list but got channel', 'E1251: List, Dictionary, Blob or String required for argument 1']) + v9.CheckDefAndScriptFailure(['map(test_null_channel(), "1")'], ['E1013: Argument 1: type mismatch, expected list but got channel', 'E1251: List, Dictionary, Blob or String required for argument 1']) endif - CheckDefAndScriptFailure(['map(1, "1")'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1251: List, Dictionary, Blob or String required for argument 1']) - CheckDefAndScriptFailure(['map([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String']) + v9.CheckDefAndScriptFailure(['map(1, "1")'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1251: List, Dictionary, Blob or String required for argument 1']) + v9.CheckDefAndScriptFailure(['map([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String']) # type of dict remains dict even when type of values changes # same for list @@ -2179,7 +2185,7 @@ def Test_map() map(g:gl, (k, v) => true) assert_equal([true], g:gl) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_map_failure() @@ -2198,7 +2204,7 @@ def Test_map_failure() enddef e END - CheckScriptFailure(lines, 'E1013:') + v9.CheckScriptFailure(lines, 'E1013:') au! BufReadPost delete('Xtmpfile') @@ -2207,7 +2213,7 @@ def Test_map_failure() g:gd = d map(g:gd, (k, v) => true) END - CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got bool') + v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got bool') enddef def Test_map_function_arg() @@ -2219,16 +2225,16 @@ def Test_map_function_arg() map(l, MapOne) assert_equal(['0:a', '1:b', '2:c'], l) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END range(3)->map((a, b, c) => a + b + c) END - CheckDefExecAndScriptFailure(lines, 'E1190: One argument too few') + v9.CheckDefExecAndScriptFailure(lines, 'E1190: One argument too few') lines =<< trim END range(3)->map((a, b, c, d) => a + b + c + d) END - CheckDefExecAndScriptFailure(lines, 'E1190: 2 arguments too few') + v9.CheckDefExecAndScriptFailure(lines, 'E1190: 2 arguments too few') # declared list cannot change type lines =<< trim END @@ -2238,7 +2244,7 @@ def Test_map_function_arg() var ll: list = [1, 2, 3] echo map(ll, Map) END - CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): number but got func(number, number): string', 'E1012: Type mismatch; expected number but got string in map()']) + v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): number but got func(number, number): string', 'E1012: Type mismatch; expected number but got string in map()']) # not declared list can change type echo [1, 2, 3]->map((..._) => 'x') @@ -2250,25 +2256,25 @@ def Test_map_item_type() map(l, (k, v) => k .. '/' .. v ) assert_equal(['0/a', '1/b', '2/c'], l) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var l: list = [0] echo map(l, (_, v) => []) END - CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): number but got func(any, any): list', 'E1012: Type mismatch; expected number but got list in map()'], 2) + v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): number but got func(any, any): list', 'E1012: Type mismatch; expected number but got list in map()'], 2) lines =<< trim END var l: list = range(2) echo map(l, (_, v) => []) END - CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): number but got func(any, any): list', 'E1012: Type mismatch; expected number but got list in map()'], 2) + v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): number but got func(any, any): list', 'E1012: Type mismatch; expected number but got list in map()'], 2) lines =<< trim END var d: dict = {key: 0} echo map(d, (_, v) => []) END - CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): number but got func(any, any): list', 'E1012: Type mismatch; expected number but got list in map()'], 2) + v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(...): number but got func(any, any): list', 'E1012: Type mismatch; expected number but got list in map()'], 2) enddef def Test_maparg() @@ -2289,10 +2295,10 @@ def Test_maparg() rhs: 'bar', buffer: 0}) unmap foo - CheckDefAndScriptFailure(['maparg(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['maparg("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['maparg("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) - CheckDefAndScriptFailure(['maparg("a", "b", true, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) + v9.CheckDefAndScriptFailure(['maparg(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['maparg("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['maparg("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['maparg("a", "b", true, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) maparg('')->assert_equal('') enddef @@ -2308,31 +2314,31 @@ def Test_mapcheck() iabbrev foo foobar mapcheck('foo', 'i', true)->assert_equal('foobar') iunabbrev foo - CheckDefAndScriptFailure(['mapcheck(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['mapcheck("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['mapcheck("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['mapcheck(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['mapcheck("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['mapcheck("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) mapcheck('')->assert_equal('') mapcheck('', '')->assert_equal('') enddef def Test_mapnew() if has('channel') - CheckDefAndScriptFailure(['mapnew(test_null_job(), "1")'], ['E1013: Argument 1: type mismatch, expected list but got job', 'E1251: List, Dictionary, Blob or String required for argument 1']) + v9.CheckDefAndScriptFailure(['mapnew(test_null_job(), "1")'], ['E1013: Argument 1: type mismatch, expected list but got job', 'E1251: List, Dictionary, Blob or String required for argument 1']) endif - CheckDefAndScriptFailure(['mapnew(1, "1")'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1251: List, Dictionary, Blob or String required for argument 1']) + v9.CheckDefAndScriptFailure(['mapnew(1, "1")'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1251: List, Dictionary, Blob or String required for argument 1']) enddef def Test_mapset() - CheckDefAndScriptFailure(['mapset(1, true, {})'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['mapset("a", 2, {})'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) - CheckDefAndScriptFailure(['mapset("a", false, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['mapset(1, true, {})'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['mapset("a", 2, {})'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['mapset("a", false, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef def Test_match() - CheckDefAndScriptFailure(['match(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['match(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['match("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['match("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['match(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['match(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['match("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['match("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) assert_equal(2, match('ab12cd', '12')) assert_equal(-1, match('ab12cd', '34')) assert_equal(6, match('ab12cd12ef', '12', 4)) @@ -2347,39 +2353,39 @@ def Test_match() enddef def Test_matchadd() - CheckDefAndScriptFailure(['matchadd(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['matchadd("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['matchadd("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['matchadd("a", "b", 1, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) - CheckDefAndScriptFailure(['matchadd("a", "b", 1, 1, [])'], ['E1013: Argument 5: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 5']) + v9.CheckDefAndScriptFailure(['matchadd(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['matchadd("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['matchadd("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['matchadd("a", "b", 1, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['matchadd("a", "b", 1, 1, [])'], ['E1013: Argument 5: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 5']) matchadd('', 'a')->assert_equal(-1) matchadd('Search', '')->assert_equal(-1) enddef def Test_matchaddpos() - CheckDefAndScriptFailure(['matchaddpos(1, [1])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['matchaddpos("a", "b")'], ['E1013: Argument 2: type mismatch, expected list but got string', 'E1211: List required for argument 2']) - CheckDefAndScriptFailure(['matchaddpos("a", [1], "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['matchaddpos("a", [1], 1, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) - CheckDefAndScriptFailure(['matchaddpos("a", [1], 1, 1, [])'], ['E1013: Argument 5: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 5']) + v9.CheckDefAndScriptFailure(['matchaddpos(1, [1])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['matchaddpos("a", "b")'], ['E1013: Argument 2: type mismatch, expected list but got string', 'E1211: List required for argument 2']) + v9.CheckDefAndScriptFailure(['matchaddpos("a", [1], "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['matchaddpos("a", [1], 1, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['matchaddpos("a", [1], 1, 1, [])'], ['E1013: Argument 5: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 5']) matchaddpos('', [1])->assert_equal(-1) enddef def Test_matcharg() - CheckDefAndScriptFailure(['matcharg("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['matcharg("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_matchdelete() - CheckDefAndScriptFailure(['matchdelete("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['matchdelete("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['matchdelete(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['matchdelete("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['matchdelete("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['matchdelete(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_matchend() - CheckDefAndScriptFailure(['matchend(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['matchend(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['matchend("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['matchend("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['matchend(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['matchend(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['matchend("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['matchend("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) assert_equal(4, matchend('ab12cd', '12')) assert_equal(-1, matchend('ab12cd', '34')) assert_equal(8, matchend('ab12cd12ef', '12', 4)) @@ -2394,24 +2400,24 @@ def Test_matchend() enddef def Test_matchfuzzy() - CheckDefAndScriptFailure(['matchfuzzy({}, "p")'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['matchfuzzy([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['matchfuzzy([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['matchfuzzy({}, "p")'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['matchfuzzy([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['matchfuzzy([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) matchfuzzy(['abc', 'xyz'], '')->assert_equal([]) enddef def Test_matchfuzzypos() - CheckDefAndScriptFailure(['matchfuzzypos({}, "p")'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['matchfuzzypos([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['matchfuzzypos([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['matchfuzzypos({}, "p")'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['matchfuzzypos([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['matchfuzzypos([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) matchfuzzypos(['abc', 'xyz'], '')->assert_equal([[], [], []]) enddef def Test_matchlist() - CheckDefAndScriptFailure(['matchlist(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['matchlist(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['matchlist("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['matchlist("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['matchlist(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['matchlist(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['matchlist("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['matchlist("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) var l: list = ['12', '', '', '', '', '', '', '', '', ''] assert_equal(l, matchlist('ab12cd', '12')) assert_equal([], matchlist('ab12cd', '34')) @@ -2429,10 +2435,10 @@ def Test_matchlist() enddef def Test_matchstr() - CheckDefAndScriptFailure(['matchstr(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['matchstr(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['matchstr("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['matchstr("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['matchstr(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['matchstr(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['matchstr("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['matchstr("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) assert_equal('12', matchstr('ab12cd', '12')) assert_equal('', matchstr('ab12cd', '34')) assert_equal('12', matchstr('ab12cd12ef', '12', 4)) @@ -2447,10 +2453,10 @@ def Test_matchstr() enddef def Test_matchstrpos() - CheckDefAndScriptFailure(['matchstrpos(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['matchstrpos(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['matchstrpos("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['matchstrpos("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['matchstrpos(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['matchstrpos(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['matchstrpos("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['matchstrpos("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) assert_equal(['12', 2, 4], matchstrpos('ab12cd', '12')) assert_equal(['', -1, -1], matchstrpos('ab12cd', '34')) assert_equal(['12', 6, 8], matchstrpos('ab12cd12ef', '12', 4)) @@ -2478,13 +2484,13 @@ def Test_max() ? [1, max([2, 3])] : [4, 5] assert_equal([4, 5], l2) - CheckDefAndScriptFailure(['max(5)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1227: List or Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['max(5)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1227: List or Dictionary required for argument 1']) enddef def Test_menu_info() - CheckDefAndScriptFailure(['menu_info(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['menu_info(10, "n")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['menu_info("File", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['menu_info(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['menu_info(10, "n")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['menu_info("File", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) assert_equal({}, menu_info('aMenu')) enddef @@ -2500,49 +2506,49 @@ def Test_min() ? [1, min([2, 3])] : [4, 5] assert_equal([4, 5], l2) - CheckDefAndScriptFailure(['min(5)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1227: List or Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['min(5)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1227: List or Dictionary required for argument 1']) enddef def Test_mkdir() - CheckDefAndScriptFailure(['mkdir(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['mkdir("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['mkdir("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefExecAndScriptFailure(['mkdir("")'], 'E1175: Non-empty string required for argument 1') + v9.CheckDefAndScriptFailure(['mkdir(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['mkdir("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['mkdir("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefExecAndScriptFailure(['mkdir("")'], 'E1175: Non-empty string required for argument 1') delete('a', 'rf') enddef def Test_mode() - CheckDefAndScriptFailure(['mode("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) - CheckDefAndScriptFailure(['mode(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['mode("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['mode(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) enddef def Test_mzeval() if !has('mzscheme') CheckFeature mzscheme endif - CheckDefAndScriptFailure(['mzeval(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['mzeval(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_nextnonblank() - CheckDefAndScriptFailure(['nextnonblank(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['nextnonblank("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['nextnonblank(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['nextnonblank("")'], 'E1209: Invalid value for a line number') assert_equal(0, nextnonblank(1)) enddef def Test_nr2char() nr2char(97, true)->assert_equal('a') - CheckDefAndScriptFailure(['nr2char("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['nr2char(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['nr2char("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['nr2char(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2']) enddef def Test_or() - CheckDefAndScriptFailure(['or("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['or(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['or("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['or(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_pathshorten() - CheckDefAndScriptFailure(['pathshorten(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['pathshorten("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['pathshorten(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['pathshorten("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) pathshorten('')->assert_equal('') enddef @@ -2550,12 +2556,12 @@ def Test_perleval() if !has('perl') CheckFeature perl endif - CheckDefAndScriptFailure(['perleval(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['perleval(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_popup_atcursor() - CheckDefAndScriptFailure(['popup_atcursor({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) - CheckDefAndScriptFailure(['popup_atcursor("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_atcursor({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_atcursor("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) # Pass variable of type 'any' to popup_atcursor() var what: any = 'Hello' @@ -2565,17 +2571,17 @@ def Test_popup_atcursor() enddef def Test_popup_beval() - CheckDefAndScriptFailure(['popup_beval({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) - CheckDefAndScriptFailure(['popup_beval("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_beval({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_beval("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_popup_clear() - CheckDefAndScriptFailure(['popup_clear(["a"])'], ['E1013: Argument 1: type mismatch, expected bool but got list', 'E1212: Bool required for argument 1']) - CheckDefAndScriptFailure(['popup_clear(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_clear(["a"])'], ['E1013: Argument 1: type mismatch, expected bool but got list', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_clear(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) enddef def Test_popup_close() - CheckDefAndScriptFailure(['popup_close("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_close("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_popup_create() @@ -2587,81 +2593,81 @@ def Test_popup_create() enddef def Test_popup_dialog() - CheckDefAndScriptFailure(['popup_dialog({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) - CheckDefAndScriptFailure(['popup_dialog("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_dialog({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_dialog("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_popup_filter_menu() - CheckDefAndScriptFailure(['popup_filter_menu("x", "")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_filter_menu(1, 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_filter_menu("x", "")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_filter_menu(1, 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) var id: number = popup_menu(["one", "two", "three"], {}) popup_filter_menu(id, '') popup_close(id) enddef def Test_popup_filter_yesno() - CheckDefAndScriptFailure(['popup_filter_yesno("x", "")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_filter_yesno(1, 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_filter_yesno("x", "")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_filter_yesno(1, 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) enddef def Test_popup_getoptions() - CheckDefAndScriptFailure(['popup_getoptions("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_getoptions(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_getoptions("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_getoptions(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) enddef def Test_popup_getpos() - CheckDefAndScriptFailure(['popup_getpos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_getpos(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_getpos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_getpos(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) enddef def Test_popup_hide() - CheckDefAndScriptFailure(['popup_hide("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_hide(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_hide("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_hide(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) enddef def Test_popup_locate() - CheckDefAndScriptFailure(['popup_locate("a", 20)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_locate(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_locate("a", 20)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_locate(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_popup_menu() - CheckDefAndScriptFailure(['popup_menu({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) - CheckDefAndScriptFailure(['popup_menu("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_menu({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_menu("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_popup_move() - CheckDefAndScriptFailure(['popup_move("x", {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_move(1, [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_move("x", {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_move(1, [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_popup_notification() - CheckDefAndScriptFailure(['popup_notification({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) - CheckDefAndScriptFailure(['popup_notification("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_notification({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_notification("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_popup_setoptions() - CheckDefAndScriptFailure(['popup_setoptions("x", {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_setoptions(1, [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_setoptions("x", {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_setoptions(1, [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_popup_settext() - CheckDefAndScriptFailure(['popup_settext("x", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_settext(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1222: String or List required for argument 2']) + v9.CheckDefAndScriptFailure(['popup_settext("x", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_settext(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1222: String or List required for argument 2']) enddef def Test_popup_show() - CheckDefAndScriptFailure(['popup_show("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['popup_show(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_show("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['popup_show(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) enddef def Test_prevnonblank() - CheckDefAndScriptFailure(['prevnonblank(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['prevnonblank("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['prevnonblank(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['prevnonblank("")'], 'E1209: Invalid value for a line number') assert_equal(0, prevnonblank(1)) enddef def Test_printf() - CheckDefAndScriptFailure(['printf([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['printf([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) printf(0x10)->assert_equal('16') assert_equal(" abc", "abc"->printf("%4s")) enddef @@ -2670,7 +2676,7 @@ def Test_prompt_getprompt() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['prompt_getprompt([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['prompt_getprompt([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) assert_equal('', prompt_getprompt('NonExistingBuf')) endif enddef @@ -2679,7 +2685,7 @@ def Test_prompt_setcallback() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['prompt_setcallback(true, "1")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['prompt_setcallback(true, "1")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) endif enddef @@ -2687,7 +2693,7 @@ def Test_prompt_setinterrupt() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['prompt_setinterrupt(true, "1")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['prompt_setinterrupt(true, "1")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) endif enddef @@ -2695,116 +2701,116 @@ def Test_prompt_setprompt() if !has('channel') CheckFeature channel else - CheckDefAndScriptFailure(['prompt_setprompt([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['prompt_setprompt(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['prompt_setprompt([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['prompt_setprompt(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) endif enddef def Test_prop_add() - CheckDefAndScriptFailure(['prop_add("a", 2, {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['prop_add(1, "b", {})'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['prop_add(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['prop_add("a", 2, {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_add(1, "b", {})'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_add(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef def Test_prop_add_list() - CheckDefAndScriptFailure(['prop_add_list([], [])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) - CheckDefAndScriptFailure(['prop_add_list({}, {})'], ['E1013: Argument 2: type mismatch, expected list but got dict', 'E1211: List required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_add_list([], [])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_add_list({}, {})'], ['E1013: Argument 2: type mismatch, expected list but got dict', 'E1211: List required for argument 2']) enddef def Test_prop_clear() - CheckDefAndScriptFailure(['prop_clear("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['prop_clear(1, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['prop_clear(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['prop_clear("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_clear(1, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_clear(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef def Test_prop_find() - CheckDefAndScriptFailure(['prop_find([1, 2])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) - CheckDefAndScriptFailure(['prop_find([1, 2], "k")'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) - CheckDefAndScriptFailure(['prop_find({"a": 10}, ["a"])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_find([1, 2])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_find([1, 2], "k")'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_find({"a": 10}, ["a"])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) assert_fails("prop_find({}, '')", 'E474:') enddef def Test_prop_list() - CheckDefAndScriptFailure(['prop_list("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['prop_list(1, [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_list("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_list(1, [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_prop_remove() - CheckDefAndScriptFailure(['prop_remove([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) - CheckDefAndScriptFailure(['prop_remove({}, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['prop_remove({}, 1, "b")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['prop_remove([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_remove({}, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_remove({}, 1, "b")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) enddef def Test_prop_type_add() - CheckDefAndScriptFailure(['prop_type_add({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['prop_type_add("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_type_add({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_type_add("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) assert_fails("prop_type_add('', {highlight: 'Search'})", 'E474:') enddef def Test_prop_type_change() - CheckDefAndScriptFailure(['prop_type_change({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['prop_type_change("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_type_change({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_type_change("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) assert_fails("prop_type_change('', {highlight: 'Search'})", 'E474:') enddef def Test_prop_type_delete() - CheckDefAndScriptFailure(['prop_type_delete({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['prop_type_delete({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['prop_type_delete("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_type_delete({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_type_delete({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_type_delete("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) assert_fails("prop_type_delete('')", 'E474:') enddef def Test_prop_type_get() - CheckDefAndScriptFailure(['prop_type_get({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['prop_type_get({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['prop_type_get("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['prop_type_get({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_type_get({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_type_get("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) assert_fails("prop_type_get('')", 'E474:') enddef def Test_prop_type_list() - CheckDefAndScriptFailure(['prop_type_list(["a"])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) - CheckDefAndScriptFailure(['prop_type_list(2)'], ['E1013: Argument 1: type mismatch, expected dict but got number', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_type_list(["a"])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['prop_type_list(2)'], ['E1013: Argument 1: type mismatch, expected dict but got number', 'E1206: Dictionary required for argument 1']) enddef def Test_py3eval() if !has('python3') CheckFeature python3 endif - CheckDefAndScriptFailure(['py3eval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['py3eval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_pyeval() if !has('python') CheckFeature python endif - CheckDefAndScriptFailure(['pyeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['pyeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_pyxeval() if !has('python') && !has('python3') CheckFeature python endif - CheckDefAndScriptFailure(['pyxeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['pyxeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_rand() - CheckDefAndScriptFailure(['rand(10)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) - CheckDefFailure(['rand(["a"])'], 'E1013: Argument 1: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['rand(10)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) + v9.CheckDefFailure(['rand(["a"])'], 'E1013: Argument 1: type mismatch, expected list but got list') assert_true(rand() >= 0) assert_true(rand(srand()) >= 0) enddef def Test_range() - CheckDefAndScriptFailure(['range("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['range(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['range(10, 20, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['range("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['range(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['range(10, 20, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) enddef def Test_readdir() eval expand('sautest')->readdir((e) => e[0] !=# '.') eval expand('sautest')->readdirex((e) => e.name[0] !=# '.') - CheckDefAndScriptFailure(['readdir(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['readdir("a", "1", [3])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['readdir(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['readdir("a", "1", [3])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) if has('unix') # only fails on Unix-like systems assert_fails('readdir("")', 'E484: Can''t open file') @@ -2812,8 +2818,8 @@ def Test_readdir() enddef def Test_readdirex() - CheckDefAndScriptFailure(['readdirex(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['readdirex("a", "1", [3])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['readdirex(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['readdirex("a", "1", [3])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) if has('unix') # only fails on Unix-like systems assert_fails('readdirex("")', 'E484: Can''t open file') @@ -2829,8 +2835,8 @@ def Test_readblob() var lines =<< trim END var read: list = readblob('Xreadblob') END - CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list but got blob', 1) - CheckDefExecAndScriptFailure(['readblob("")'], 'E484: Can''t open file ') + v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list but got blob', 1) + v9.CheckDefExecAndScriptFailure(['readblob("")'], 'E484: Can''t open file ') delete('Xreadblob') enddef @@ -2843,16 +2849,16 @@ def Test_readfile() var lines =<< trim END var read: dict = readfile('Xreadfile') END - CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected dict but got list', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected dict but got list', 1) delete('Xreadfile') - CheckDefAndScriptFailure(['readfile("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['readfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefExecAndScriptFailure(['readfile("")'], 'E1175: Non-empty string required for argument 1') + v9.CheckDefAndScriptFailure(['readfile("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['readfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefExecAndScriptFailure(['readfile("")'], 'E1175: Non-empty string required for argument 1') enddef def Test_reduce() - CheckDefAndScriptFailure(['reduce({a: 10}, "1")'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1252: String, List or Blob required for argument 1']) + v9.CheckDefAndScriptFailure(['reduce({a: 10}, "1")'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1252: String, List or Blob required for argument 1']) assert_equal(6, [1, 2, 3]->reduce((r, c) => r + c, 0)) assert_equal(11, 0z0506->reduce((r, c) => r + c, 0)) enddef @@ -2860,13 +2866,13 @@ enddef def Test_reltime() CheckFeature reltime - CheckDefExecAndScriptFailure(['[]->reltime()'], 'E474:') - CheckDefExecAndScriptFailure(['[]->reltime([])'], 'E474:') + v9.CheckDefExecAndScriptFailure(['[]->reltime()'], 'E474:') + v9.CheckDefExecAndScriptFailure(['[]->reltime([])'], 'E474:') - CheckDefAndScriptFailure(['reltime("x")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefFailure(['reltime(["x", "y"])'], 'E1013: Argument 1: type mismatch, expected list but got list') - CheckDefAndScriptFailure(['reltime([1, 2], 10)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) - CheckDefFailure(['reltime([1, 2], ["a", "b"])'], 'E1013: Argument 2: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['reltime("x")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefFailure(['reltime(["x", "y"])'], 'E1013: Argument 1: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['reltime([1, 2], 10)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) + v9.CheckDefFailure(['reltime([1, 2], ["a", "b"])'], 'E1013: Argument 2: type mismatch, expected list but got list') var start: list = reltime() assert_true(type(reltime(start)) == v:t_list) var end: list = reltime() @@ -2876,31 +2882,31 @@ enddef def Test_reltimefloat() CheckFeature reltime - CheckDefExecAndScriptFailure(['[]->reltimefloat()'], 'E474:') + v9.CheckDefExecAndScriptFailure(['[]->reltimefloat()'], 'E474:') - CheckDefAndScriptFailure(['reltimefloat("x")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefFailure(['reltimefloat([1.1])'], 'E1013: Argument 1: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['reltimefloat("x")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefFailure(['reltimefloat([1.1])'], 'E1013: Argument 1: type mismatch, expected list but got list') assert_true(type(reltimefloat(reltime())) == v:t_float) enddef def Test_reltimestr() CheckFeature reltime - CheckDefExecAndScriptFailure(['[]->reltimestr()'], 'E474:') + v9.CheckDefExecAndScriptFailure(['[]->reltimestr()'], 'E474:') - CheckDefAndScriptFailure(['reltimestr(true)'], ['E1013: Argument 1: type mismatch, expected list but got bool', 'E1211: List required for argument 1']) - CheckDefFailure(['reltimestr([true])'], 'E1013: Argument 1: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['reltimestr(true)'], ['E1013: Argument 1: type mismatch, expected list but got bool', 'E1211: List required for argument 1']) + v9.CheckDefFailure(['reltimestr([true])'], 'E1013: Argument 1: type mismatch, expected list but got list') assert_true(type(reltimestr(reltime())) == v:t_string) enddef def Test_remote_expr() CheckFeature clientserver CheckEnv DISPLAY - CheckDefAndScriptFailure(['remote_expr(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['remote_expr("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['remote_expr("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) - CheckDefAndScriptFailure(['remote_expr("a", "b", "c", "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) - CheckDefExecAndScriptFailure(['remote_expr("", "")'], 'E241: Unable to send to ') + v9.CheckDefAndScriptFailure(['remote_expr(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['remote_expr("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['remote_expr("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['remote_expr("a", "b", "c", "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefExecAndScriptFailure(['remote_expr("", "")'], 'E241: Unable to send to ') enddef def Test_remote_foreground() @@ -2909,7 +2915,7 @@ def Test_remote_foreground() CheckNotMSWindows CheckEnv DISPLAY - CheckDefAndScriptFailure(['remote_foreground(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['remote_foreground(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_fails('remote_foreground("NonExistingServer")', 'E241:') assert_fails('remote_foreground("")', 'E241:') enddef @@ -2917,32 +2923,32 @@ enddef def Test_remote_peek() CheckFeature clientserver CheckEnv DISPLAY - CheckDefAndScriptFailure(['remote_peek(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['remote_peek("a5b6c7", [1])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefExecAndScriptFailure(['remote_peek("")'], 'E573: Invalid server id used') + v9.CheckDefAndScriptFailure(['remote_peek(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['remote_peek("a5b6c7", [1])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefExecAndScriptFailure(['remote_peek("")'], 'E573: Invalid server id used') enddef def Test_remote_read() CheckFeature clientserver CheckEnv DISPLAY - CheckDefAndScriptFailure(['remote_read(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['remote_read("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefExecAndScriptFailure(['remote_read("")'], 'E573: Invalid server id used') + v9.CheckDefAndScriptFailure(['remote_read(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['remote_read("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefExecAndScriptFailure(['remote_read("")'], 'E573: Invalid server id used') enddef def Test_remote_send() CheckFeature clientserver CheckEnv DISPLAY - CheckDefAndScriptFailure(['remote_send(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['remote_send("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['remote_send("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['remote_send(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['remote_send("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['remote_send("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) assert_fails('remote_send("", "")', 'E241:') enddef def Test_remote_startserver() CheckFeature clientserver CheckEnv DISPLAY - CheckDefAndScriptFailure(['remote_startserver({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['remote_startserver({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) enddef def Test_remove_const_list() @@ -2952,12 +2958,12 @@ def Test_remove_const_list() enddef def Test_remove() - CheckDefAndScriptFailure(['remove("a", 1)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1228: List, Dictionary or Blob required for argument 1']) - CheckDefAndScriptFailure(['remove([], "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['remove([], 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['remove({}, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2']) - CheckDefAndScriptFailure(['remove(0z10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['remove(0z20, 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['remove("a", 1)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1228: List, Dictionary or Blob required for argument 1']) + v9.CheckDefAndScriptFailure(['remove([], "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['remove([], 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['remove({}, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['remove(0z10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['remove(0z20, 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) var l: any = [1, 2, 3, 4] remove(l, 1) assert_equal([1, 3, 4], l) @@ -2986,14 +2992,14 @@ def Test_remove_return_type() enddef def Test_rename() - CheckDefAndScriptFailure(['rename(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['rename("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['rename(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['rename("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) rename('', '')->assert_equal(0) enddef def Test_repeat() - CheckDefAndScriptFailure(['repeat(1.1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1224: String, Number or List required for argument 1']) - CheckDefAndScriptFailure(['repeat({a: 10}, 2)'], ['E1013: Argument 1: type mismatch, expected string but got dict<', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['repeat(1.1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['repeat({a: 10}, 2)'], ['E1013: Argument 1: type mismatch, expected string but got dict<', 'E1224: String, Number or List required for argument 1']) var lines =<< trim END assert_equal('aaa', repeat('a', 3)) assert_equal('111', repeat(1, 3)) @@ -3002,18 +3008,18 @@ def Test_repeat() s ..= repeat(5, 3) assert_equal('-555', s) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_resolve() - CheckDefAndScriptFailure(['resolve([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['resolve([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) assert_equal('SomeFile', resolve('SomeFile')) resolve('')->assert_equal('') enddef def Test_reverse() - CheckDefAndScriptFailure(['reverse(10)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1226: List or Blob required for argument 1']) - CheckDefAndScriptFailure(['reverse("abc")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1226: List or Blob required for argument 1']) + v9.CheckDefAndScriptFailure(['reverse(10)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1226: List or Blob required for argument 1']) + v9.CheckDefAndScriptFailure(['reverse("abc")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1226: List or Blob required for argument 1']) enddef def Test_reverse_return_type() @@ -3029,34 +3035,34 @@ def Test_rubyeval() if !has('ruby') CheckFeature ruby endif - CheckDefAndScriptFailure(['rubyeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['rubyeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_screenattr() - CheckDefAndScriptFailure(['screenattr("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['screenattr(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['screenattr("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['screenattr(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_screenchar() - CheckDefAndScriptFailure(['screenchar("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['screenchar(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['screenchar("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['screenchar(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_screenchars() - CheckDefAndScriptFailure(['screenchars("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['screenchars(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['screenchars("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['screenchars(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_screenpos() - CheckDefAndScriptFailure(['screenpos("a", 1, 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['screenpos(1, "b", 1)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['screenpos(1, 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['screenpos("a", 1, 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['screenpos(1, "b", 1)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['screenpos(1, 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) assert_equal({col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(1, 1, 1)) enddef def Test_screenstring() - CheckDefAndScriptFailure(['screenstring("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['screenstring(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['screenstring("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['screenstring(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_search() @@ -3088,13 +3094,13 @@ def Test_search() normal 0 assert_equal([0, 0], searchpos('this', '', 0, 0, 'col(".") > col')) bwipe! - CheckDefAndScriptFailure(['search(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['search("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['search("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['search("a", "b", 3, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['search(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['search("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['search("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['search("a", "b", 3, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) new setline(1, "match this") - CheckDefAndScriptFailure(['search("a", "", 9, 0, [0])'], ['E1013: Argument 5: type mismatch, expected func(...): any but got list', 'E730: Using a List as a String']) + v9.CheckDefAndScriptFailure(['search("a", "", 9, 0, [0])'], ['E1013: Argument 5: type mismatch, expected func(...): any but got list', 'E730: Using a List as a String']) bwipe! enddef @@ -3110,14 +3116,14 @@ def Test_searchcount() maxcount: 99, incomplete: 0}) bwipe! - CheckDefAndScriptFailure(['searchcount([1])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['searchcount([1])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) enddef def Test_searchdecl() searchdecl('blah', true, true)->assert_equal(1) - CheckDefAndScriptFailure(['searchdecl(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['searchdecl("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) - CheckDefAndScriptFailure(['searchdecl("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['searchdecl(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['searchdecl("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['searchdecl("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) enddef def Test_searchpair() @@ -3159,7 +3165,7 @@ def Test_searchpair() enddef Fail() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_equal('yes', g:caught) unlet g:caught bwipe! @@ -3167,62 +3173,62 @@ def Test_searchpair() lines =<< trim END echo searchpair("a", "b", "c", "d", "f", 33) END - CheckDefAndScriptFailure(lines, ['E1001: Variable not found: f', 'E475: Invalid argument: d']) + v9.CheckDefAndScriptFailure(lines, ['E1001: Variable not found: f', 'E475: Invalid argument: d']) var errors = ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'] - CheckDefAndScriptFailure(['searchpair(1, "b", "c")'], errors) - CheckDefAndScriptFailure(['searchpairpos(1, "b", "c")'], errors) + v9.CheckDefAndScriptFailure(['searchpair(1, "b", "c")'], errors) + v9.CheckDefAndScriptFailure(['searchpairpos(1, "b", "c")'], errors) errors = ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'] - CheckDefAndScriptFailure(['searchpair("a", 2, "c")'], errors) - CheckDefAndScriptFailure(['searchpairpos("a", 2, "c")'], errors) + v9.CheckDefAndScriptFailure(['searchpair("a", 2, "c")'], errors) + v9.CheckDefAndScriptFailure(['searchpairpos("a", 2, "c")'], errors) errors = ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'] - CheckDefAndScriptFailure(['searchpair("a", "b", 3)'], errors) - CheckDefAndScriptFailure(['searchpairpos("a", "b", 3)'], errors) + v9.CheckDefAndScriptFailure(['searchpair("a", "b", 3)'], errors) + v9.CheckDefAndScriptFailure(['searchpairpos("a", "b", 3)'], errors) errors = ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'] - CheckDefAndScriptFailure(['searchpair("a", "b", "c", 4)'], errors) + v9.CheckDefAndScriptFailure(['searchpair("a", "b", "c", 4)'], errors) new setline(1, "match this") errors = ['E1013: Argument 5: type mismatch, expected func(...): any but got list', 'E730: Using a List as a String'] - CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", [0])'], errors) - CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", [0])'], errors) + v9.CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", [0])'], errors) + v9.CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", [0])'], errors) bwipe! errors = ['E1013: Argument 6: type mismatch, expected number but got string', 'E1210: Number required for argument 6'] - CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", "1", "f")'], errors) - CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", "1", "f")'], errors) + v9.CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", "1", "f")'], errors) + v9.CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", "1", "f")'], errors) errors = ['E1013: Argument 7: type mismatch, expected number but got string', 'E1210: Number required for argument 7'] - CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", "1", 3, "g")'], errors) - CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", "1", 3, "g")'], errors) + v9.CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", "1", 3, "g")'], errors) + v9.CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", "1", 3, "g")'], errors) enddef def Test_searchpos() - CheckDefAndScriptFailure(['searchpos(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['searchpos("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['searchpos("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['searchpos("a", "b", 3, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['searchpos(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['searchpos("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['searchpos("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['searchpos("a", "b", 3, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) new setline(1, "match this") - CheckDefAndScriptFailure(['searchpos("a", "", 9, 0, [0])'], ['E1013: Argument 5: type mismatch, expected func(...): any but got list', 'E730: Using a List as a String']) + v9.CheckDefAndScriptFailure(['searchpos("a", "", 9, 0, [0])'], ['E1013: Argument 5: type mismatch, expected func(...): any but got list', 'E730: Using a List as a String']) bwipe! enddef def Test_server2client() CheckFeature clientserver CheckEnv DISPLAY - CheckDefAndScriptFailure(['server2client(10, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['server2client("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefExecAndScriptFailure(['server2client("", "a")'], 'E573: Invalid server id used') - CheckDefExecAndScriptFailure(['server2client("", "")'], 'E573: Invalid server id used') + v9.CheckDefAndScriptFailure(['server2client(10, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['server2client("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefExecAndScriptFailure(['server2client("", "a")'], 'E573: Invalid server id used') + v9.CheckDefExecAndScriptFailure(['server2client("", "")'], 'E573: Invalid server id used') enddef def Test_shellescape() - CheckDefAndScriptFailure(['shellescape(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['shellescape("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['shellescape(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['shellescape("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) if has('unix') assert_equal("''", shellescape('')) endif @@ -3275,7 +3281,7 @@ def Test_set_get_bufline() exe 'bwipe! ' .. b END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_setbufvar() @@ -3302,8 +3308,8 @@ def Test_setbufvar() setbufvar('%', 'myvar', 123) getbufvar('%', 'myvar')->assert_equal(123) - CheckDefAndScriptFailure(['setbufvar(true, "v", 3)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['setbufvar(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['setbufvar(true, "v", 3)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['setbufvar(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) assert_fails('setbufvar("%", "", 10)', 'E461: Illegal variable name') enddef @@ -3316,10 +3322,10 @@ def Test_setbufline() setbufline(bnum, 5, 10) setbufline(bnum, 6, ['two', 11]) assert_equal(['1', '2', '3', 'one', '10', 'two', '11'], getbufline(bnum, 1, '$')) - CheckDefAndScriptFailure(['setbufline([1], 1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['setbufline(1, [1], "x")'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) - CheckDefExecAndScriptFailure(['setbufline(' .. bnum .. ', -1, "x")'], 'E966: Invalid line number: -1') - CheckDefAndScriptFailure(['setbufline(1, 1, {"a": 10})'], ['E1013: Argument 3: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 3']) + v9.CheckDefAndScriptFailure(['setbufline([1], 1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['setbufline(1, [1], "x")'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1220: String or Number required for argument 2']) + v9.CheckDefExecAndScriptFailure(['setbufline(' .. bnum .. ', -1, "x")'], 'E966: Invalid line number: -1') + v9.CheckDefAndScriptFailure(['setbufline(1, 1, {"a": 10})'], ['E1013: Argument 3: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 3']) bnum->bufwinid()->win_gotoid() setbufline('', 1, 'nombres') getline(1)->assert_equal('nombres') @@ -3327,47 +3333,47 @@ def Test_setbufline() enddef def Test_setcellwidths() - CheckDefAndScriptFailure(['setcellwidths(1)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['setcellwidths({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['setcellwidths(1)'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['setcellwidths({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) enddef def Test_setcharpos() - CheckDefAndScriptFailure(['setcharpos(1, [])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefFailure(['setcharpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list but got list') - CheckDefAndScriptFailure(['setcharpos(".", 1)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) - CheckDefExecAndScriptFailure(['setcharpos("", [0, 1, 1, 1])'], 'E474: Invalid argument') + v9.CheckDefAndScriptFailure(['setcharpos(1, [])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefFailure(['setcharpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['setcharpos(".", 1)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) + v9.CheckDefExecAndScriptFailure(['setcharpos("", [0, 1, 1, 1])'], 'E474: Invalid argument') enddef def Test_setcharsearch() - CheckDefAndScriptFailure(['setcharsearch("x")'], ['E1013: Argument 1: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 1']) - CheckDefAndScriptFailure(['setcharsearch([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['setcharsearch("x")'], ['E1013: Argument 1: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['setcharsearch([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) var d: dict = {char: 'x', forward: 1, until: 1} setcharsearch(d) assert_equal(d, getcharsearch()) enddef def Test_setcmdpos() - CheckDefAndScriptFailure(['setcmdpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['setcmdpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_setcursorcharpos() - CheckDefAndScriptFailure(['setcursorcharpos(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected number but got blob', 'E1224: String, Number or List required for argument 1']) - CheckDefAndScriptFailure(['setcursorcharpos(1, "2")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['setcursorcharpos(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefExecAndScriptFailure(['setcursorcharpos("", 10)'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['setcursorcharpos(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected number but got blob', 'E1224: String, Number or List required for argument 1']) + v9.CheckDefAndScriptFailure(['setcursorcharpos(1, "2")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['setcursorcharpos(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefExecAndScriptFailure(['setcursorcharpos("", 10)'], 'E1209: Invalid value for a line number') enddef def Test_setenv() - CheckDefAndScriptFailure(['setenv(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['setenv(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal(0, setenv('', '')) assert_equal(0, setenv('', v:null)) enddef def Test_setfperm() - CheckDefAndScriptFailure(['setfperm(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['setfperm("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2']) - CheckDefExecAndScriptFailure(['setfperm("Xfile", "")'], 'E475: Invalid argument') - CheckDefExecAndScriptFailure(['setfperm("", "")'], 'E475: Invalid argument') + v9.CheckDefAndScriptFailure(['setfperm(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['setfperm("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2']) + v9.CheckDefExecAndScriptFailure(['setfperm("Xfile", "")'], 'E475: Invalid argument') + v9.CheckDefExecAndScriptFailure(['setfperm("", "")'], 'E475: Invalid argument') assert_equal(0, setfperm('', 'rw-r--r--')) enddef @@ -3381,9 +3387,9 @@ def Test_setline() assert_equal(['one', 'b', 'c', 'd'], getline(1, '$')) setline(1, 10) assert_equal(['10', 'b', 'c', 'd'], getline(1, '$')) - CheckDefAndScriptFailure(['setline([1], "x")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefExecAndScriptFailure(['setline("", "x")'], 'E1209: Invalid value for a line number') - CheckDefExecAndScriptFailure(['setline(-1, "x")'], 'E966: Invalid line number: -1') + v9.CheckDefAndScriptFailure(['setline([1], "x")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefExecAndScriptFailure(['setline("", "x")'], 'E1209: Invalid value for a line number') + v9.CheckDefExecAndScriptFailure(['setline(-1, "x")'], 'E966: Invalid line number: -1') assert_fails('setline(".a", "x")', ['E1209:', 'E1209:']) bw! enddef @@ -3393,28 +3399,28 @@ def Test_setloclist() var what = {items: items} setqflist([], ' ', what) setloclist(0, [], ' ', what) - CheckDefAndScriptFailure(['setloclist("1", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['setloclist(1, 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) - CheckDefAndScriptFailure(['setloclist(1, [], 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) - CheckDefAndScriptFailure(['setloclist(1, [], "a", [])'], ['E1013: Argument 4: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 4']) + v9.CheckDefAndScriptFailure(['setloclist("1", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['setloclist(1, 2)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) + v9.CheckDefAndScriptFailure(['setloclist(1, [], 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['setloclist(1, [], "a", [])'], ['E1013: Argument 4: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 4']) enddef def Test_setmatches() - CheckDefAndScriptFailure(['setmatches({})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['setmatches([], "1")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['setmatches({})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['setmatches([], "1")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_setpos() - CheckDefAndScriptFailure(['setpos(1, [])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefFailure(['setpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list but got list') - CheckDefAndScriptFailure(['setpos(".", 1)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) - CheckDefExecAndScriptFailure(['setpos("", [0, 1, 1, 1])'], 'E474: Invalid argument') + v9.CheckDefAndScriptFailure(['setpos(1, [])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefFailure(['setpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list but got list') + v9.CheckDefAndScriptFailure(['setpos(".", 1)'], ['E1013: Argument 2: type mismatch, expected list but got number', 'E1211: List required for argument 2']) + v9.CheckDefExecAndScriptFailure(['setpos("", [0, 1, 1, 1])'], 'E474: Invalid argument') enddef def Test_setqflist() - CheckDefAndScriptFailure(['setqflist(1, "")'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['setqflist([], 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['setqflist([], "", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['setqflist(1, "")'], ['E1013: Argument 1: type mismatch, expected list but got number', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['setqflist([], 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['setqflist([], "", [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef def Test_setreg() @@ -3423,110 +3429,110 @@ def Test_setreg() setreg('a', reginfo) getreginfo('a')->assert_equal(reginfo) assert_fails('setreg("ab", 0)', 'E1162:') - CheckDefAndScriptFailure(['setreg(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['setreg("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['setreg(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['setreg("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) setreg('', '1a2b3c') assert_equal('1a2b3c', @") enddef def Test_settabvar() - CheckDefAndScriptFailure(['settabvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['settabvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['settabvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['settabvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) assert_fails('settabvar(1, "", 10)', 'E461: Illegal variable name') enddef def Test_settabwinvar() - CheckDefAndScriptFailure(['settabwinvar("a", 2, "c", true)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['settabwinvar(1, "b", "c", [])'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['settabwinvar(1, 1, 3, {})'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['settabwinvar("a", 2, "c", true)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['settabwinvar(1, "b", "c", [])'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['settabwinvar(1, 1, 3, {})'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) assert_fails('settabwinvar(1, 1, "", 10)', 'E461: Illegal variable name') enddef def Test_settagstack() - CheckDefAndScriptFailure(['settagstack(true, {})'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['settagstack(1, [1])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) - CheckDefAndScriptFailure(['settagstack(1, {}, 2)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['settagstack(true, {})'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['settagstack(1, [1])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['settagstack(1, {}, 2)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) assert_fails('settagstack(1, {}, "")', 'E962: Invalid action') enddef def Test_setwinvar() - CheckDefAndScriptFailure(['setwinvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['setwinvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['setwinvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['setwinvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) assert_fails('setwinvar(1, "", 10)', 'E461: Illegal variable name') enddef def Test_sha256() - CheckDefAndScriptFailure(['sha256(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['sha256(0zABCD)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['sha256(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['sha256(0zABCD)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1']) assert_equal('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', sha256('abc')) assert_equal('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', sha256('')) enddef def Test_shiftwidth() - CheckDefAndScriptFailure(['shiftwidth("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['shiftwidth("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_sign_define() - CheckDefAndScriptFailure(['sign_define({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['sign_define({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['sign_define("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['sign_define({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_define({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_define("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_sign_getdefined() - CheckDefAndScriptFailure(['sign_getdefined(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['sign_getdefined(2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_getdefined(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_getdefined(2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) sign_getdefined('')->assert_equal([]) enddef def Test_sign_getplaced() - CheckDefAndScriptFailure(['sign_getplaced(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['sign_getplaced(1, ["a"])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) - CheckDefAndScriptFailure(['sign_getplaced("a", 1.1)'], ['E1013: Argument 2: type mismatch, expected dict but got float', 'E1206: Dictionary required for argument 2']) - CheckDefExecAndScriptFailure(['sign_getplaced(bufnr(), {lnum: ""})'], 'E1030: Using a String as a Number:') + v9.CheckDefAndScriptFailure(['sign_getplaced(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_getplaced(1, ["a"])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['sign_getplaced("a", 1.1)'], ['E1013: Argument 2: type mismatch, expected dict but got float', 'E1206: Dictionary required for argument 2']) + v9.CheckDefExecAndScriptFailure(['sign_getplaced(bufnr(), {lnum: ""})'], 'E1030: Using a String as a Number:') sign_getplaced('')->assert_equal([{signs: [], bufnr: bufnr()}]) enddef def Test_sign_jump() - CheckDefAndScriptFailure(['sign_jump("a", "b", "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['sign_jump(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['sign_jump(1, "b", true)'], ['E1013: Argument 3: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 3']) + v9.CheckDefAndScriptFailure(['sign_jump("a", "b", "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_jump(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['sign_jump(1, "b", true)'], ['E1013: Argument 3: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 3']) enddef def Test_sign_place() - CheckDefAndScriptFailure(['sign_place("a", "b", "c", "d")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['sign_place(1, 2, "c", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['sign_place(1, "b", 3, "d")'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) - CheckDefAndScriptFailure(['sign_place(1, "b", "c", 1.1)'], ['E1013: Argument 4: type mismatch, expected string but got float', 'E1220: String or Number required for argument 4']) - CheckDefAndScriptFailure(['sign_place(1, "b", "c", "d", [1])'], ['E1013: Argument 5: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 5']) - CheckDefExecAndScriptFailure(['sign_place(0, "", "MySign", bufnr(), {lnum: ""})'], 'E1209: Invalid value for a line number: ""') + v9.CheckDefAndScriptFailure(['sign_place("a", "b", "c", "d")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_place(1, 2, "c", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['sign_place(1, "b", 3, "d")'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['sign_place(1, "b", "c", 1.1)'], ['E1013: Argument 4: type mismatch, expected string but got float', 'E1220: String or Number required for argument 4']) + v9.CheckDefAndScriptFailure(['sign_place(1, "b", "c", "d", [1])'], ['E1013: Argument 5: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 5']) + v9.CheckDefExecAndScriptFailure(['sign_place(0, "", "MySign", bufnr(), {lnum: ""})'], 'E1209: Invalid value for a line number: ""') assert_fails("sign_place(0, '', '', '')", 'E155:') enddef def Test_sign_placelist() - CheckDefAndScriptFailure(['sign_placelist("x")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['sign_placelist({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) - CheckDefExecAndScriptFailure(['sign_placelist([{"name": "MySign", "buffer": bufnr(), "lnum": ""}])'], 'E1209: Invalid value for a line number: ""') + v9.CheckDefAndScriptFailure(['sign_placelist("x")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_placelist({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefExecAndScriptFailure(['sign_placelist([{"name": "MySign", "buffer": bufnr(), "lnum": ""}])'], 'E1209: Invalid value for a line number: ""') assert_fails('sign_placelist([{name: "MySign", buffer: "", lnum: 1}])', 'E155:') enddef def Test_sign_undefine() - CheckDefAndScriptFailure(['sign_undefine({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['sign_undefine([1])'], ['E1013: Argument 1: type mismatch, expected list but got list', 'E155: Unknown sign:']) + v9.CheckDefAndScriptFailure(['sign_undefine({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_undefine([1])'], ['E1013: Argument 1: type mismatch, expected list but got list', 'E155: Unknown sign:']) enddef def Test_sign_unplace() - CheckDefAndScriptFailure(['sign_unplace({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['sign_unplace({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['sign_unplace("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['sign_unplace({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_unplace({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_unplace("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) enddef def Test_sign_unplacelist() - CheckDefAndScriptFailure(['sign_unplacelist("x")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['sign_unplacelist({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_unplacelist("x")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['sign_unplacelist({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) enddef def Test_simplify() - CheckDefAndScriptFailure(['simplify(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['simplify(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) call assert_equal('NonExistingFile', simplify('NonExistingFile')) simplify('')->assert_equal('') enddef @@ -3552,9 +3558,9 @@ def Test_slice() assert_equal(0z11, slice(0z001122334455, 1, -4)) assert_equal(0z, slice(0z001122334455, 1, -5)) assert_equal(0z, slice(0z001122334455, 1, -6)) - CheckDefAndScriptFailure(['slice({"a": 10}, 1)'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['slice([1, 2, 3], "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['slice("abc", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['slice({"a": 10}, 1)'], ['E1013: Argument 1: type mismatch, expected list but got dict', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['slice([1, 2, 3], "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['slice("abc", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) enddef def Test_spellsuggest() @@ -3563,29 +3569,29 @@ def Test_spellsuggest() else spellsuggest('marrch', 1, true)->assert_equal(['March']) endif - CheckDefAndScriptFailure(['spellsuggest(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['spellsuggest("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['spellsuggest("a", 1, 0z01)'], ['E1013: Argument 3: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['spellsuggest(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['spellsuggest("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['spellsuggest("a", 1, 0z01)'], ['E1013: Argument 3: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 3']) spellsuggest('')->assert_equal([]) enddef def Test_sound_playevent() CheckFeature sound - CheckDefAndScriptFailure(['sound_playevent(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['sound_playevent(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) enddef def Test_sound_playfile() CheckFeature sound - CheckDefAndScriptFailure(['sound_playfile(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['sound_playfile(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) enddef def Test_sound_stop() CheckFeature sound - CheckDefAndScriptFailure(['sound_stop("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['sound_stop("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_soundfold() - CheckDefAndScriptFailure(['soundfold(20)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['soundfold(20)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal('abc', soundfold('abc')) assert_equal('', soundfold('')) enddef @@ -3607,9 +3613,9 @@ def Test_sort_argument() sort(l, Compare) assert_equal([1, 2, 3, 4, 5, 6, 7, 8], l) END - CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(['sort("a")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['sort([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptFailure(['sort("a")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['sort([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef def Test_sort_compare_func_fails() @@ -3624,27 +3630,27 @@ def Test_sort_compare_func_fails() enddef def Test_spellbadword() - CheckDefAndScriptFailure(['spellbadword(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['spellbadword(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) spellbadword('good')->assert_equal(['', '']) spellbadword('')->assert_equal(['', '']) enddef def Test_split() split(' aa bb ', '\W\+', true)->assert_equal(['', 'aa', 'bb', '']) - CheckDefAndScriptFailure(['split(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['split("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['split("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['split(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['split("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['split("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) split('')->assert_equal([]) split('', '')->assert_equal([]) enddef def Test_srand() - CheckDefAndScriptFailure(['srand("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['srand("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) type(srand(100))->assert_equal(v:t_list) enddef def Test_state() - CheckDefAndScriptFailure(['state({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['state({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) assert_equal('', state('a')) enddef @@ -3656,13 +3662,13 @@ def Test_str2float() str2float("2e-2")->assert_equal(0.02) str2float('')->assert_equal(0.0) - CheckDefAndScriptFailure(['str2float(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['str2float(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) endif enddef def Test_str2list() - CheckDefAndScriptFailure(['str2list(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['str2list("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['str2list(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['str2list("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) assert_equal([97], str2list('a')) assert_equal([97], str2list('a', 1)) assert_equal([97], str2list('a', true)) @@ -3673,29 +3679,29 @@ def Test_str2nr() str2nr("1'000'000", 10, true)->assert_equal(1000000) str2nr('')->assert_equal(0) - CheckDefAndScriptFailure(['str2nr(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['str2nr("123", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['str2nr("123", 10, "x")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) + v9.CheckDefAndScriptFailure(['str2nr(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['str2nr("123", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['str2nr("123", 10, "x")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3']) enddef def Test_strcharlen() - CheckDefAndScriptFailure(['strcharlen([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['strcharlen([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) "abc"->strcharlen()->assert_equal(3) strcharlen(99)->assert_equal(2) enddef def Test_strcharpart() - CheckDefAndScriptFailure(['strcharpart(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['strcharpart("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['strcharpart("a", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['strcharpart("a", 1, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) + v9.CheckDefAndScriptFailure(['strcharpart(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strcharpart("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['strcharpart("a", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['strcharpart("a", 1, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) strcharpart('', 0)->assert_equal('') enddef def Test_strchars() strchars("A\u20dd", true)->assert_equal(1) - CheckDefAndScriptFailure(['strchars(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['strchars("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['strchars(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strchars("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) assert_equal(3, strchars('abc')) assert_equal(3, strchars('abc', 1)) assert_equal(3, strchars('abc', true)) @@ -3703,76 +3709,76 @@ def Test_strchars() enddef def Test_strdisplaywidth() - CheckDefAndScriptFailure(['strdisplaywidth(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['strdisplaywidth("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['strdisplaywidth(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strdisplaywidth("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) strdisplaywidth('')->assert_equal(0) enddef def Test_strftime() if exists('*strftime') - CheckDefAndScriptFailure(['strftime(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['strftime("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['strftime(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strftime("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) strftime('')->assert_equal('') endif enddef def Test_strgetchar() - CheckDefAndScriptFailure(['strgetchar(1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['strgetchar("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['strgetchar(1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strgetchar("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) strgetchar('', 0)->assert_equal(-1) strgetchar('', 1)->assert_equal(-1) enddef def Test_stridx() - CheckDefAndScriptFailure(['stridx([1], "b")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['stridx("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['stridx("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['stridx([1], "b")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['stridx("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['stridx("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) stridx('', '')->assert_equal(0) stridx('', 'a')->assert_equal(-1) stridx('a', '')->assert_equal(0) enddef def Test_strlen() - CheckDefAndScriptFailure(['strlen([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['strlen([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) "abc"->strlen()->assert_equal(3) strlen(99)->assert_equal(2) enddef def Test_strpart() - CheckDefAndScriptFailure(['strpart(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['strpart("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['strpart("a", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['strpart("a", 1, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) + v9.CheckDefAndScriptFailure(['strpart(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strpart("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['strpart("a", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['strpart("a", 1, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4']) strpart('', 0)->assert_equal('') enddef def Test_strptime() CheckFunction strptime if exists_compiled('*strptime') - CheckDefAndScriptFailure(['strptime(10, "2021")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['strptime("%Y", 2021)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['strptime(10, "2021")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strptime("%Y", 2021)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) assert_true(strptime('%Y', '2021') != 0) assert_true(strptime('%Y', '') == 0) endif enddef def Test_strridx() - CheckDefAndScriptFailure(['strridx([1], "b")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['strridx("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['strridx("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['strridx([1], "b")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strridx("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['strridx("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) strridx('', '')->assert_equal(0) strridx('', 'a')->assert_equal(-1) strridx('a', '')->assert_equal(1) enddef def Test_strtrans() - CheckDefAndScriptFailure(['strtrans(20)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strtrans(20)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal('abc', strtrans('abc')) strtrans('')->assert_equal('') enddef def Test_strwidth() - CheckDefAndScriptFailure(['strwidth(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['strwidth(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal(4, strwidth('abcd')) strwidth('')->assert_equal(0) enddef @@ -3783,8 +3789,8 @@ def Test_submatch() var actual = substitute('A123456789', pat, Rep, '') var expected = "[['A123456789'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9']]" actual->assert_equal(expected) - CheckDefAndScriptFailure(['submatch("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['submatch(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['submatch("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['submatch(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2']) enddef def Test_substitute() @@ -3795,20 +3801,20 @@ def Test_substitute() assert_fails('"text"->substitute(".*", () => test_null_job(), "")', 'E908: using an invalid value as a String: job') assert_fails('"text"->substitute(".*", () => test_null_channel(), "")', 'E908: using an invalid value as a String: channel') endif - CheckDefAndScriptFailure(['substitute(1, "b", "1", "d")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['substitute("a", 2, "1", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['substitute("a", "b", "1", 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']) + v9.CheckDefAndScriptFailure(['substitute(1, "b", "1", "d")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['substitute("a", 2, "1", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['substitute("a", "b", "1", 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']) substitute('', '', '', '')->assert_equal('') enddef def Test_swapinfo() - CheckDefAndScriptFailure(['swapinfo({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['swapinfo({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) call swapinfo('x')->assert_equal({error: 'Cannot open file'}) call swapinfo('')->assert_equal({error: 'Cannot open file'}) enddef def Test_swapname() - CheckDefAndScriptFailure(['swapname([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['swapname([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) assert_fails('swapname("NonExistingBuf")', 'E94:') enddef @@ -3817,46 +3823,46 @@ def Test_synID() setline(1, "text") synID(1, 1, true)->assert_equal(0) bwipe! - CheckDefAndScriptFailure(['synID(0z10, 1, true)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['synID("a", true, false)'], ['E1013: Argument 2: type mismatch, expected number but got bool', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['synID(1, 1, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) - CheckDefExecAndScriptFailure(['synID("", 10, true)'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['synID(0z10, 1, true)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['synID("a", true, false)'], ['E1013: Argument 2: type mismatch, expected number but got bool', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['synID(1, 1, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3']) + v9.CheckDefExecAndScriptFailure(['synID("", 10, true)'], 'E1209: Invalid value for a line number') enddef def Test_synIDattr() - CheckDefAndScriptFailure(['synIDattr("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['synIDattr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['synIDattr(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['synIDattr("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['synIDattr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['synIDattr(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) synIDattr(1, '', '')->assert_equal('') enddef def Test_synIDtrans() - CheckDefAndScriptFailure(['synIDtrans("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['synIDtrans("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_synconcealed() - CheckDefAndScriptFailure(['synconcealed(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['synconcealed(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['synconcealed(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['synconcealed(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) if has('conceal') - CheckDefExecAndScriptFailure(['synconcealed("", 4)'], 'E1209: Invalid value for a line number') + v9.CheckDefExecAndScriptFailure(['synconcealed("", 4)'], 'E1209: Invalid value for a line number') endif enddef def Test_synstack() - CheckDefAndScriptFailure(['synstack(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['synstack(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefExecAndScriptFailure(['synstack("", 4)'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['synstack(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['synstack(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefExecAndScriptFailure(['synstack("", 4)'], 'E1209: Invalid value for a line number') enddef def Test_system() - CheckDefAndScriptFailure(['system(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['system("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 2']) + v9.CheckDefAndScriptFailure(['system(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['system("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 2']) assert_equal("123\n", system('echo 123')) enddef def Test_systemlist() - CheckDefAndScriptFailure(['systemlist(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['systemlist("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 2']) + v9.CheckDefAndScriptFailure(['systemlist(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['systemlist("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict', 'E1224: String, Number or List required for argument 2']) if has('win32') call assert_equal(["123\r"], systemlist('echo 123')) else @@ -3865,137 +3871,137 @@ def Test_systemlist() enddef def Test_tabpagebuflist() - CheckDefAndScriptFailure(['tabpagebuflist("t")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['tabpagebuflist("t")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) assert_equal([bufnr('')], tabpagebuflist()) assert_equal([bufnr('')], tabpagebuflist(1)) enddef def Test_tabpagenr() - CheckDefAndScriptFailure(['tabpagenr(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefExecAndScriptFailure(['tabpagenr("")'], 'E15: Invalid expression') + v9.CheckDefAndScriptFailure(['tabpagenr(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefExecAndScriptFailure(['tabpagenr("")'], 'E15: Invalid expression') assert_equal(1, tabpagenr('$')) assert_equal(1, tabpagenr()) enddef def Test_tabpagewinnr() - CheckDefAndScriptFailure(['tabpagewinnr("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['tabpagewinnr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefExecAndScriptFailure(['tabpagewinnr(1, "")'], 'E15: Invalid expression') + v9.CheckDefAndScriptFailure(['tabpagewinnr("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['tabpagewinnr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefExecAndScriptFailure(['tabpagewinnr(1, "")'], 'E15: Invalid expression') enddef def Test_taglist() - CheckDefAndScriptFailure(['taglist([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['taglist("a", [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['taglist([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['taglist("a", [2])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) taglist('')->assert_equal(0) taglist('', '')->assert_equal(0) enddef def Test_term_dumpload() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_dumpload({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['term_dumpload({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['term_dumpload("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) - CheckDefExecAndScriptFailure(['term_dumpload("")'], 'E485: Can''t read file') + v9.CheckDefAndScriptFailure(['term_dumpload({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['term_dumpload({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['term_dumpload("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefExecAndScriptFailure(['term_dumpload("")'], 'E485: Can''t read file') enddef def Test_term_dumpdiff() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_dumpdiff(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['term_dumpdiff("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['term_dumpdiff("a", "b", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) - CheckDefExecAndScriptFailure(['term_dumpdiff("", "")'], 'E485: Can''t read file') + v9.CheckDefAndScriptFailure(['term_dumpdiff(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['term_dumpdiff("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['term_dumpdiff("a", "b", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefExecAndScriptFailure(['term_dumpdiff("", "")'], 'E485: Can''t read file') enddef def Test_term_dumpwrite() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_dumpwrite(true, "b")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_dumpwrite(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['term_dumpwrite("a", "b", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['term_dumpwrite(true, "b")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_dumpwrite(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['term_dumpwrite("a", "b", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef def Test_term_getaltscreen() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_getaltscreen(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getaltscreen(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1']) enddef def Test_term_getansicolors() CheckRunVimInTerminal CheckFeature termguicolors - CheckDefAndScriptFailure(['term_getansicolors(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getansicolors(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) enddef def Test_term_getattr() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_getattr("x", "a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['term_getattr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['term_getattr("x", "a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getattr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) enddef def Test_term_getcursor() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_getcursor({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getcursor({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1220: String or Number required for argument 1']) enddef def Test_term_getjob() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_getjob(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getjob(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) enddef def Test_term_getline() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_getline(1.1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_getline(1, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['term_getline(1.1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getline(1, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2']) enddef def Test_term_getscrolled() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_getscrolled(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getscrolled(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) enddef def Test_term_getsize() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_getsize(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getsize(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) enddef def Test_term_getstatus() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_getstatus(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_getstatus(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) enddef def Test_term_gettitle() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_gettitle(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_gettitle(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) enddef def Test_term_gettty() if !has('terminal') CheckFeature terminal else - var buf = Run_shell_in_terminal({}) + var buf = g:Run_shell_in_terminal({}) term_gettty(buf, true)->assert_notequal('') - StopShellInTerminal(buf) + g:StopShellInTerminal(buf) endif - CheckDefAndScriptFailure(['term_gettty([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_gettty(1, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['term_gettty([1])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_gettty(1, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2']) enddef def Test_term_scrape() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_scrape(1.1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_scrape(1, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2']) + v9.CheckDefAndScriptFailure(['term_scrape(1.1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_scrape(1, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2']) enddef def Test_term_sendkeys() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_sendkeys([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_sendkeys(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['term_sendkeys([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_sendkeys(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) enddef def Test_term_setansicolors() CheckRunVimInTerminal if has('termguicolors') || has('gui') - CheckDefAndScriptFailure(['term_setansicolors([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_setansicolors(10, {})'], ['E1013: Argument 2: type mismatch, expected list but got dict', 'E1211: List required for argument 2']) + v9.CheckDefAndScriptFailure(['term_setansicolors([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_setansicolors(10, {})'], ['E1013: Argument 2: type mismatch, expected list but got dict', 'E1211: List required for argument 2']) else throw 'Skipped: Only works with termguicolors or gui feature' endif @@ -4003,27 +4009,27 @@ enddef def Test_term_setapi() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_setapi([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_setapi(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['term_setapi([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_setapi(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) enddef def Test_term_setkill() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_setkill([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_setkill(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['term_setkill([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_setkill(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) enddef def Test_term_setrestore() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_setrestore([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_setrestore(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['term_setrestore([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_setrestore(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) enddef def Test_term_setsize() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_setsize(1.1, 2, 3)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_setsize(1, "2", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['term_setsize(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['term_setsize(1.1, 2, 3)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_setsize(1, "2", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['term_setsize(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) enddef def Test_term_start() @@ -4036,94 +4042,94 @@ def Test_term_start() winnr()->assert_equal(winnr) bwipe! endif - CheckDefAndScriptFailure(['term_start({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) - CheckDefAndScriptFailure(['term_start([], [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) - CheckDefAndScriptFailure(['term_start("", "")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) - CheckDefExecAndScriptFailure(['term_start("")'], 'E474: Invalid argument') + v9.CheckDefAndScriptFailure(['term_start({})'], ['E1013: Argument 1: type mismatch, expected string but got dict', 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['term_start([], [])'], ['E1013: Argument 2: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 2']) + v9.CheckDefAndScriptFailure(['term_start("", "")'], ['E1013: Argument 2: type mismatch, expected dict but got string', 'E1206: Dictionary required for argument 2']) + v9.CheckDefExecAndScriptFailure(['term_start("")'], 'E474: Invalid argument') enddef def Test_term_wait() CheckRunVimInTerminal - CheckDefAndScriptFailure(['term_wait(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) - CheckDefAndScriptFailure(['term_wait(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['term_wait(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1']) + v9.CheckDefAndScriptFailure(['term_wait(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_test_alloc_fail() - CheckDefAndScriptFailure(['test_alloc_fail("a", 10, 20)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['test_alloc_fail(10, "b", 20)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['test_alloc_fail(10, 20, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['test_alloc_fail("a", 10, 20)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['test_alloc_fail(10, "b", 20)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['test_alloc_fail(10, 20, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) enddef def Test_test_feedinput() - CheckDefAndScriptFailure(['test_feedinput(test_void())'], ['E1013: Argument 1: type mismatch, expected string but got void', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['test_feedinput(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['test_feedinput(test_void())'], ['E1013: Argument 1: type mismatch, expected string but got void', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['test_feedinput(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_test_getvalue() - CheckDefAndScriptFailure(['test_getvalue(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['test_getvalue(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1']) enddef def Test_test_gui_drop_files() CheckGui - CheckDefAndScriptFailure(['test_gui_drop_files("a", 1, 1, 0)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['test_gui_drop_files(["x"], "", 1, 0)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['test_gui_drop_files(["x"], 1, "", 0)'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['test_gui_drop_files(["x"], 1, 1, "")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['test_gui_drop_files("a", 1, 1, 0)'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['test_gui_drop_files(["x"], "", 1, 0)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['test_gui_drop_files(["x"], 1, "", 0)'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['test_gui_drop_files(["x"], 1, 1, "")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) enddef def Test_test_gui_mouse_event() CheckGui - CheckDefAndScriptFailure(['test_gui_mouse_event(1.1, 1, 1, 1, 1)'], ['E1013: Argument 1: type mismatch, expected number but got float', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['test_gui_mouse_event(1, "1", 1, 1, 1)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['test_gui_mouse_event(1, 1, "1", 1, 1)'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) - CheckDefAndScriptFailure(['test_gui_mouse_event(1, 1, 1, "1", 1)'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) - CheckDefAndScriptFailure(['test_gui_mouse_event(1, 1, 1, 1, "1")'], ['E1013: Argument 5: type mismatch, expected number but got string', 'E1210: Number required for argument 5']) + v9.CheckDefAndScriptFailure(['test_gui_mouse_event(1.1, 1, 1, 1, 1)'], ['E1013: Argument 1: type mismatch, expected number but got float', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['test_gui_mouse_event(1, "1", 1, 1, 1)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['test_gui_mouse_event(1, 1, "1", 1, 1)'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['test_gui_mouse_event(1, 1, 1, "1", 1)'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4']) + v9.CheckDefAndScriptFailure(['test_gui_mouse_event(1, 1, 1, 1, "1")'], ['E1013: Argument 5: type mismatch, expected number but got string', 'E1210: Number required for argument 5']) enddef def Test_test_ignore_error() - CheckDefAndScriptFailure(['test_ignore_error([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['test_ignore_error([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) test_ignore_error('RESET') enddef def Test_test_option_not_set() - CheckDefAndScriptFailure(['test_option_not_set([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['test_option_not_set([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) enddef def Test_test_override() - CheckDefAndScriptFailure(['test_override(1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['test_override("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['test_override(1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['test_override("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_test_scrollbar() CheckGui - CheckDefAndScriptFailure(['test_scrollbar(1, 2, 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['test_scrollbar("a", "b", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['test_scrollbar("a", 2, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['test_scrollbar(1, 2, 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['test_scrollbar("a", "b", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['test_scrollbar("a", 2, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) enddef def Test_test_setmouse() - CheckDefAndScriptFailure(['test_setmouse("a", 10)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['test_setmouse(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['test_setmouse("a", 10)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['test_setmouse(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_test_settime() - CheckDefAndScriptFailure(['test_settime([1])'], ['E1013: Argument 1: type mismatch, expected number but got list', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['test_settime([1])'], ['E1013: Argument 1: type mismatch, expected number but got list', 'E1210: Number required for argument 1']) enddef def Test_test_srand_seed() - CheckDefAndScriptFailure(['test_srand_seed([1])'], ['E1013: Argument 1: type mismatch, expected number but got list', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['test_srand_seed("10")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['test_srand_seed([1])'], ['E1013: Argument 1: type mismatch, expected number but got list', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['test_srand_seed("10")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_timer_info() - CheckDefAndScriptFailure(['timer_info("id")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['timer_info("id")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) assert_equal([], timer_info(100)) assert_equal([], timer_info()) enddef def Test_timer_pause() - CheckDefAndScriptFailure(['timer_pause("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['timer_pause(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2']) + v9.CheckDefAndScriptFailure(['timer_pause("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['timer_pause(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2']) enddef def Test_timer_paused() @@ -4135,31 +4141,31 @@ def Test_timer_paused() enddef def Test_timer_start() - CheckDefAndScriptFailure(['timer_start("a", "1")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['timer_start(1, "1", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) - CheckDefExecAndScriptFailure(['timer_start(100, 0)'], 'E921:') - CheckDefExecAndScriptFailure(['timer_start(100, "")'], 'E921:') + v9.CheckDefAndScriptFailure(['timer_start("a", "1")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['timer_start(1, "1", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefExecAndScriptFailure(['timer_start(100, 0)'], 'E921:') + v9.CheckDefExecAndScriptFailure(['timer_start(100, "")'], 'E921:') enddef def Test_timer_stop() - CheckDefAndScriptFailure(['timer_stop("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['timer_stop("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) assert_equal(0, timer_stop(100)) enddef def Test_tolower() - CheckDefAndScriptFailure(['tolower(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['tolower(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) tolower('')->assert_equal('') enddef def Test_toupper() - CheckDefAndScriptFailure(['toupper(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['toupper(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) toupper('')->assert_equal('') enddef def Test_tr() - CheckDefAndScriptFailure(['tr(1, "a", "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['tr("a", 1, "b")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['tr("a", "a", 1)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['tr(1, "a", "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['tr("a", 1, "b")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['tr("a", "a", 1)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) tr('', '', '')->assert_equal('') tr('ab', '', '')->assert_equal('ab') assert_fails("tr('ab', 'ab', '')", 'E475:') @@ -4167,9 +4173,9 @@ def Test_tr() enddef def Test_trim() - CheckDefAndScriptFailure(['trim(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefAndScriptFailure(['trim("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) - CheckDefAndScriptFailure(['trim("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) + v9.CheckDefAndScriptFailure(['trim(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['trim("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected string but got list', 'E1174: String required for argument 2']) + v9.CheckDefAndScriptFailure(['trim("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) trim('')->assert_equal('') trim('', '')->assert_equal('') enddef @@ -4190,27 +4196,27 @@ def Test_typename() enddef def Test_undofile() - CheckDefAndScriptFailure(['undofile(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) + v9.CheckDefAndScriptFailure(['undofile(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']) assert_equal('.abc.un~', fnamemodify(undofile('abc'), ':t')) undofile('')->assert_equal('') enddef def Test_uniq() - CheckDefAndScriptFailure(['uniq("a")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) - CheckDefAndScriptFailure(['uniq([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['uniq("a")'], ['E1013: Argument 1: type mismatch, expected list but got string', 'E1211: List required for argument 1']) + v9.CheckDefAndScriptFailure(['uniq([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) - CheckDefFailure(['var l: list = uniq(["a", "b"])'], 'E1012: Type mismatch; expected list but got list') + v9.CheckDefFailure(['var l: list = uniq(["a", "b"])'], 'E1012: Type mismatch; expected list but got list') enddef def Test_values() - CheckDefAndScriptFailure(['values([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['values([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) assert_equal([], {}->values()) assert_equal(['sun'], {star: 'sun'}->values()) enddef def Test_virtcol() - CheckDefAndScriptFailure(['virtcol(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1222: String or List required for argument 1']) - CheckDefExecAndScriptFailure(['virtcol("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['virtcol(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1222: String or List required for argument 1']) + v9.CheckDefExecAndScriptFailure(['virtcol("")'], 'E1209: Invalid value for a line number') new setline(1, ['abcdefgh']) cursor(1, 4) @@ -4222,8 +4228,8 @@ def Test_virtcol() enddef def Test_visualmode() - CheckDefAndScriptFailure(['visualmode("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) - CheckDefAndScriptFailure(['visualmode(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['visualmode("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1']) + v9.CheckDefAndScriptFailure(['visualmode(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1']) enddef def Test_win_execute() @@ -4231,67 +4237,67 @@ def Test_win_execute() assert_equal("\n" .. winnr(), 'echo winnr()'->win_execute(win_getid())) assert_equal("\n" .. winnr(), win_execute(win_getid(), 'echo winnr()', 'silent')) assert_equal('', win_execute(342343, 'echo winnr()')) - CheckDefAndScriptFailure(['win_execute("a", "b", "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['win_execute(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1222: String or List required for argument 2']) - CheckDefAndScriptFailure(['win_execute(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) + v9.CheckDefAndScriptFailure(['win_execute("a", "b", "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_execute(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1222: String or List required for argument 2']) + v9.CheckDefAndScriptFailure(['win_execute(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']) enddef def Test_win_findbuf() - CheckDefAndScriptFailure(['win_findbuf("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_findbuf("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) assert_equal([], win_findbuf(1000)) assert_equal([win_getid()], win_findbuf(bufnr(''))) enddef def Test_win_getid() - CheckDefAndScriptFailure(['win_getid(".")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['win_getid(1, ".")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['win_getid(".")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_getid(1, ".")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) assert_equal(win_getid(), win_getid(1, 1)) enddef def Test_win_gettype() - CheckDefAndScriptFailure(['win_gettype("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_gettype("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_win_gotoid() - CheckDefAndScriptFailure(['win_gotoid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_gotoid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_win_id2tabwin() - CheckDefAndScriptFailure(['win_id2tabwin("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_id2tabwin("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_win_id2win() - CheckDefAndScriptFailure(['win_id2win("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_id2win("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_win_screenpos() - CheckDefAndScriptFailure(['win_screenpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_screenpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_win_splitmove() split win_splitmove(1, 2, {vertical: true, rightbelow: true}) close - CheckDefAndScriptFailure(['win_splitmove("a", 2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['win_splitmove(1, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) - CheckDefAndScriptFailure(['win_splitmove(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) + v9.CheckDefAndScriptFailure(['win_splitmove("a", 2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['win_splitmove(1, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['win_splitmove(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 3']) enddef def Test_winbufnr() - CheckDefAndScriptFailure(['winbufnr("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['winbufnr("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_winheight() - CheckDefAndScriptFailure(['winheight("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['winheight("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_winlayout() - CheckDefAndScriptFailure(['winlayout("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['winlayout("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_winnr() - CheckDefAndScriptFailure(['winnr([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) - CheckDefExecAndScriptFailure(['winnr("")'], 'E15: Invalid expression') + v9.CheckDefAndScriptFailure(['winnr([])'], ['E1013: Argument 1: type mismatch, expected string but got list', 'E1174: String required for argument 1']) + v9.CheckDefExecAndScriptFailure(['winnr("")'], 'E15: Invalid expression') assert_equal(1, winnr()) assert_equal(1, winnr('$')) enddef @@ -4306,7 +4312,7 @@ def Test_winrestcmd() enddef def Test_winrestview() - CheckDefAndScriptFailure(['winrestview([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) + v9.CheckDefAndScriptFailure(['winrestview([])'], ['E1013: Argument 1: type mismatch, expected dict but got list', 'E1206: Dictionary required for argument 1']) :%d _ setline(1, 'Hello World') winrestview({lnum: 1, col: 6}) @@ -4319,20 +4325,20 @@ def Test_winsaveview() var lines =<< trim END var view: list = winsaveview() END - CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list but got dict', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list but got dict', 1) enddef def Test_winwidth() - CheckDefAndScriptFailure(['winwidth("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['winwidth("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) enddef def Test_xor() - CheckDefAndScriptFailure(['xor("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) - CheckDefAndScriptFailure(['xor(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) + v9.CheckDefAndScriptFailure(['xor("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1']) + v9.CheckDefAndScriptFailure(['xor(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2']) enddef def Test_writefile() - CheckDefExecAndScriptFailure(['writefile(["a"], "")'], 'E482: Can''t create file ') + v9.CheckDefExecAndScriptFailure(['writefile(["a"], "")'], 'E482: Can''t create file ') enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index cfbac9aaf..92c86d8c3 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1,7 +1,7 @@ " Test commands that are not compiled in a :def function source check.vim -source vim9.vim +import './vim9.vim' as v9 source term_util.vim source view_util.vim @@ -12,7 +12,7 @@ def Test_vim9cmd() vim9c assert_equal(123, x) vim9cm assert_equal('yes', y) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_fails('vim9cmd', 'E1164:') assert_fails('legacy', 'E1234:') @@ -22,7 +22,7 @@ def Test_vim9cmd() let str = 'con' vim9cmd str .= 'cat' END - CheckScriptFailure(lines, 'E492:') + v9.CheckScriptFailure(lines, 'E492:') lines =<< trim END vim9script @@ -30,7 +30,7 @@ def Test_vim9cmd() legacy let str = 'con' legacy let str .= 'cat' END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -39,7 +39,7 @@ def Test_vim9cmd() enddef nmap ,; :vim9cmd Foo() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) feedkeys(',;', 'xt') assert_equal("bar", g:found_bar) @@ -50,23 +50,23 @@ def Test_vim9cmd() vim9script legacy echo 1'000 END - CheckScriptFailure(lines, 'E115:') + v9.CheckScriptFailure(lines, 'E115:') if has('float') lines =<< trim END vim9script echo .10 END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9cmd echo .10 END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script legacy echo .10 END - CheckScriptFailure(lines, 'E15:') + v9.CheckScriptFailure(lines, 'E15:') endif echo v:version @@ -75,12 +75,12 @@ def Test_vim9cmd() vim9script echo version END - CheckScriptFailure(lines, 'E121:') + v9.CheckScriptFailure(lines, 'E121:') lines =<< trim END vim9script legacy echo version END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_edit_wildcards() @@ -99,8 +99,8 @@ def Test_edit_wildcards() edit X`=filename`xx`=filenr`yy assert_equal('XXtestxx77yy', bufname()) - CheckDefFailure(['edit `=xxx`'], 'E1001:') - CheckDefFailure(['edit `="foo"'], 'E1083:') + v9.CheckDefFailure(['edit `=xxx`'], 'E1001:') + v9.CheckDefFailure(['edit `="foo"'], 'E1083:') var files = ['file 1', 'file%2', 'file# 3'] args `=files` @@ -179,7 +179,7 @@ def Test_expand_alternate_file() bwipe! altfoo bwipe! bar END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_global_backtick_expansion() @@ -221,7 +221,7 @@ def Test_folddo_backtick_expansion() enddef call Test() END - CheckScriptFailure(lines, 'E15: Invalid expression: "`=g:val`"') + v9.CheckScriptFailure(lines, 'E15: Invalid expression: "`=g:val`"') enddef def Test_hardcopy_wildcards() @@ -257,7 +257,7 @@ def Test_echo_linebreak() redir END assert_equal("\nonetwo", @a) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -268,7 +268,7 @@ def Test_echo_linebreak() redir END assert_equal("\n66", @a) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_condition_types() @@ -276,21 +276,21 @@ def Test_condition_types() if 'text' endif END - CheckDefAndScriptFailure(lines, 'E1135:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1135:', 1) lines =<< trim END if [1] endif END - CheckDefFailure(lines, 'E1012:', 1) - CheckScriptFailure(['vim9script'] + lines, 'E745:', 2) + v9.CheckDefFailure(lines, 'E1012:', 1) + v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 2) lines =<< trim END g:cond = 'text' if g:cond endif END - CheckDefExecAndScriptFailure(lines, 'E1135:', 2) + v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 2) lines =<< trim END g:cond = 0 @@ -298,7 +298,7 @@ def Test_condition_types() elseif 'text' endif END - CheckDefAndScriptFailure(lines, 'E1135:', 3) + v9.CheckDefAndScriptFailure(lines, 'E1135:', 3) lines =<< trim END g:cond = 0 @@ -306,7 +306,7 @@ def Test_condition_types() elseif 'text' garbage endif END - CheckDefAndScriptFailure(lines, 'E488:', 3) + v9.CheckDefAndScriptFailure(lines, 'E488:', 3) lines =<< trim END g:cond = 0 @@ -314,8 +314,8 @@ def Test_condition_types() elseif [1] endif END - CheckDefFailure(lines, 'E1012:', 3) - CheckScriptFailure(['vim9script'] + lines, 'E745:', 4) + v9.CheckDefFailure(lines, 'E1012:', 3) + v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 4) lines =<< trim END g:cond = 'text' @@ -323,28 +323,28 @@ def Test_condition_types() elseif g:cond endif END - CheckDefExecAndScriptFailure(lines, 'E1135:', 3) + v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 3) lines =<< trim END while 'text' endwhile END - CheckDefFailure(lines, 'E1012:', 1) - CheckScriptFailure(['vim9script'] + lines, 'E1135:', 2) + v9.CheckDefFailure(lines, 'E1012:', 1) + v9.CheckScriptFailure(['vim9script'] + lines, 'E1135:', 2) lines =<< trim END while [1] endwhile END - CheckDefFailure(lines, 'E1012:', 1) - CheckScriptFailure(['vim9script'] + lines, 'E745:', 2) + v9.CheckDefFailure(lines, 'E1012:', 1) + v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 2) lines =<< trim END g:cond = 'text' while g:cond endwhile END - CheckDefExecAndScriptFailure(lines, 'E1135:', 2) + v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 2) enddef def Test_if_linebreak() @@ -357,7 +357,7 @@ def Test_if_linebreak() endif assert_equal(42, g:res) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) unlet g:res lines =<< trim END @@ -372,7 +372,7 @@ def Test_if_linebreak() endif assert_equal(12, g:res) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) unlet g:res enddef @@ -387,7 +387,7 @@ def Test_while_linebreak() endwhile assert_equal(16, nr) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -403,7 +403,7 @@ def Test_while_linebreak() endwhile assert_equal(16, nr) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_for_linebreak() @@ -417,7 +417,7 @@ def Test_for_linebreak() endfor assert_equal(10, nr) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -433,10 +433,10 @@ def Test_for_linebreak() endfor assert_equal(10, nr) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef -def MethodAfterLinebreak(arg: string) +def s:MethodAfterLinebreak(arg: string) arg ->setline(1) enddef @@ -455,7 +455,7 @@ def Test_method_call_linebreak() 3]->RetArg() assert_equal([1, 2, 3], res) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END new @@ -466,7 +466,7 @@ def Test_method_call_linebreak() assert_equal(['1', '2'], getline(1, 2)) bwipe! END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END new @@ -484,7 +484,7 @@ def Test_method_call_linebreak() assert_equal('the text', getline(1)) bwipe! END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END new @@ -495,7 +495,7 @@ def Test_method_call_linebreak() bwipe! END g:shortlist = [1, 2] - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) unlet g:shortlist new @@ -516,7 +516,7 @@ def Test_method_call_linebreak() Foo->Bar() ->setline(1) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_equal('# some text', getline(1)) bwipe! enddef @@ -532,7 +532,7 @@ def Test_method_call_whitespace() assert_equal(['text', 'text', 'text', 'text'], getline(1, 4)) bwipe! END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_method_and_user_command() @@ -559,7 +559,7 @@ def Test_method_and_user_command() enddef InDefFunc() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_option_use_linebreak() @@ -575,7 +575,7 @@ def Test_option_use_linebreak() assert_equal(['(:)', '[:]', '{:}'], getline(1, '$')) bwipe! END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_use_register() @@ -591,46 +591,46 @@ def Test_use_register() assert_equal(['one', 'two', 'three'], getline(1, '$')) bwipe! END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END @a = 'echo "text"' @a END - CheckDefAndScriptFailure(lines, 'E1207:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) lines =<< trim END @/ = 'pattern' @/ END - CheckDefAndScriptFailure(lines, 'E1207:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) lines =<< trim END &opfunc = 'nothing' &opfunc END - CheckDefAndScriptFailure(lines, 'E1207:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) &opfunc = '' lines =<< trim END &l:showbreak = 'nothing' &l:showbreak END - CheckDefAndScriptFailure(lines, 'E1207:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) &l:showbreak = '' lines =<< trim END &g:showbreak = 'nothing' &g:showbreak END - CheckDefAndScriptFailure(lines, 'E1207:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) &g:showbreak = '' lines =<< trim END $SomeEnv = 'value' $SomeEnv END - CheckDefAndScriptFailure(lines, 'E1207:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) $SomeEnv = '' enddef @@ -647,7 +647,7 @@ def Test_environment_use_linebreak() assert_equal(['one', 'two', 'three'], getline(1, '$')) bwipe! END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_skipped_expr_linebreak() @@ -671,7 +671,7 @@ def Test_dict_member() test.data->sort() assert_equal({data: [1, 2, 3]}, test) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_bar_after_command() @@ -680,14 +680,14 @@ def Test_bar_after_command() redraw | echo x enddef RedrawAndEcho() - assert_match('did redraw', Screenline(&lines)) + assert_match('did redraw', g:Screenline(&lines)) def CallAndEcho() var x = 'did redraw' reg_executing() | echo x enddef CallAndEcho() - assert_match('did redraw', Screenline(&lines)) + assert_match('did redraw', g:Screenline(&lines)) if has('unix') # bar in filter write command does not start new command @@ -729,15 +729,15 @@ def Test_command_modifier_filter() assert_equal(execute('filter /piyo/ registers abc'), expected) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # also do this compiled lines =<< trim END @a = 'very specific z3d37dh234 string' filter z3d37dh234 registers - assert_match('very specific z3d37dh234 string', Screenline(&lines)) + assert_match('very specific z3d37dh234 string', g:Screenline(&lines)) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END edit foobar @@ -747,7 +747,7 @@ def Test_command_modifier_filter() assert_match('"foobar"', g:filter_out) unlet g:filter_out END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_win_command_modifiers() @@ -930,7 +930,7 @@ def Test_bar_line_continuation() unlet g:readExtra unlet g:readMore END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_command_modifier_other() @@ -972,10 +972,10 @@ def Test_command_modifier_other() unlet g:verbose_now enddef -def EchoHere() +def s:EchoHere() echomsg 'here' enddef -def EchoThere() +def s:EchoThere() unsilent echomsg 'there' enddef @@ -1009,21 +1009,21 @@ def Test_modifier_silent_unsilent() assert_equal(11, &history) set history& END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_range_after_command_modifier() - CheckScriptFailure(['vim9script', 'silent keepjump 1d _'], 'E1050: Colon required before a range: 1d _', 2) + v9.CheckScriptFailure(['vim9script', 'silent keepjump 1d _'], 'E1050: Colon required before a range: 1d _', 2) new setline(1, 'xxx') - CheckScriptSuccess(['vim9script', 'silent keepjump :1d _']) + v9.CheckScriptSuccess(['vim9script', 'silent keepjump :1d _']) assert_equal('', getline(1)) bwipe! var lines =<< trim END legacy /pat/ END - CheckDefExecAndScriptFailure(lines, 'E486: Pattern not found: pat') + v9.CheckDefExecAndScriptFailure(lines, 'E486: Pattern not found: pat') enddef def Test_silent_pattern() @@ -1038,50 +1038,50 @@ def Test_useless_command_modifier() if g:maybe silent endif END - CheckDefAndScriptFailure(lines, 'E1176:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1176:', 2) lines =<< trim END for i in [0] silent endfor END - CheckDefFailure(lines, 'E1176:', 2) - CheckScriptSuccess(['vim9script'] + lines) + v9.CheckDefFailure(lines, 'E1176:', 2) + v9.CheckScriptSuccess(['vim9script'] + lines) lines =<< trim END while g:maybe silent endwhile END - CheckDefFailure(lines, 'E1176:', 2) + v9.CheckDefFailure(lines, 'E1176:', 2) g:maybe = false - CheckScriptSuccess(['vim9script'] + lines) + v9.CheckScriptSuccess(['vim9script'] + lines) lines =<< trim END silent try finally endtry END - CheckDefAndScriptFailure(lines, 'E1176:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1176:', 1) lines =<< trim END try silent catch endtry END - CheckDefAndScriptFailure(lines, 'E1176:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1176:', 2) lines =<< trim END try silent finally endtry END - CheckDefAndScriptFailure(lines, 'E1176:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1176:', 2) lines =<< trim END try finally silent endtry END - CheckDefAndScriptFailure(lines, 'E1176:', 3) + v9.CheckDefAndScriptFailure(lines, 'E1176:', 3) enddef def Test_eval_command() @@ -1109,7 +1109,7 @@ def Test_eval_command() assert_equal('yes', g:caught) unlet g:caught END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_map_command() @@ -1117,8 +1117,8 @@ def Test_map_command() nnoremap :echo 'hit F3 #' assert_equal(":echo 'hit F3 #'", maparg("", "n")) END - CheckDefSuccess(lines) - CheckScriptSuccess(['vim9script'] + lines) + v9.CheckDefSuccess(lines) + v9.CheckScriptSuccess(['vim9script'] + lines) enddef def Test_normal_command() @@ -1173,7 +1173,7 @@ def Test_put_command() bwipe! - CheckDefFailure(['put =xxx'], 'E1001:') + v9.CheckDefFailure(['put =xxx'], 'E1001:') enddef def Test_put_with_linebreak() @@ -1183,7 +1183,7 @@ def Test_put_with_linebreak() pu =split('abc', '\zs') ->join() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) getline(2)->assert_equal('a b c') bwipe! enddef @@ -1215,7 +1215,7 @@ def Test_f_args() TestFArgs one two three assert_equal(['one', 'two', 'three'], g:args) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_user_command_comment() @@ -1225,13 +1225,13 @@ def Test_user_command_comment() vim9script Comd # comment END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script Comd# comment END - CheckScriptFailure(lines, 'E1144:') + v9.CheckScriptFailure(lines, 'E1144:') delcommand Comd lines =<< trim END @@ -1239,7 +1239,7 @@ def Test_user_command_comment() command Foo echo 'Foo' Foo3Bar END - CheckScriptFailure(lines, 'E1144: Command "Foo" is not followed by white space: Foo3Bar') + v9.CheckScriptFailure(lines, 'E1144: Command "Foo" is not followed by white space: Foo3Bar') delcommand Foo enddef @@ -1255,7 +1255,7 @@ def Test_star_command() set cpo-=* assert_fails("exe '*s'", 'E1050:') END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_cmd_argument_without_colon() @@ -1276,7 +1276,7 @@ def Test_ambiguous_user_cmd() var lines =<< trim END Cmd END - CheckDefAndScriptFailure(lines, 'E464:', 1) + v9.CheckDefAndScriptFailure(lines, 'E464:', 1) delcommand Cmd1 delcommand Cmd2 enddef @@ -1285,12 +1285,12 @@ def Test_command_not_recognized() var lines =<< trim END d.key = 'asdf' END - CheckDefFailure(lines, 'E1146:', 1) + v9.CheckDefFailure(lines, 'E1146:', 1) lines =<< trim END d['key'] = 'asdf' END - CheckDefFailure(lines, 'E1146:', 1) + v9.CheckDefFailure(lines, 'E1146:', 1) enddef def Test_magic_not_used() @@ -1378,7 +1378,7 @@ def Test_windo_missing_endif() var lines =<< trim END windo if 1 END - CheckDefExecFailure(lines, 'E171:', 1) + v9.CheckDefExecFailure(lines, 'E171:', 1) enddef let s:theList = [1, 2, 3] @@ -1464,26 +1464,26 @@ def Test_lockvar() enddef SetList() END - CheckScriptFailure(lines, 'E1119', 4) + v9.CheckScriptFailure(lines, 'E1119', 4) lines =<< trim END var theList = [1, 2, 3] lockvar theList END - CheckDefFailure(lines, 'E1178', 2) + v9.CheckDefFailure(lines, 'E1178', 2) lines =<< trim END var theList = [1, 2, 3] unlockvar theList END - CheckDefFailure(lines, 'E1178', 2) + v9.CheckDefFailure(lines, 'E1178', 2) lines =<< trim END vim9script var name = 'john' lockvar nameX END - CheckScriptFailure(lines, 'E1246', 3) + v9.CheckScriptFailure(lines, 'E1246', 3) lines =<< trim END vim9script @@ -1493,7 +1493,7 @@ def Test_lockvar() enddef LockIt() END - CheckScriptFailure(lines, 'E1246', 1) + v9.CheckScriptFailure(lines, 'E1246', 1) enddef def Test_substitute_expr() @@ -1520,8 +1520,8 @@ def Test_substitute_expr() bwipe! - CheckDefFailure(['s/from/\="x")/'], 'E488:') - CheckDefFailure(['s/from/\="x"/9'], 'E488:') + v9.CheckDefFailure(['s/from/\="x")/'], 'E488:') + v9.CheckDefFailure(['s/from/\="x"/9'], 'E488:') # When calling a function the right instruction list needs to be restored. g:cond = true @@ -1545,7 +1545,7 @@ def Test_substitute_expr() assert_equal('rep', getline(1)) bwipe! END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) unlet g:cond # List results in multiple lines @@ -1594,14 +1594,14 @@ def Test_redir_to_var() var lines =<< trim END redir => notexist END - CheckDefFailure(lines, 'E1089:') + v9.CheckDefFailure(lines, 'E1089:') lines =<< trim END var ls = 'asdf' redir => ls[1] redir END END - CheckDefFailure(lines, 'E1141:') + v9.CheckDefFailure(lines, 'E1141:') lines =<< trim END var text: string @@ -1610,7 +1610,7 @@ def Test_redir_to_var() redir > Xfile redir END END - CheckDefFailure(lines, 'E1185:') + v9.CheckDefFailure(lines, 'E1185:') lines =<< trim END var text: number @@ -1618,7 +1618,7 @@ def Test_redir_to_var() echo 'hello' redir END END - CheckDefFailure(lines, 'E1012:') + v9.CheckDefFailure(lines, 'E1012:') enddef def Test_echo_void() @@ -1629,7 +1629,7 @@ def Test_echo_void() enddef echo NoReturn() END - CheckScriptFailure(lines, 'E1186:', 5) + v9.CheckScriptFailure(lines, 'E1186:', 5) lines =<< trim END vim9script @@ -1641,7 +1641,7 @@ def Test_echo_void() enddef defcompile END - CheckScriptFailure(lines, 'E1186:', 1) + v9.CheckScriptFailure(lines, 'E1186:', 1) enddef def Test_cmdwin_block() @@ -1661,81 +1661,81 @@ def Test_var_not_cmd() var lines =<< trim END g:notexist:cmd END - CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :cmd', 'E121: Undefined variable: g:notexist'], 1) + v9.CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :cmd', 'E121: Undefined variable: g:notexist'], 1) lines =<< trim END g-pat-cmd END - CheckDefAndScriptFailure(lines, 'E1241:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1241:', 1) lines =<< trim END g.pat.cmd END - CheckDefAndScriptFailure(lines, ['E1001: Variable not found: g', 'E121: Undefined variable: g'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1001: Variable not found: g', 'E121: Undefined variable: g'], 1) lines =<< trim END s:notexist:repl END - CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :repl', 'E121: Undefined variable: s:notexist'], 1) + v9.CheckDefAndScriptFailure(lines, ['E488: Trailing characters: :repl', 'E121: Undefined variable: s:notexist'], 1) lines =<< trim END s-pat-repl END - CheckDefAndScriptFailure(lines, 'E1241:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1241:', 1) lines =<< trim END s.pat.repl END - CheckDefAndScriptFailure(lines, ['E1001: Variable not found: s', 'E121: Undefined variable: s'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1001: Variable not found: s', 'E121: Undefined variable: s'], 1) lines =<< trim END w:notexist->len() END - CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: w:notexist', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: w:notexist', 1) lines =<< trim END b:notexist->len() END - CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: b:notexist', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: b:notexist', 1) lines =<< trim END t:notexist->len() END - CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: t:notexist', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: t:notexist', 1) enddef def Test_no_space_after_command() var lines =<< trim END g /pat/cmd END - CheckDefAndScriptFailure(lines, 'E1242:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1242:', 1) lines =<< trim END g #pat#cmd END - CheckDefAndScriptFailure(lines, 'E1242:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1242:', 1) lines =<< trim END g#pat#cmd END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END g# pat#cmd END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END s /pat/repl END - CheckDefAndScriptFailure(lines, 'E1242:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1242:', 1) lines =<< trim END s #pat#repl END - CheckDefAndScriptFailure(lines, 'E1242:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1242:', 1) lines =<< trim END s#pat#repl END - CheckDefExecAndScriptFailure(lines, 'E486:', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E486:', 1) lines =<< trim END s# pat#repl END - CheckDefExecAndScriptFailure(lines, 'E486:', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E486:', 1) enddef " Test for the 'previewpopup' option diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim index d3330908e..5fbdef82a 100644 --- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -1,9 +1,9 @@ " Test the :disassemble command, and compilation as a side effect source check.vim -source vim9.vim +import './vim9.vim' as v9 -func NotCompiled() +func s:NotCompiled() echo "not" endfunc @@ -312,7 +312,7 @@ def Test_disassemble_push() '2 RETURN void', res) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delete('Xdir', 'rf') &rtp = save_rtp @@ -690,22 +690,22 @@ def Test_disassemble_new() res) enddef -def FuncWithArg(arg: any) +def s:FuncWithArg(arg: any) echo arg enddef -func UserFunc() +func s:UserFunc() echo 'nothing' endfunc -func UserFuncWithArg(arg) +func s:UserFuncWithArg(arg) echo a:arg endfunc def s:ScriptFuncCall(): string changenr() char2nr("abc") - Test_disassemble_new() + g:Test_disassemble_new() FuncWithArg(343) ScriptFuncNew() s:ScriptFuncNew() @@ -728,12 +728,12 @@ def Test_disassemble_call() '\d PUSHS "abc"\_s*' .. '\d BCALL char2nr(argc 1)\_s*' .. '\d DROP\_s*' .. - 'Test_disassemble_new()\_s*' .. + 'g:Test_disassemble_new()\_s*' .. '\d DCALL Test_disassemble_new(argc 0)\_s*' .. '\d DROP\_s*' .. 'FuncWithArg(343)\_s*' .. '\d\+ PUSHNR 343\_s*' .. - '\d\+ DCALL FuncWithArg(argc 1)\_s*' .. + '\d\+ DCALL \d\+_FuncWithArg(argc 1)\_s*' .. '\d\+ DROP\_s*' .. 'ScriptFuncNew()\_s*' .. '\d\+ DCALL \d\+_ScriptFuncNew(argc 0)\_s*' .. @@ -742,11 +742,11 @@ def Test_disassemble_call() '\d\+ DCALL \d\+_ScriptFuncNew(argc 0)\_s*' .. '\d\+ DROP\_s*' .. 'UserFunc()\_s*' .. - '\d\+ UCALL UserFunc(argc 0)\_s*' .. + '\d\+ UCALL <80>R\d\+_UserFunc(argc 0)\_s*' .. '\d\+ DROP\_s*' .. 'UserFuncWithArg("foo")\_s*' .. '\d\+ PUSHS "foo"\_s*' .. - '\d\+ UCALL UserFuncWithArg(argc 1)\_s*' .. + '\d\+ UCALL <80>R\d\+_UserFuncWithArg(argc 1)\_s*' .. '\d\+ DROP\_s*' .. 'var FuncRef = function("UserFunc")\_s*' .. '\d\+ PUSHS "UserFunc"\_s*' .. @@ -811,7 +811,7 @@ enddef def EchoArg(arg: string): string return arg enddef -def RefThis(): func +def s:RefThis(): func return function('EchoArg') enddef def s:ScriptPCall() @@ -822,7 +822,7 @@ def Test_disassemble_pcall() var res = execute('disass s:ScriptPCall') assert_match('\d\+_ScriptPCall\_s*' .. 'RefThis()("text")\_s*' .. - '\d DCALL RefThis(argc 0)\_s*' .. + '\d DCALL \d\+_RefThis(argc 0)\_s*' .. '\d PUSHS "text"\_s*' .. '\d PCALL top (argc 1)\_s*' .. '\d PCALL end\_s*' .. @@ -1116,7 +1116,7 @@ def Test_disassemble_channel() instr) enddef -def WithLambda(): string +def s:WithLambda(): string var F = (a) => "X" .. a .. "X" return F("x") enddef @@ -1149,7 +1149,7 @@ def Test_disassemble_lambda() instr) enddef -def LambdaWithType(): number +def s:LambdaWithType(): number var Ref = (a: number) => a + 10 return Ref(g:value) enddef @@ -1210,7 +1210,7 @@ def Test_disassemble_nested_def_list() instr) enddef -def AndOr(arg: any): string +def s:AndOr(arg: any): string if arg == 1 && arg != 2 || arg == 4 return 'yes' endif @@ -1239,7 +1239,7 @@ def Test_disassemble_and_or() instr) enddef -def AndConstant(arg: any): string +def s:AndConstant(arg: any): string if true && arg return "yes" endif @@ -1271,7 +1271,7 @@ def Test_disassemble_and_constant() instr) enddef -def ForLoop(): list +def s:ForLoop(): list var res: list for i in range(3) res->add(i) @@ -1304,7 +1304,7 @@ def Test_disassemble_for_loop() instr) enddef -def ForLoopEval(): string +def s:ForLoopEval(): string var res = "" for str in eval('["one", "two"]') res ..= str @@ -1340,7 +1340,7 @@ def Test_disassemble_for_loop_eval() instr) enddef -def ForLoopUnpack() +def s:ForLoopUnpack() for [x1, x2] in [[1, 2], [3, 4]] echo x1 x2 endfor @@ -1373,7 +1373,7 @@ def Test_disassemble_for_loop_unpack() instr) enddef -def ForLoopContinue() +def s:ForLoopContinue() for nr in [1, 2] try echo "ok" @@ -1432,7 +1432,7 @@ enddef let g:number = 42 -def TypeCast() +def s:TypeCast() var l: list = [23, g:number] enddef @@ -1450,7 +1450,7 @@ def Test_disassemble_typecast() instr) enddef -def Computing() +def s:Computing() var nr = 3 var nrres = nr + 7 nrres = nr - 7 @@ -1525,7 +1525,7 @@ def Test_disassemble_computing() endif enddef -def AddListBlob() +def s:AddListBlob() var reslist = [1, 2] + [3, 4] var resblob = 0z1122 + 0z3344 enddef @@ -1551,7 +1551,7 @@ def Test_disassemble_add_list_blob() enddef let g:aa = 'aa' -def ConcatString(): string +def s:ConcatString(): string var res = g:aa .. "bb" return res enddef @@ -1569,7 +1569,7 @@ def Test_disassemble_concat() assert_equal('aabb', ConcatString()) enddef -def StringIndex(): string +def s:StringIndex(): string var s = "abcd" var res = s[1] return res @@ -1590,7 +1590,7 @@ def Test_disassemble_string_index() assert_equal('b', StringIndex()) enddef -def StringSlice(): string +def s:StringSlice(): string var s = "abcd" var res = s[1 : 8] return res @@ -1612,7 +1612,7 @@ def Test_disassemble_string_slice() assert_equal('bcd', StringSlice()) enddef -def ListIndex(): number +def s:ListIndex(): number var l = [1, 2, 3] var res = l[1] return res @@ -1636,7 +1636,7 @@ def Test_disassemble_list_index() assert_equal(2, ListIndex()) enddef -def ListSlice(): list +def s:ListSlice(): list var l = [1, 2, 3] var res = l[1 : 8] return res @@ -1661,7 +1661,7 @@ def Test_disassemble_list_slice() assert_equal([2, 3], ListSlice()) enddef -def DictMember(): number +def s:DictMember(): number var d = {item: 1} var res = d.item res = d["item"] @@ -1692,7 +1692,7 @@ def Test_disassemble_dict_member() enddef let somelist = [1, 2, 3, 4, 5] -def AnyIndex(): number +def s:AnyIndex(): number var res = g:somelist[2] return res enddef @@ -1713,7 +1713,7 @@ def Test_disassemble_any_index() assert_equal(3, AnyIndex()) enddef -def AnySlice(): list +def s:AnySlice(): list var res = g:somelist[1 : 3] return res enddef @@ -1735,7 +1735,7 @@ def Test_disassemble_any_slice() assert_equal([2, 3, 4], AnySlice()) enddef -def NegateNumber(): number +def s:NegateNumber(): number g:nr = 9 var plus = +g:nr var minus = -g:nr @@ -1761,7 +1761,7 @@ def Test_disassemble_negate_number() assert_equal(-9, NegateNumber()) enddef -def InvertBool(): bool +def s:InvertBool(): bool var flag = true var invert = !flag var res = !!flag @@ -1786,7 +1786,7 @@ def Test_disassemble_invert_bool() assert_equal(true, InvertBool()) enddef -def ReturnBool(): bool +def s:ReturnBool(): bool var one = 1 var zero = 0 var none: number @@ -1818,7 +1818,7 @@ def Test_disassemble_return_bool() assert_equal(true, InvertBool()) enddef -def AutoInit() +def s:AutoInit() var t: number t = 1 t = 0 diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 6428e6386..d2f69abf7 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1,7 +1,7 @@ " Tests for Vim9 script expressions source check.vim -source vim9.vim +import './vim9.vim' as v9 let g:cond = v:false def FuncOne(arg: number): string @@ -66,7 +66,7 @@ def Test_expr1_trinary() var Z = g:cond ? FuncOne : FuncTwo assert_equal(123, Z(3)) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr1_trinary_vimscript() @@ -77,7 +77,7 @@ def Test_expr1_trinary_vimscript() : 'no' assert_equal('yes', name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:false @@ -85,7 +85,7 @@ def Test_expr1_trinary_vimscript() : 'no' assert_equal('no', name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:false ? @@ -93,7 +93,7 @@ def Test_expr1_trinary_vimscript() 'no' assert_equal('no', name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:false ? # comment @@ -102,48 +102,48 @@ def Test_expr1_trinary_vimscript() 'no' # comment assert_equal('no', name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # check white space lines =<< trim END var name = v:true?1:2 END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''?'' at "?1:2"', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''?'' at "?1:2"', 1) lines =<< trim END var name = v:true? 1 : 2 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END var name = v:true ?1 : 2 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END var name = v:true ? 1: 2 END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after '':'' at ": 2"', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after '':'' at ": 2"', 1) lines =<< trim END var name = v:true ? 1 :2 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END var name = 'x' ? 1 : 2 END - CheckDefAndScriptFailure(lines, 'E1135:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1135:', 1) lines =<< trim END var name = [] ? 1 : 2 END - CheckDefExecAndScriptFailure(lines, 'E745:', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E745:', 1) lines =<< trim END var name = {} ? 1 : 2 END - CheckDefExecAndScriptFailure(lines, 'E728:', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E728:', 1) # check after failure eval_flags is reset lines =<< trim END @@ -153,7 +153,7 @@ def Test_expr1_trinary_vimscript() endtry assert_equal(v:true, eval(string(v:true))) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END try @@ -162,53 +162,53 @@ def Test_expr1_trinary_vimscript() endtry assert_equal(v:true, eval(string(v:true))) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef func Test_expr1_trinary_fails() - call CheckDefAndScriptFailure(["var x = 1 ? 'one'"], "Missing ':' after '?'", 1) + call v9.CheckDefAndScriptFailure(["var x = 1 ? 'one'"], "Missing ':' after '?'", 1) let msg = "White space required before and after '?'" - call CheckDefAndScriptFailure(["var x = 1? 'one' : 'two'"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 ?'one' : 'two'"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1?'one' : 'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1? 'one' : 'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 ?'one' : 'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1?'one' : 'two'"], msg, 1) let lines =<< trim END var x = 1 ?'one' : 'two' # comment END - call CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''?'' at "?''one'' : ''two''"', 2) + call v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''?'' at "?''one'' : ''two''"', 2) let msg = "White space required before and after ':'" - call CheckDefAndScriptFailure(["var x = 1 ? 'one': 'two'"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 ? 'one' :'two'"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 ? 'one':'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 ? 'one': 'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 ? 'one' :'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 ? 'one':'two'"], msg, 1) let lines =<< trim END var x = 1 ? 'one' :'two' # Comment END - call CheckDefAndScriptFailure(lines, 'E1004: White space required before and after '':'' at ":''two''"', 2) + call v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after '':'' at ":''two''"', 2) - call CheckDefAndScriptFailure(["var x = 'x' ? 'one' : 'two'"], 'E1135:', 1) - call CheckDefAndScriptFailure(["var x = 0z1234 ? 'one' : 'two'"], 'E974:', 1) - call CheckDefExecAndScriptFailure(["var x = [] ? 'one' : 'two'"], 'E745:', 1) - call CheckDefExecAndScriptFailure(["var x = {} ? 'one' : 'two'"], 'E728:', 1) + call v9.CheckDefAndScriptFailure(["var x = 'x' ? 'one' : 'two'"], 'E1135:', 1) + call v9.CheckDefAndScriptFailure(["var x = 0z1234 ? 'one' : 'two'"], 'E974:', 1) + call v9.CheckDefExecAndScriptFailure(["var x = [] ? 'one' : 'two'"], 'E745:', 1) + call v9.CheckDefExecAndScriptFailure(["var x = {} ? 'one' : 'two'"], 'E728:', 1) - call CheckDefExecFailure(["var x = false ? "], 'E1097:', 3) - call CheckScriptFailure(['vim9script', "var x = false ? "], 'E15:', 2) - call CheckDefExecFailure(["var x = false ? 'one' : "], 'E1097:', 3) - call CheckScriptFailure(['vim9script', "var x = false ? 'one' : "], 'E15:', 2) + call v9.CheckDefExecFailure(["var x = false ? "], 'E1097:', 3) + call v9.CheckScriptFailure(['vim9script', "var x = false ? "], 'E15:', 2) + call v9.CheckDefExecFailure(["var x = false ? 'one' : "], 'E1097:', 3) + call v9.CheckScriptFailure(['vim9script', "var x = false ? 'one' : "], 'E15:', 2) - call CheckDefExecAndScriptFailure(["var x = true ? xxx : 'foo'"], ['E1001:', 'E121:'], 1) - call CheckDefExecAndScriptFailure(["var x = false ? 'foo' : xxx"], ['E1001:', 'E121:'], 1) + call v9.CheckDefExecAndScriptFailure(["var x = true ? xxx : 'foo'"], ['E1001:', 'E121:'], 1) + call v9.CheckDefExecAndScriptFailure(["var x = false ? 'foo' : xxx"], ['E1001:', 'E121:'], 1) if has('float') - call CheckDefAndScriptFailure(["var x = 0.1 ? 'one' : 'two'"], 'E805:', 1) + call v9.CheckDefAndScriptFailure(["var x = 0.1 ? 'one' : 'two'"], 'E805:', 1) endif " missing argument detected even when common type is used - call CheckDefAndScriptFailure([ + call v9.CheckDefAndScriptFailure([ \ 'var X = FuncOne', \ 'var Y = FuncTwo', \ 'var Z = g:cond ? FuncOne : FuncTwo', @@ -235,21 +235,21 @@ def Test_expr1_falsy() assert_equal(456, 0.0 ?? 456) endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) var msg = "White space required before and after '??'" - call CheckDefAndScriptFailure(["var x = 1?? 'one' : 'two'"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 ??'one' : 'two'"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1??'one' : 'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1?? 'one' : 'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 ??'one' : 'two'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1??'one' : 'two'"], msg, 1) lines =<< trim END var x = 1 ??'one' : 'two' #comment END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''??'' at "??''one'' : ''two''"', 2) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''??'' at "??''one'' : ''two''"', 2) enddef -def Record(val: any): any +def g:Record(val: any): any g:vals->add(val) return val enddef @@ -270,35 +270,35 @@ def Test_expr2() assert_equal(false, 0 || false) g:vals = [] - assert_equal(true, Record(1) || Record(3)) + assert_equal(true, g:Record(1) || g:Record(3)) assert_equal([1], g:vals) g:vals = [] - assert_equal(true, Record(0) || Record(1)) + assert_equal(true, g:Record(0) || g:Record(1)) assert_equal([0, 1], g:vals) g:vals = [] - assert_equal(true, Record(0) || Record(true)) + assert_equal(true, g:Record(0) || g:Record(true)) assert_equal([0, true], g:vals) g:vals = [] - assert_equal(true, Record(0) - || Record(1) - || Record(0)) + assert_equal(true, g:Record(0) + || g:Record(1) + || g:Record(0)) assert_equal([0, 1], g:vals) g:vals = [] - assert_equal(true, Record(0) - || Record(true) - || Record(0)) + assert_equal(true, g:Record(0) + || g:Record(true) + || g:Record(0)) assert_equal([0, true], g:vals) g:vals = [] - assert_equal(true, Record(true) || Record(false)) + assert_equal(true, g:Record(true) || g:Record(false)) assert_equal([true], g:vals) g:vals = [] - assert_equal(false, Record(0) || Record(false) || Record(0)) + assert_equal(false, g:Record(0) || g:Record(false) || g:Record(0)) assert_equal([0, false, 0], g:vals) g:vals = [] @@ -315,7 +315,7 @@ def Test_expr2() endif assert_equal([1], g:vals) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr2_vimscript() @@ -325,7 +325,7 @@ def Test_expr2_vimscript() || 1 assert_equal(true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:false @@ -333,7 +333,7 @@ def Test_expr2_vimscript() || v:false assert_equal(v:true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:false || @@ -341,7 +341,7 @@ def Test_expr2_vimscript() v:false assert_equal(v:true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:false || # comment @@ -351,48 +351,48 @@ def Test_expr2_vimscript() v:false # comment assert_equal(v:true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # check white space lines =<< trim END var name = v:true||v:true END - CheckDefExecAndScriptFailure(lines, 'E1004: White space required before and after ''||'' at "||v:true"', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E1004: White space required before and after ''||'' at "||v:true"', 1) lines =<< trim END var name = v:true ||v:true END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END var name = v:true|| v:true END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) enddef def Test_expr2_fails() var msg = "White space required before and after '||'" - call CheckDefAndScriptFailure(["var x = 1||0"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 ||0"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1|| 0"], msg, 1) + v9.CheckDefAndScriptFailure(["var x = 1||0"], msg, 1) + v9.CheckDefAndScriptFailure(["var x = 1 ||0"], msg, 1) + v9.CheckDefAndScriptFailure(["var x = 1|| 0"], msg, 1) - call CheckDefFailure(["var x = false || "], 'E1097:', 3) - call CheckScriptFailure(['vim9script', "var x = false || "], 'E15:', 2) + v9.CheckDefFailure(["var x = false || "], 'E1097:', 3) + v9.CheckScriptFailure(['vim9script', "var x = false || "], 'E15:', 2) # script does not fail, the second expression is skipped - call CheckDefFailure(["var x = 1 || xxx"], 'E1001:', 1) + v9.CheckDefFailure(["var x = 1 || xxx"], 'E1001:', 1) - call CheckDefAndScriptFailure(["var x = [] || false"], ['E1012:', 'E745:'], 1) + v9.CheckDefAndScriptFailure(["var x = [] || false"], ['E1012:', 'E745:'], 1) - call CheckDefAndScriptFailure(["if 'yes' || 0", 'echo 0', 'endif'], ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool'], 1) + v9.CheckDefAndScriptFailure(["if 'yes' || 0", 'echo 0', 'endif'], ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool'], 1) - call CheckDefAndScriptFailure(["var x = 3 || false"], ['E1012:', 'E1023:'], 1) - call CheckDefAndScriptFailure(["var x = false || 3"], ['E1012:', 'E1023:'], 1) + v9.CheckDefAndScriptFailure(["var x = 3 || false"], ['E1012:', 'E1023:'], 1) + v9.CheckDefAndScriptFailure(["var x = false || 3"], ['E1012:', 'E1023:'], 1) - call CheckDefAndScriptFailure(["if 3"], 'E1023:', 1) - call CheckDefExecAndScriptFailure(['var x = 3', 'if x', 'endif'], 'E1023:', 2) + v9.CheckDefAndScriptFailure(["if 3"], 'E1023:', 1) + v9.CheckDefExecAndScriptFailure(['var x = 3', 'if x', 'endif'], 'E1023:', 2) - call CheckDefAndScriptFailure(["var x = [] || false"], ['E1012: Type mismatch; expected bool but got list', 'E745:'], 1) + v9.CheckDefAndScriptFailure(["var x = [] || false"], ['E1012: Type mismatch; expected bool but got list', 'E745:'], 1) var lines =<< trim END vim9script @@ -400,14 +400,14 @@ def Test_expr2_fails() ||true # comment END - CheckScriptFailure(lines, 'E1004: White space required before and after ''||'' at "||true"', 3) + v9.CheckScriptFailure(lines, 'E1004: White space required before and after ''||'' at "||true"', 3) lines =<< trim END var x = false || false || a.b END - CheckDefFailure(lines, 'E1001:', 3) + v9.CheckDefFailure(lines, 'E1001:', 3) enddef " test && @@ -425,30 +425,30 @@ def Test_expr3() assert_equal(true, 1 && true) g:vals = [] - assert_equal(true, Record(true) && Record(1)) + assert_equal(true, g:Record(true) && g:Record(1)) assert_equal([true, 1], g:vals) g:vals = [] - assert_equal(true, Record(1) && Record(true)) + assert_equal(true, g:Record(1) && g:Record(true)) assert_equal([1, true], g:vals) g:vals = [] - assert_equal(false, Record(0) && Record(1)) + assert_equal(false, g:Record(0) && g:Record(1)) assert_equal([0], g:vals) g:vals = [] - assert_equal(false, Record(0) && Record(1) && Record(0)) + assert_equal(false, g:Record(0) && g:Record(1) && g:Record(0)) assert_equal([0], g:vals) g:vals = [] - assert_equal(false, Record(0) && Record(4) && Record(0)) + assert_equal(false, g:Record(0) && g:Record(4) && g:Record(0)) assert_equal([0], g:vals) g:vals = [] - assert_equal(false, Record(1) && Record(true) && Record(0)) + assert_equal(false, g:Record(1) && g:Record(true) && g:Record(0)) assert_equal([1, true, 0], g:vals) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr3_vimscript() @@ -458,7 +458,7 @@ def Test_expr3_vimscript() && 1 assert_equal(false, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:true @@ -466,7 +466,7 @@ def Test_expr3_vimscript() && v:true assert_equal(v:true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:true && @@ -474,7 +474,7 @@ def Test_expr3_vimscript() v:true assert_equal(v:true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = v:true && # comment @@ -484,62 +484,62 @@ def Test_expr3_vimscript() v:true assert_equal(v:true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # check white space lines =<< trim END var name = v:true&&v:true END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END var name = v:true &&v:true END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''&&'' at "&&v:true"', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''&&'' at "&&v:true"', 1) lines =<< trim END var name = v:true&& v:true END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) enddef def Test_expr3_fails() var msg = "White space required before and after '&&'" - CheckDefAndScriptFailure(["var x = 1&&0"], msg, 1) - CheckDefAndScriptFailure(["var x = 1 &&0"], msg, 1) - CheckDefAndScriptFailure(["var x = 1&& 0"], msg, 1) + v9.CheckDefAndScriptFailure(["var x = 1&&0"], msg, 1) + v9.CheckDefAndScriptFailure(["var x = 1 &&0"], msg, 1) + v9.CheckDefAndScriptFailure(["var x = 1&& 0"], msg, 1) var lines =<< trim END var x = 1 &&0 # comment END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''&&'' at "&&0"', 2) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''&&'' at "&&0"', 2) g:vals = [] - CheckDefAndScriptFailure(["if 'yes' && 0", 'echo 0', 'endif'], ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool'], 1) + v9.CheckDefAndScriptFailure(["if 'yes' && 0", 'echo 0', 'endif'], ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool'], 1) - CheckDefExecAndScriptFailure(['assert_equal(false, Record(1) && Record(4) && Record(0))'], 'E1023: Using a Number as a Bool: 4', 1) + v9.CheckDefExecAndScriptFailure(['assert_equal(false, g:Record(1) && g:Record(4) && g:Record(0))'], 'E1023: Using a Number as a Bool: 4', 1) lines =<< trim END if 3 && true endif END - CheckDefAndScriptFailure(lines, ['E1012:', 'E1023:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1012:', 'E1023:'], 1) lines =<< trim END if true && 3 endif END - CheckDefAndScriptFailure(lines, ['E1012:', 'E1023:'], 2) + v9.CheckDefAndScriptFailure(lines, ['E1012:', 'E1023:'], 2) lines =<< trim END if 'yes' && true endif END - CheckDefAndScriptFailure(lines, ['E1012:', 'E1135: Using a String as a Bool'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1012:', 'E1135: Using a String as a Bool'], 1) enddef " global variables to use for tests with the "any" type @@ -663,18 +663,18 @@ def Test_expr4_equal() assert_equal(true, OneFunc('abc') == TwoFunc('123')) endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(["var x = 'a' == xxx"], ['E1001:', 'E121:'], 1) - CheckDefFailure(["var x = 'a' == "], 'E1097:', 3) - CheckScriptFailure(['vim9script', "var x = 'a' == "], 'E15:', 2) + v9.CheckDefAndScriptFailure(["var x = 'a' == xxx"], ['E1001:', 'E121:'], 1) + v9.CheckDefFailure(["var x = 'a' == "], 'E1097:', 3) + v9.CheckScriptFailure(['vim9script', "var x = 'a' == "], 'E15:', 2) - CheckDefExecAndScriptFailure(['var items: any', 'eval 1 + 1', 'eval 2 + 2', 'if items == []', 'endif'], ['E691:', 'E1072:'], 4) + v9.CheckDefExecAndScriptFailure(['var items: any', 'eval 1 + 1', 'eval 2 + 2', 'if items == []', 'endif'], ['E691:', 'E1072:'], 4) - CheckDefExecAndScriptFailure(['var x: any = "a"', 'echo x == true'], 'E1072: Cannot compare string with bool', 2) - CheckDefExecAndScriptFailure(["var x: any = true", 'echo x == ""'], 'E1072: Cannot compare bool with string', 2) - CheckDefExecAndScriptFailure(["var x: any = 99", 'echo x == true'], ['E1138', 'E1072:'], 2) - CheckDefExecAndScriptFailure(["var x: any = 'a'", 'echo x == 99'], ['E1030:', 'E1072:'], 2) + v9.CheckDefExecAndScriptFailure(['var x: any = "a"', 'echo x == true'], 'E1072: Cannot compare string with bool', 2) + v9.CheckDefExecAndScriptFailure(["var x: any = true", 'echo x == ""'], 'E1072: Cannot compare bool with string', 2) + v9.CheckDefExecAndScriptFailure(["var x: any = 99", 'echo x == true'], ['E1138', 'E1072:'], 2) + v9.CheckDefExecAndScriptFailure(["var x: any = 'a'", 'echo x == 99'], ['E1030:', 'E1072:'], 2) lines =<< trim END vim9script @@ -686,7 +686,7 @@ def Test_expr4_equal() g:notReached = true Compare() END - CheckScriptFailure(lines, 'E1030: Using a String as a Number: "3"') + v9.CheckScriptFailure(lines, 'E1030: Using a String as a Number: "3"') assert_true(g:notReached) if has('float') @@ -700,7 +700,7 @@ def Test_expr4_equal() g:notReached = true Compare() END - CheckScriptFailure(lines, 'E892: Using a String as a Float') + v9.CheckScriptFailure(lines, 'E892: Using a String as a Float') assert_true(g:notReached) endif @@ -709,30 +709,30 @@ enddef def Test_expr4_wrong_type() for op in ['>', '>=', '<', '<=', '=~', '!~'] - CheckDefExecAndScriptFailure([ + v9.CheckDefExecAndScriptFailure([ "var a: any = 'a'", 'var b: any = true', 'echo a ' .. op .. ' b'], 'E1072:', 3) endfor for op in ['>', '>=', '<', '<='] - CheckDefExecAndScriptFailure([ + v9.CheckDefExecAndScriptFailure([ "var n: any = 2", 'echo n ' .. op .. ' "3"'], ['E1030:', 'E1072:'], 2) endfor for op in ['=~', '!~'] - CheckDefExecAndScriptFailure([ + v9.CheckDefExecAndScriptFailure([ "var n: any = 2", 'echo n ' .. op .. ' "3"'], 'E1072:', 2) endfor - CheckDefAndScriptFailure([ + v9.CheckDefAndScriptFailure([ 'echo v:none == true'], 'E1072:', 1) - CheckDefAndScriptFailure([ + v9.CheckDefAndScriptFailure([ 'echo false >= true'], 'E1072:', 1) - CheckDefExecAndScriptFailure([ + v9.CheckDefExecAndScriptFailure([ "var n: any = v:none", 'echo n == true'], 'E1072:', 2) - CheckDefExecAndScriptFailure([ + v9.CheckDefExecAndScriptFailure([ "var n: any = v:none", 'echo n < true'], 'E1072:', 2) enddef @@ -819,7 +819,7 @@ def Test_expr4_notequal() assert_equal(true, function('g:Test_expr4_equal', [123]) != function('g:Test_expr4_is', [123])) assert_equal(true, function('g:Test_expr4_equal', [123]) != function('g:Test_expr4_equal', [999])) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test > comperator @@ -845,7 +845,7 @@ def Test_expr4_greater() assert_false(ff > 3.0) endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test >= comperator @@ -866,7 +866,7 @@ def Test_expr4_greaterequal() assert_false(ff >= 3.0) endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test < comperator @@ -888,7 +888,7 @@ def Test_expr4_smaller() assert_true(ff < 3.0) endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test <= comperator @@ -913,7 +913,7 @@ def Test_expr4_smallerequal() assert_true(ff <= 3.0) endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test =~ comperator @@ -930,7 +930,7 @@ def Test_expr4_match() assert_equal(true, 'abc' =~? 'ABC') set noignorecase END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test !~ comperator @@ -942,7 +942,7 @@ def Test_expr4_nomatch() assert_equal(false, '2' !~ '[0-9]') END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test is comperator @@ -960,7 +960,7 @@ def Test_expr4_is() var otherblob = myblob assert_true(myblob is otherblob) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test isnot comperator @@ -979,10 +979,10 @@ def Test_expr4_isnot() var otherblob = myblob assert_false(myblob isnot otherblob) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef -def RetVoid() +def g:RetVoid() var x = 1 enddef @@ -993,7 +993,7 @@ def Test_expr4_vim9script() < 1 assert_equal(true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = 123 @@ -1001,14 +1001,14 @@ def Test_expr4_vim9script() != 123 assert_equal(false, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = 123 == 123 assert_equal(true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var list = [1, 2, 3] @@ -1016,7 +1016,7 @@ def Test_expr4_vim9script() is list assert_equal(true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var list = [1, 2, 3] @@ -1025,7 +1025,7 @@ def Test_expr4_vim9script() is list assert_equal(true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var myblob = 0z1234 @@ -1033,140 +1033,140 @@ def Test_expr4_vim9script() isnot 0z11 assert_equal(true, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # spot check mismatching types lines =<< trim END echo '' == 0 END - CheckDefAndScriptFailure(lines, 'E1072:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1072:', 1) lines =<< trim END echo v:true > v:false END - CheckDefAndScriptFailure(lines, 'Cannot compare bool with bool', 1) + v9.CheckDefAndScriptFailure(lines, 'Cannot compare bool with bool', 1) lines =<< trim END echo 123 is 123 END - CheckDefAndScriptFailure(lines, 'Cannot use "is" with number', 1) + v9.CheckDefAndScriptFailure(lines, 'Cannot use "is" with number', 1) # check missing white space lines =<< trim END echo 2>3 END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''>'' at ">3"', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''>'' at ">3"', 1) lines =<< trim END echo 2 >3 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 2> 3 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 2!=3 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 2 !=3 END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''!='' at "!=3"', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''!='' at "!=3"', 1) lines =<< trim END echo 2!= 3 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) for op in ['==', '>', '>=', '<', '<=', '=~', '!~', 'is', 'isnot'] lines = ["echo 'aaa'", op .. "'bbb'", '# comment'] var msg = printf("E1004: White space required before and after '%s'", op) - CheckDefAndScriptFailure(lines, msg, 2) + v9.CheckDefAndScriptFailure(lines, msg, 2) endfor lines =<< trim END echo len('xxx') == 3 END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var line = 'abc' echo line[1] =~ '\w' END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef func Test_expr4_fails() let msg = "White space required before and after '>'" - call CheckDefAndScriptFailure(["var x = 1>2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 >2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1> 2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1>2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 >2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1> 2"], msg, 1) let msg = "White space required before and after '=='" - call CheckDefAndScriptFailure(["var x = 1==2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 ==2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1== 2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1==2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 ==2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1== 2"], msg, 1) let msg = "White space required before and after 'is'" - call CheckDefAndScriptFailure(["var x = '1'is'2'"], msg, 1) - call CheckDefAndScriptFailure(["var x = '1' is'2'"], msg, 1) - call CheckDefAndScriptFailure(["var x = '1'is '2'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = '1'is'2'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = '1' is'2'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = '1'is '2'"], msg, 1) let msg = "White space required before and after 'isnot'" - call CheckDefAndScriptFailure(["var x = '1'isnot'2'"], msg, 1) - call CheckDefAndScriptFailure(["var x = '1' isnot'2'"], msg, 1) - call CheckDefAndScriptFailure(["var x = '1'isnot '2'"], msg, 1) - - call CheckDefAndScriptFailure(["var x = 1 is# 2"], 'E15:', 1) - call CheckDefAndScriptFailure(["var x = 1 is? 2"], 'E15:', 1) - call CheckDefAndScriptFailure(["var x = 1 isnot# 2"], 'E15:', 1) - call CheckDefAndScriptFailure(["var x = 1 isnot? 2"], 'E15:', 1) - - call CheckDefAndScriptFailure(["var x = 1 == '2'"], 'Cannot compare number with string', 1) - call CheckDefAndScriptFailure(["var x = '1' == 2"], 'Cannot compare string with number', 1) - call CheckDefAndScriptFailure(["var x = 1 == RetVoid()"], 'Cannot compare number with void', 1) - call CheckDefAndScriptFailure(["var x = RetVoid() == 1"], 'Cannot compare void with number', 1) - - call CheckDefAndScriptFailure(["var x = true > false"], 'Cannot compare bool with bool', 1) - call CheckDefAndScriptFailure(["var x = true >= false"], 'Cannot compare bool with bool', 1) - call CheckDefAndScriptFailure(["var x = true < false"], 'Cannot compare bool with bool', 1) - call CheckDefAndScriptFailure(["var x = true <= false"], 'Cannot compare bool with bool', 1) - call CheckDefAndScriptFailure(["var x = true =~ false"], 'Cannot compare bool with bool', 1) - call CheckDefAndScriptFailure(["var x = true !~ false"], 'Cannot compare bool with bool', 1) - call CheckDefAndScriptFailure(["var x = true is false"], 'Cannot use "is" with bool', 1) - call CheckDefAndScriptFailure(["var x = true isnot false"], 'Cannot use "isnot" with bool', 1) - - call CheckDefAndScriptFailure(["var x = v:none is v:null"], 'Cannot use "is" with special', 1) - call CheckDefAndScriptFailure(["var x = v:none isnot v:null"], 'Cannot use "isnot" with special', 1) - call CheckDefAndScriptFailure(["var x = 123 is 123"], 'Cannot use "is" with number', 1) - call CheckDefAndScriptFailure(["var x = 123 isnot 123"], 'Cannot use "isnot" with number', 1) + call v9.CheckDefAndScriptFailure(["var x = '1'isnot'2'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = '1' isnot'2'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = '1'isnot '2'"], msg, 1) + + call v9.CheckDefAndScriptFailure(["var x = 1 is# 2"], 'E15:', 1) + call v9.CheckDefAndScriptFailure(["var x = 1 is? 2"], 'E15:', 1) + call v9.CheckDefAndScriptFailure(["var x = 1 isnot# 2"], 'E15:', 1) + call v9.CheckDefAndScriptFailure(["var x = 1 isnot? 2"], 'E15:', 1) + + call v9.CheckDefAndScriptFailure(["var x = 1 == '2'"], 'Cannot compare number with string', 1) + call v9.CheckDefAndScriptFailure(["var x = '1' == 2"], 'Cannot compare string with number', 1) + call v9.CheckDefAndScriptFailure(["var x = 1 == g:RetVoid()"], 'Cannot compare number with void', 1) + call v9.CheckDefAndScriptFailure(["var x = g:RetVoid() == 1"], 'Cannot compare void with number', 1) + + call v9.CheckDefAndScriptFailure(["var x = true > false"], 'Cannot compare bool with bool', 1) + call v9.CheckDefAndScriptFailure(["var x = true >= false"], 'Cannot compare bool with bool', 1) + call v9.CheckDefAndScriptFailure(["var x = true < false"], 'Cannot compare bool with bool', 1) + call v9.CheckDefAndScriptFailure(["var x = true <= false"], 'Cannot compare bool with bool', 1) + call v9.CheckDefAndScriptFailure(["var x = true =~ false"], 'Cannot compare bool with bool', 1) + call v9.CheckDefAndScriptFailure(["var x = true !~ false"], 'Cannot compare bool with bool', 1) + call v9.CheckDefAndScriptFailure(["var x = true is false"], 'Cannot use "is" with bool', 1) + call v9.CheckDefAndScriptFailure(["var x = true isnot false"], 'Cannot use "isnot" with bool', 1) + + call v9.CheckDefAndScriptFailure(["var x = v:none is v:null"], 'Cannot use "is" with special', 1) + call v9.CheckDefAndScriptFailure(["var x = v:none isnot v:null"], 'Cannot use "isnot" with special', 1) + call v9.CheckDefAndScriptFailure(["var x = 123 is 123"], 'Cannot use "is" with number', 1) + call v9.CheckDefAndScriptFailure(["var x = 123 isnot 123"], 'Cannot use "isnot" with number', 1) if has('float') - call CheckDefAndScriptFailure(["var x = 1.3 is 1.3"], 'Cannot use "is" with float', 1) - call CheckDefAndScriptFailure(["var x = 1.3 isnot 1.3"], 'Cannot use "isnot" with float', 1) + call v9.CheckDefAndScriptFailure(["var x = 1.3 is 1.3"], 'Cannot use "is" with float', 1) + call v9.CheckDefAndScriptFailure(["var x = 1.3 isnot 1.3"], 'Cannot use "isnot" with float', 1) endif - call CheckDefAndScriptFailure(["var x = 0za1 > 0z34"], 'Cannot compare blob with blob', 1) - call CheckDefAndScriptFailure(["var x = 0za1 >= 0z34"], 'Cannot compare blob with blob', 1) - call CheckDefAndScriptFailure(["var x = 0za1 < 0z34"], 'Cannot compare blob with blob', 1) - call CheckDefAndScriptFailure(["var x = 0za1 <= 0z34"], 'Cannot compare blob with blob', 1) - call CheckDefAndScriptFailure(["var x = 0za1 =~ 0z34"], 'Cannot compare blob with blob', 1) - call CheckDefAndScriptFailure(["var x = 0za1 !~ 0z34"], 'Cannot compare blob with blob', 1) - - call CheckDefAndScriptFailure(["var x = [13] > [88]"], 'Cannot compare list with list', 1) - call CheckDefAndScriptFailure(["var x = [13] >= [88]"], 'Cannot compare list with list', 1) - call CheckDefAndScriptFailure(["var x = [13] < [88]"], 'Cannot compare list with list', 1) - call CheckDefAndScriptFailure(["var x = [13] <= [88]"], 'Cannot compare list with list', 1) - call CheckDefAndScriptFailure(["var x = [13] =~ [88]"], 'Cannot compare list with list', 1) - call CheckDefAndScriptFailure(["var x = [13] !~ [88]"], 'Cannot compare list with list', 1) - - call CheckDefAndScriptFailure(['var j: job', 'var chan: channel', 'var r = j == chan'], 'Cannot compare job with channel', 3) - call CheckDefAndScriptFailure(['var j: job', 'var x: list', 'var r = j == x'], 'Cannot compare job with list', 3) - call CheckDefAndScriptFailure(['var j: job', 'var Xx: func', 'var r = j == Xx'], 'Cannot compare job with func', 3) - call CheckDefAndScriptFailure(['var j: job', 'var Xx: func', 'var r = j == Xx'], 'Cannot compare job with func', 3) + call v9.CheckDefAndScriptFailure(["var x = 0za1 > 0z34"], 'Cannot compare blob with blob', 1) + call v9.CheckDefAndScriptFailure(["var x = 0za1 >= 0z34"], 'Cannot compare blob with blob', 1) + call v9.CheckDefAndScriptFailure(["var x = 0za1 < 0z34"], 'Cannot compare blob with blob', 1) + call v9.CheckDefAndScriptFailure(["var x = 0za1 <= 0z34"], 'Cannot compare blob with blob', 1) + call v9.CheckDefAndScriptFailure(["var x = 0za1 =~ 0z34"], 'Cannot compare blob with blob', 1) + call v9.CheckDefAndScriptFailure(["var x = 0za1 !~ 0z34"], 'Cannot compare blob with blob', 1) + + call v9.CheckDefAndScriptFailure(["var x = [13] > [88]"], 'Cannot compare list with list', 1) + call v9.CheckDefAndScriptFailure(["var x = [13] >= [88]"], 'Cannot compare list with list', 1) + call v9.CheckDefAndScriptFailure(["var x = [13] < [88]"], 'Cannot compare list with list', 1) + call v9.CheckDefAndScriptFailure(["var x = [13] <= [88]"], 'Cannot compare list with list', 1) + call v9.CheckDefAndScriptFailure(["var x = [13] =~ [88]"], 'Cannot compare list with list', 1) + call v9.CheckDefAndScriptFailure(["var x = [13] !~ [88]"], 'Cannot compare list with list', 1) + + call v9.CheckDefAndScriptFailure(['var j: job', 'var chan: channel', 'var r = j == chan'], 'Cannot compare job with channel', 3) + call v9.CheckDefAndScriptFailure(['var j: job', 'var x: list', 'var r = j == x'], 'Cannot compare job with list', 3) + call v9.CheckDefAndScriptFailure(['var j: job', 'var Xx: func', 'var r = j == Xx'], 'Cannot compare job with func', 3) + call v9.CheckDefAndScriptFailure(['var j: job', 'var Xx: func', 'var r = j == Xx'], 'Cannot compare job with func', 3) endfunc " test addition, subtraction, concatenation @@ -1232,7 +1232,7 @@ def Test_expr5() assert_equal('val', '' .. {key: 'val'}['key']) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr5_vim9script() @@ -1243,7 +1243,7 @@ def Test_expr5_vim9script() - 22 assert_equal(66, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = 11 + @@ -1251,7 +1251,7 @@ def Test_expr5_vim9script() 22 assert_equal(66, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = 11 + # comment @@ -1260,112 +1260,112 @@ def Test_expr5_vim9script() 22 assert_equal(66, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = 'one' .. 'two' assert_equal('onetwo', name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END echo 'abc' is# 'abc' END - CheckDefAndScriptFailure(lines, 'E15:', 1) + v9.CheckDefAndScriptFailure(lines, 'E15:', 1) lines =<< trim END echo {} - 22 END - CheckDefAndScriptFailure(lines, ['E1036:', 'E728:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1036:', 'E728:'], 1) lines =<< trim END echo [] - 33 END - CheckDefAndScriptFailure(lines, ['E1036:', 'E745:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1036:', 'E745:'], 1) lines =<< trim END echo 0z1234 - 44 END - CheckDefAndScriptFailure(lines, ['E1036', 'E974:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1036', 'E974:'], 1) lines =<< trim END echo 'abc' is? 'abc' END - CheckDefAndScriptFailure(lines, 'E15:', 1) + v9.CheckDefAndScriptFailure(lines, 'E15:', 1) lines =<< trim END echo 'abc' isnot# 'abc' END - CheckDefAndScriptFailure(lines, 'E15:', 1) + v9.CheckDefAndScriptFailure(lines, 'E15:', 1) lines =<< trim END echo 'abc' isnot? 'abc' END - CheckDefAndScriptFailure(lines, 'E15:', 1) + v9.CheckDefAndScriptFailure(lines, 'E15:', 1) # check white space lines =<< trim END echo 5+6 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 5 +6 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 5+ 6 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 'a'..'b' END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at "..''b''"', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at "..''b''"', 1) lines =<< trim END echo 'a' ..'b' END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 'a'.. 'b' END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at ".. ''b''"', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at ".. ''b''"', 1) lines =<< trim END echo 'a' ..'b' # comment END - CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at "..''b''"', 2) + v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at "..''b''"', 2) # check invalid string concatenation lines =<< trim END echo 'a' .. [1] END - CheckDefAndScriptFailure(lines, ['E1105:', 'E730:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E730:'], 1) lines =<< trim END echo 'a' .. {a: 1} END - CheckDefAndScriptFailure(lines, ['E1105:', 'E731:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E731:'], 1) lines =<< trim END echo 'a' .. test_void() END - CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) lines =<< trim END echo 'a' .. 0z33 END - CheckDefAndScriptFailure(lines, ['E1105:', 'E976:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E976:'], 1) lines =<< trim END echo 'a' .. function('len') END - CheckDefAndScriptFailure(lines, ['E1105:', 'E729:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E729:'], 1) lines =<< trim END new @@ -1375,12 +1375,12 @@ def Test_expr5_vim9script() eval 0 bwipe! END - CheckDefAndScriptFailure(lines, "E1004: White space required before and after '/' at \"/pattern", 3) + v9.CheckDefAndScriptFailure(lines, "E1004: White space required before and after '/' at \"/pattern", 3) for op in ['+', '-'] lines = ['var x = 1', op .. '2', '# comment'] var msg = printf("E1004: White space required before and after '%s' at \"%s2\"", op, op) - CheckDefAndScriptFailure(lines, msg, 2) + v9.CheckDefAndScriptFailure(lines, msg, 2) endfor enddef @@ -1391,11 +1391,11 @@ def Test_expr5_vim9script_channel() var lines =<< trim END echo 'a' .. test_null_job() END - CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) lines =<< trim END echo 'a' .. test_null_channel() END - CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) endif enddef @@ -1423,53 +1423,53 @@ def Test_expr5_float() assert_equal(9.9, g:anint - g:afloat) assert_equal(-9.9, g:afloat - g:anint) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) endif enddef func Test_expr5_fails() let msg = "White space required before and after '+'" - call CheckDefAndScriptFailure(["var x = 1+2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 +2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1+ 2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1+2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 +2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1+ 2"], msg, 1) let msg = "White space required before and after '-'" - call CheckDefAndScriptFailure(["var x = 1-2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 -2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1- 2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1-2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 -2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1- 2"], msg, 1) let msg = "White space required before and after '..'" - call CheckDefAndScriptFailure(["var x = '1'..'2'"], msg, 1) - call CheckDefAndScriptFailure(["var x = '1' ..'2'"], msg, 1) - call CheckDefAndScriptFailure(["var x = '1'.. '2'"], msg, 1) - - call CheckDefAndScriptFailure(["var x = 0z1122 + 33"], ['E1051:', 'E974:'], 1) - call CheckDefAndScriptFailure(["var x = 0z1122 + [3]"], ['E1051:', 'E974:'], 1) - call CheckDefAndScriptFailure(["var x = 0z1122 + 'asd'"], ['E1051:', 'E974:'], 1) - call CheckDefAndScriptFailure(["var x = 33 + 0z1122"], ['E1051:', 'E974:'], 1) - call CheckDefAndScriptFailure(["var x = [3] + 0z1122"], ['E1051:', 'E745:'], 1) - call CheckDefAndScriptFailure(["var x = 'asdf' + 0z1122"], ['E1051:', 'E1030:'], 1) - call CheckDefAndScriptFailure(["var x = 6 + xxx"], ['E1001:', 'E121:'], 1) - - call CheckDefAndScriptFailure(["var x = 'a' .. [1]"], ['E1105:', 'E730:'], 1) - call CheckDefAndScriptFailure(["var x = 'a' .. {a: 1}"], ['E1105:', 'E731:'], 1) - call CheckDefAndScriptFailure(["var x = 'a' .. test_void()"], ['E1105:', 'E908:'], 1) - call CheckDefAndScriptFailure(["var x = 'a' .. 0z32"], ['E1105:', 'E976:'], 1) - call CheckDefAndScriptFailure(["var x = 'a' .. function('len')"], ['E1105:', 'E729:'], 1) - call CheckDefAndScriptFailure(["var x = 'a' .. function('len', ['a'])"], ['E1105:', 'E729:'], 1) - - call CheckDefAndScriptFailure(['var x = 1 + v:none'], ['E1051:', 'E611:'], 1) - call CheckDefAndScriptFailure(['var x = 1 + v:null'], ['E1051:', 'E611:'], 1) - call CheckDefAndScriptFailure(['var x = 1 + v:true'], ['E1051:', 'E1138:'], 1) - call CheckDefAndScriptFailure(['var x = 1 + v:false'], ['E1051:', 'E1138:'], 1) - call CheckDefAndScriptFailure(['var x = 1 + true'], ['E1051:', 'E1138:'], 1) - call CheckDefAndScriptFailure(['var x = 1 + false'], ['E1051:', 'E1138:'], 1) + call v9.CheckDefAndScriptFailure(["var x = '1'..'2'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = '1' ..'2'"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = '1'.. '2'"], msg, 1) + + call v9.CheckDefAndScriptFailure(["var x = 0z1122 + 33"], ['E1051:', 'E974:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 0z1122 + [3]"], ['E1051:', 'E974:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 0z1122 + 'asd'"], ['E1051:', 'E974:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 33 + 0z1122"], ['E1051:', 'E974:'], 1) + call v9.CheckDefAndScriptFailure(["var x = [3] + 0z1122"], ['E1051:', 'E745:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 'asdf' + 0z1122"], ['E1051:', 'E1030:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 6 + xxx"], ['E1001:', 'E121:'], 1) + + call v9.CheckDefAndScriptFailure(["var x = 'a' .. [1]"], ['E1105:', 'E730:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 'a' .. {a: 1}"], ['E1105:', 'E731:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 'a' .. test_void()"], ['E1105:', 'E908:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 'a' .. 0z32"], ['E1105:', 'E976:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 'a' .. function('len')"], ['E1105:', 'E729:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 'a' .. function('len', ['a'])"], ['E1105:', 'E729:'], 1) + + call v9.CheckDefAndScriptFailure(['var x = 1 + v:none'], ['E1051:', 'E611:'], 1) + call v9.CheckDefAndScriptFailure(['var x = 1 + v:null'], ['E1051:', 'E611:'], 1) + call v9.CheckDefAndScriptFailure(['var x = 1 + v:true'], ['E1051:', 'E1138:'], 1) + call v9.CheckDefAndScriptFailure(['var x = 1 + v:false'], ['E1051:', 'E1138:'], 1) + call v9.CheckDefAndScriptFailure(['var x = 1 + true'], ['E1051:', 'E1138:'], 1) + call v9.CheckDefAndScriptFailure(['var x = 1 + false'], ['E1051:', 'E1138:'], 1) endfunc func Test_expr5_fails_channel() - CheckFeature channel - call CheckDefAndScriptFailure(["var x = 'a' .. test_null_job()"], ['E1105:', 'E908:'], 1) - call CheckDefAndScriptFailure(["var x = 'a' .. test_null_channel()"], ['E1105:', 'E908:'], 1) + g:CheckFeature channel + call v9.CheckDefAndScriptFailure(["var x = 'a' .. test_null_job()"], ['E1105:', 'E908:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 'a' .. test_null_channel()"], ['E1105:', 'E908:'], 1) endfunc def Test_expr5_list_add() @@ -1490,7 +1490,7 @@ def Test_expr5_list_add() # result of glob() is "any", runtime type check var sl: list = glob('*.txt', false, true) + [''] END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef " test multiply, divide, modulo @@ -1532,26 +1532,26 @@ def Test_expr6() * yf[0]) endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(["var x = 6 * xxx"], ['E1001:', 'E121:'], 1) - CheckDefFailure(["var d = 6 * "], 'E1097:', 3) - CheckScriptFailure(['vim9script', "var d = 6 * "], 'E15:', 2) + v9.CheckDefAndScriptFailure(["var x = 6 * xxx"], ['E1001:', 'E121:'], 1) + v9.CheckDefFailure(["var d = 6 * "], 'E1097:', 3) + v9.CheckScriptFailure(['vim9script', "var d = 6 * "], 'E15:', 2) - CheckDefExecAndScriptFailure(['echo 1 / 0'], 'E1154', 1) - CheckDefExecAndScriptFailure(['echo 1 % 0'], 'E1154', 1) + v9.CheckDefExecAndScriptFailure(['echo 1 / 0'], 'E1154', 1) + v9.CheckDefExecAndScriptFailure(['echo 1 % 0'], 'E1154', 1) lines =<< trim END var n = 0 eval 1 / n END - CheckDefExecAndScriptFailure(lines, 'E1154', 2) + v9.CheckDefExecAndScriptFailure(lines, 'E1154', 2) lines =<< trim END var n = 0 eval 1 % n END - CheckDefExecAndScriptFailure(lines, 'E1154', 2) + v9.CheckDefExecAndScriptFailure(lines, 'E1154', 2) enddef def Test_expr6_vim9script() @@ -1562,14 +1562,14 @@ def Test_expr6_vim9script() / 3 assert_equal(80, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = 25 % 10 assert_equal(5, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = 25 @@ -1579,7 +1579,7 @@ def Test_expr6_vim9script() % 10 assert_equal(5, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var name = 11 * @@ -1587,23 +1587,23 @@ def Test_expr6_vim9script() 3 assert_equal(80, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # check white space lines =<< trim END echo 5*6 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 5 *6 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) lines =<< trim END echo 5* 6 END - CheckDefAndScriptFailure(lines, 'E1004:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) enddef def Test_expr6_float() @@ -1635,57 +1635,57 @@ def Test_expr6_float() assert_equal(4.0, 6.0 * 4.0 / 6.0) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) endif enddef func Test_expr6_fails() let msg = "White space required before and after '*'" - call CheckDefAndScriptFailure(["var x = 1*2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 *2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1* 2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1*2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 *2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1* 2"], msg, 1) let msg = "White space required before and after '/'" - call CheckDefAndScriptFailure(["var x = 1/2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 /2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1/ 2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1/2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 /2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1/ 2"], msg, 1) let msg = "White space required before and after '%'" - call CheckDefAndScriptFailure(["var x = 1%2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1 %2"], msg, 1) - call CheckDefAndScriptFailure(["var x = 1% 2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1%2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1 %2"], msg, 1) + call v9.CheckDefAndScriptFailure(["var x = 1% 2"], msg, 1) - call CheckDefAndScriptFailure(["var x = '1' * '2'"], ['E1036:', 'E1030:'], 1) - call CheckDefAndScriptFailure(["var x = '1' / '2'"], ['E1036:', 'E1030:'], 1) - call CheckDefAndScriptFailure(["var x = '1' % '2'"], ['E1035:', 'E1030:'], 1) + call v9.CheckDefAndScriptFailure(["var x = '1' * '2'"], ['E1036:', 'E1030:'], 1) + call v9.CheckDefAndScriptFailure(["var x = '1' / '2'"], ['E1036:', 'E1030:'], 1) + call v9.CheckDefAndScriptFailure(["var x = '1' % '2'"], ['E1035:', 'E1030:'], 1) - call CheckDefAndScriptFailure(["var x = 0z01 * 0z12"], ['E1036:', 'E974:'], 1) - call CheckDefAndScriptFailure(["var x = 0z01 / 0z12"], ['E1036:', 'E974:'], 1) - call CheckDefAndScriptFailure(["var x = 0z01 % 0z12"], ['E1035:', 'E974:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 0z01 * 0z12"], ['E1036:', 'E974:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 0z01 / 0z12"], ['E1036:', 'E974:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 0z01 % 0z12"], ['E1035:', 'E974:'], 1) - call CheckDefAndScriptFailure(["var x = [1] * [2]"], ['E1036:', 'E745:'], 1) - call CheckDefAndScriptFailure(["var x = [1] / [2]"], ['E1036:', 'E745:'], 1) - call CheckDefAndScriptFailure(["var x = [1] % [2]"], ['E1035:', 'E745:'], 1) + call v9.CheckDefAndScriptFailure(["var x = [1] * [2]"], ['E1036:', 'E745:'], 1) + call v9.CheckDefAndScriptFailure(["var x = [1] / [2]"], ['E1036:', 'E745:'], 1) + call v9.CheckDefAndScriptFailure(["var x = [1] % [2]"], ['E1035:', 'E745:'], 1) - call CheckDefAndScriptFailure(["var x = {one: 1} * {two: 2}"], ['E1036:', 'E728:'], 1) - call CheckDefAndScriptFailure(["var x = {one: 1} / {two: 2}"], ['E1036:', 'E728:'], 1) - call CheckDefAndScriptFailure(["var x = {one: 1} % {two: 2}"], ['E1035:', 'E728:'], 1) + call v9.CheckDefAndScriptFailure(["var x = {one: 1} * {two: 2}"], ['E1036:', 'E728:'], 1) + call v9.CheckDefAndScriptFailure(["var x = {one: 1} / {two: 2}"], ['E1036:', 'E728:'], 1) + call v9.CheckDefAndScriptFailure(["var x = {one: 1} % {two: 2}"], ['E1035:', 'E728:'], 1) - call CheckDefAndScriptFailure(["var x = 0xff[1]"], ['E1107:', 'E1062:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 0xff[1]"], ['E1107:', 'E1062:'], 1) if has('float') - call CheckDefAndScriptFailure(["var x = 0.7[1]"], ['E1107:', 'E806:'], 1) + call v9.CheckDefAndScriptFailure(["var x = 0.7[1]"], ['E1107:', 'E806:'], 1) endif for op in ['*', '/', '%'] let lines = ['var x = 1', op .. '2', '# comment'] let msg = printf("E1004: White space required before and after '%s' at \"%s2\"", op, op) - call CheckDefAndScriptFailure(lines, msg, 2) + call v9.CheckDefAndScriptFailure(lines, msg, 2) endfor endfunc func Test_expr6_float_fails() - CheckFeature float - call CheckDefAndScriptFailure(["var x = 1.0 % 2"], ['E1035:', 'E804:'], 1) + g:CheckFeature float + call v9.CheckDefAndScriptFailure(["var x = 1.0 % 2"], ['E1035:', 'E804:'], 1) endfunc " define here to use old style parsing @@ -1732,14 +1732,14 @@ def Test_expr7() text = 'xxx' endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(["var x = 123"], 'E1010:', 1) - CheckDefFailure(["var x = "], 'E1097:', 3) - CheckDefFailure(["var x = string(1)"], 'E1012:', 1) - CheckScriptFailure(['vim9script', "var x = "], 'E15:', 2) - CheckDefAndScriptFailure(["var x = 123"], 'E1068:', 1) - CheckDefAndScriptFailure(["var x = 123"], 'E1010:', 1) + v9.CheckDefFailure(["var x = "], 'E1097:', 3) + v9.CheckDefFailure(["var x = string(1)"], 'E1012:', 1) + v9.CheckScriptFailure(['vim9script', "var x = "], 'E15:', 2) + v9.CheckDefAndScriptFailure(["var x = 123"], 'E1068:', 1) + v9.CheckDefAndScriptFailure(["var x = = v:errors - CheckDefFailure(['var errs: list = v:errors'], 'E1012:') + v9.CheckDefFailure(['var errs: list = v:errors'], 'E1012:') var old: list = v:oldfiles - CheckDefFailure(['var old: list = v:oldfiles'], 'E1012:') + v9.CheckDefFailure(['var old: list = v:oldfiles'], 'E1012:') var compl: dict = v:completed_item - CheckDefFailure(['var compl: dict = v:completed_item'], 'E1012:') + v9.CheckDefFailure(['var compl: dict = v:completed_item'], 'E1012:') var args: list = v:argv - CheckDefFailure(['var args: list = v:argv'], 'E1012:') + v9.CheckDefFailure(['var args: list = v:argv'], 'E1012:') var colors: dict = v:colornames - CheckDefFailure(['var colors: dict = v:colornames'], 'E1012:') + v9.CheckDefFailure(['var colors: dict = v:colornames'], 'E1012:') - CheckDefFailure(["var old: list = v:oldfiles"], 'E1012: Type mismatch; expected list but got list', 1) - CheckScriptFailure(['vim9script', 'v:oldfiles = ["foo"]', "var old: list = v:oldfiles"], 'E1012: Type mismatch; expected list but got list', 3) + v9.CheckDefFailure(["var old: list = v:oldfiles"], 'E1012: Type mismatch; expected list but got list', 1) + v9.CheckScriptFailure(['vim9script', 'v:oldfiles = ["foo"]', "var old: list = v:oldfiles"], 'E1012: Type mismatch; expected list but got list', 3) new exec "normal! afoo fo\\" - CheckDefExecAndScriptFailure(["var old: dict = v:completed_item"], 'E1012: Type mismatch; expected dict but got dict', 1) + v9.CheckDefExecAndScriptFailure(["var old: dict = v:completed_item"], 'E1012: Type mismatch; expected dict but got dict', 1) bwipe! enddef @@ -1873,13 +1873,13 @@ def Test_expr8_special() assert_equal(g:special_null, null) assert_equal(g:special_none, v:none) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(['v:true = true'], 'E46:', 1) - CheckDefAndScriptFailure(['v:true = false'], 'E46:', 1) - CheckDefAndScriptFailure(['v:false = true'], 'E46:', 1) - CheckDefAndScriptFailure(['v:null = 11'], 'E46:', 1) - CheckDefAndScriptFailure(['v:none = 22'], 'E46:', 1) + v9.CheckDefAndScriptFailure(['v:true = true'], 'E46:', 1) + v9.CheckDefAndScriptFailure(['v:true = false'], 'E46:', 1) + v9.CheckDefAndScriptFailure(['v:false = true'], 'E46:', 1) + v9.CheckDefAndScriptFailure(['v:null = 11'], 'E46:', 1) + v9.CheckDefAndScriptFailure(['v:none = 22'], 'E46:', 1) enddef def Test_expr8_list() @@ -1908,32 +1908,32 @@ def Test_expr8_list() llstring = [[], ['text']] llstring = [[], []] END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) var rangelist: list = range(3) g:rangelist = range(3) - CheckDefExecAndScriptFailure(["var x: list = g:rangelist"], 'E1012: Type mismatch; expected list but got list', 1) + v9.CheckDefExecAndScriptFailure(["var x: list = g:rangelist"], 'E1012: Type mismatch; expected list but got list', 1) - CheckDefAndScriptFailure(["var x = 1234[3]"], ['E1107:', 'E1062:'], 1) - CheckDefExecAndScriptFailure(["var x = g:anint[3]"], 'E1062:', 1) + v9.CheckDefAndScriptFailure(["var x = 1234[3]"], ['E1107:', 'E1062:'], 1) + v9.CheckDefExecAndScriptFailure(["var x = g:anint[3]"], 'E1062:', 1) - CheckDefAndScriptFailure(["var x = g:list_mixed[xxx]"], ['E1001:', 'E121:'], 1) + v9.CheckDefAndScriptFailure(["var x = g:list_mixed[xxx]"], ['E1001:', 'E121:'], 1) - CheckDefAndScriptFailure(["var x = [1,2,3]"], 'E1069:', 1) - CheckDefAndScriptFailure(["var x = [1 ,2, 3]"], 'E1068:', 1) + v9.CheckDefAndScriptFailure(["var x = [1,2,3]"], 'E1069:', 1) + v9.CheckDefAndScriptFailure(["var x = [1 ,2, 3]"], 'E1068:', 1) - CheckDefExecAndScriptFailure(["echo 1", "var x = [][0]", "echo 3"], 'E684:', 2) + v9.CheckDefExecAndScriptFailure(["echo 1", "var x = [][0]", "echo 3"], 'E684:', 2) - CheckDefExecAndScriptFailure(["var x = g:list_mixed['xx']"], ['E1012:', 'E1030:'], 1) - CheckDefFailure(["var x = g:list_mixed["], 'E1097:', 3) - CheckScriptFailure(['vim9script', "var x = g:list_mixed["], 'E15:', 2) - CheckDefFailure(["var x = g:list_mixed[0"], 'E1097:', 3) - CheckScriptFailure(['vim9script', "var x = g:list_mixed[0"], 'E111:', 2) - CheckDefExecAndScriptFailure(["var x = g:list_empty[3]"], 'E684:', 1) - CheckDefExecAndScriptFailure(["var l: list = [234, 'x']"], 'E1012:', 1) - CheckDefExecAndScriptFailure(["var l: list = ['x', 234]"], 'E1012:', 1) - CheckDefExecAndScriptFailure(["var l: list = [234, 'x']"], 'E1012:', 1) - CheckDefExecAndScriptFailure(["var l: list = ['x', 123]"], 'E1012:', 1) + v9.CheckDefExecAndScriptFailure(["var x = g:list_mixed['xx']"], ['E1012:', 'E1030:'], 1) + v9.CheckDefFailure(["var x = g:list_mixed["], 'E1097:', 3) + v9.CheckScriptFailure(['vim9script', "var x = g:list_mixed["], 'E15:', 2) + v9.CheckDefFailure(["var x = g:list_mixed[0"], 'E1097:', 3) + v9.CheckScriptFailure(['vim9script', "var x = g:list_mixed[0"], 'E111:', 2) + v9.CheckDefExecAndScriptFailure(["var x = g:list_empty[3]"], 'E684:', 1) + v9.CheckDefExecAndScriptFailure(["var l: list = [234, 'x']"], 'E1012:', 1) + v9.CheckDefExecAndScriptFailure(["var l: list = ['x', 234]"], 'E1012:', 1) + v9.CheckDefExecAndScriptFailure(["var l: list = [234, 'x']"], 'E1012:', 1) + v9.CheckDefExecAndScriptFailure(["var l: list = ['x', 123]"], 'E1012:', 1) lines =<< trim END var datalist: list @@ -1942,17 +1942,17 @@ def Test_expr8_list() enddef Main() END - CheckDefAndScriptFailure(lines, 'E1127:') + v9.CheckDefAndScriptFailure(lines, 'E1127:') lines =<< trim END var numbers = [1, 2, 3, 4] var a = 1 var b = 2 END - CheckDefAndScriptFailure(lines + ['echo numbers[1:b]'], + v9.CheckDefAndScriptFailure(lines + ['echo numbers[1:b]'], 'E1004: White space required before and after '':'' at ":b]"', 4) - CheckDefAndScriptFailure(lines + ['echo numbers[1: b]'], 'E1004:', 4) - CheckDefAndScriptFailure(lines + ['echo numbers[a :b]'], 'E1004:', 4) + v9.CheckDefAndScriptFailure(lines + ['echo numbers[1: b]'], 'E1004:', 4) + v9.CheckDefAndScriptFailure(lines + ['echo numbers[a :b]'], 'E1004:', 4) enddef def Test_expr8_list_vim9script() @@ -1973,44 +1973,44 @@ def Test_expr8_list_vim9script() # comment 4] END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var l = [11, 22] assert_equal([11, 22], l) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var l = [11,22] END - CheckDefAndScriptFailure(lines, 'E1069:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1069:', 1) lines =<< trim END var l = [11 , 22] END - CheckDefAndScriptFailure(lines, 'E1068:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1068:', 1) lines =<< trim END var l: list = [234, 'x'] END - CheckDefAndScriptFailure(lines, 'E1012:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) lines =<< trim END var l: list = ['x', 234] END - CheckDefAndScriptFailure(lines, 'E1012:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) lines =<< trim END var l: list = ['x', 234] END - CheckDefAndScriptFailure(lines, 'E1012:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) lines =<< trim END var l: list = [234, 'x'] END - CheckDefAndScriptFailure(lines, 'E1012:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) lines =<< trim END def Failing() @@ -2019,9 +2019,9 @@ def Test_expr8_list_vim9script() var list = [Failing] END if has('channel') - CheckDefAndScriptFailure(lines, 'E119:', 0) + v9.CheckDefAndScriptFailure(lines, 'E119:', 0) else - CheckDefAndScriptFailure(lines, 'E117:', 0) + v9.CheckDefAndScriptFailure(lines, 'E117:', 0) endif enddef @@ -2084,49 +2084,49 @@ def Test_expr8_lambda() assert_equal([{key: 12}], filter(dl, (_, v) => has_key(v, 'key') ? v['key'] == 12 : 0)) - assert_equal(false, LambdaWithComments()(0)) - assert_equal(true, LambdaWithComments()(1)) - assert_equal(true, LambdaWithComments()(2)) - assert_equal(false, LambdaWithComments()(3)) + assert_equal(false, g:LambdaWithComments()(0)) + assert_equal(true, g:LambdaWithComments()(1)) + assert_equal(true, g:LambdaWithComments()(2)) + assert_equal(false, g:LambdaWithComments()(3)) - assert_equal(false, LambdaUsingArg(0)()) - assert_equal(true, LambdaUsingArg(1)()) + assert_equal(false, g:LambdaUsingArg(0)()) + assert_equal(true, g:LambdaUsingArg(1)()) var res = map([1, 2, 3], (i: number, v: number) => i + v) assert_equal([1, 3, 5], res) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') - CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004: White space required before and after ''=>'' at "=> a + 1"') - CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004:') - CheckDefAndScriptFailure(["var Ref = (a) =< a + 1"], ['E1001:', 'E121:']) - CheckDefAndScriptFailure(["var Ref = (a: int) => a + 1"], 'E1010:') - CheckDefAndScriptFailure(["var Ref = (a): int => a + 1"], 'E1010:') + v9.CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') + v9.CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004: White space required before and after ''=>'' at "=> a + 1"') + v9.CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004:') + v9.CheckDefAndScriptFailure(["var Ref = (a) =< a + 1"], ['E1001:', 'E121:']) + v9.CheckDefAndScriptFailure(["var Ref = (a: int) => a + 1"], 'E1010:') + v9.CheckDefAndScriptFailure(["var Ref = (a): int => a + 1"], 'E1010:') - CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1) + v9.CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1) # error is in first line of the lambda - CheckDefAndScriptFailure(["var L = (a) => a + b"], 'E1001:', 0) + v9.CheckDefAndScriptFailure(["var L = (a) => a + b"], 'E1001:', 0) assert_equal('xxxyyy', 'xxx'->((a, b) => a .. b)('yyy')) - CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x')"], 'E118:') - CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x', 'y')"], 'E118:') - CheckDefAndScriptFailure(["echo 'asdf'->((a) => a)(x)"], ['E1001:', 'E121:'], 1) + v9.CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x')"], 'E118:') + v9.CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x', 'y')"], 'E118:') + v9.CheckDefAndScriptFailure(["echo 'asdf'->((a) => a)(x)"], ['E1001:', 'E121:'], 1) - CheckDefAndScriptSuccess(['var Fx = (a) => ({k1: 0,', ' k2: 1})']) - CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0', ' k2: 1})'], 'E722:', 2) - CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0,', ' k2 1})'], 'E720:', 2) + v9.CheckDefAndScriptSuccess(['var Fx = (a) => ({k1: 0,', ' k2: 1})']) + v9.CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0', ' k2: 1})'], 'E722:', 2) + v9.CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0,', ' k2 1})'], 'E720:', 2) - CheckDefAndScriptSuccess(['var Fx = (a) => [0,', ' 1]']) - CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2) + v9.CheckDefAndScriptSuccess(['var Fx = (a) => [0,', ' 1]']) + v9.CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2) # no error for existing script variable when checking for lambda lines =<< trim END var name = 0 eval (name + 2) / 3 END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_lambda_block() @@ -2154,41 +2154,41 @@ def Test_expr8_lambda_block() } assert_equal(10, Safe(3)) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END map([1, 2], (k, v) => { redrawt }) END - CheckDefAndScriptFailure(lines, 'E488') + v9.CheckDefAndScriptFailure(lines, 'E488') lines =<< trim END var Func = (nr: int) => { echo nr } END - CheckDefAndScriptFailure(lines, 'E1010', 1) + v9.CheckDefAndScriptFailure(lines, 'E1010', 1) lines =<< trim END var Func = (nr: number): int => { return nr } END - CheckDefAndScriptFailure(lines, 'E1010', 1) + v9.CheckDefAndScriptFailure(lines, 'E1010', 1) lines =<< trim END var Func = (nr: number): int => { return nr END - CheckDefFailure(lines, 'E1171', 0) # line nr is function start - CheckScriptFailure(['vim9script'] + lines, 'E1171', 2) + v9.CheckDefFailure(lines, 'E1171', 0) # line nr is function start + v9.CheckScriptFailure(['vim9script'] + lines, 'E1171', 2) lines =<< trim END var Func = (nr: number): int => { var ll =<< ENDIT nothing END - CheckDefFailure(lines, 'E1145: Missing heredoc end marker: ENDIT', 0) - CheckScriptFailure(['vim9script'] + lines, 'E1145: Missing heredoc end marker: ENDIT', 2) + v9.CheckDefFailure(lines, 'E1145: Missing heredoc end marker: ENDIT', 0) + v9.CheckScriptFailure(['vim9script'] + lines, 'E1145: Missing heredoc end marker: ENDIT', 2) enddef def NewLambdaWithComments(): func @@ -2243,13 +2243,13 @@ def Test_expr8_new_lambda() assert_equal([{key: 12}], filter(dl, (_, v) => has_key(v, 'key') ? v['key'] == 12 : 0)) - assert_equal(false, NewLambdaWithComments()(0)) - assert_equal(true, NewLambdaWithComments()(1)) - assert_equal(true, NewLambdaWithComments()(2)) - assert_equal(false, NewLambdaWithComments()(3)) + assert_equal(false, g:NewLambdaWithComments()(0)) + assert_equal(true, g:NewLambdaWithComments()(1)) + assert_equal(true, g:NewLambdaWithComments()(2)) + assert_equal(false, g:NewLambdaWithComments()(3)) - assert_equal(false, NewLambdaUsingArg(0)()) - assert_equal(true, NewLambdaUsingArg(1)()) + assert_equal(false, g:NewLambdaUsingArg(0)()) + assert_equal(true, g:NewLambdaUsingArg(1)()) var res = map([1, 2, 3], (i: number, v: number) => i + v) assert_equal([1, 3, 5], res) @@ -2266,32 +2266,32 @@ def Test_expr8_new_lambda() var Fy = (a) => [0, 1] END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') - CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004:') - CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], + v9.CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') + v9.CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004:') + v9.CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004: White space required before and after ''=>'' at " =>a + 1"') - CheckDefAndScriptFailure(["var Ref: func(number): number = (a: number): string => 'x'"], 'E1012:') - CheckDefAndScriptFailure(["var Ref: func(number): string = (a: number): string => 99"], 'E1012:') + v9.CheckDefAndScriptFailure(["var Ref: func(number): number = (a: number): string => 'x'"], 'E1012:') + v9.CheckDefAndScriptFailure(["var Ref: func(number): string = (a: number): string => 99"], 'E1012:') - CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1) + v9.CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1) # error is in first line of the lambda - CheckDefAndScriptFailure(["var L = (a) -> a + b"], ['E1001:', 'E121:'], 1) + v9.CheckDefAndScriptFailure(["var L = (a) -> a + b"], ['E1001:', 'E121:'], 1) assert_equal('xxxyyy', 'xxx'->((a, b) => a .. b)('yyy')) - CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x')"], + v9.CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x')"], 'E118: Too many arguments for function:') - CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x', 'y')"], + v9.CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x', 'y')"], 'E118: Too many arguments for function:') - CheckDefFailure(["echo 'asdf'->((a) => a)(x)"], 'E1001:', 1) + v9.CheckDefFailure(["echo 'asdf'->((a) => a)(x)"], 'E1001:', 1) - CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0', ' k2: 1})'], 'E722:', 2) - CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0,', ' k2 1})'], 'E720:', 2) + v9.CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0', ' k2: 1})'], 'E722:', 2) + v9.CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0,', ' k2 1})'], 'E720:', 2) - CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2) + v9.CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2) enddef def Test_expr8_lambda_vim9script() @@ -2302,7 +2302,7 @@ def Test_expr8_lambda_vim9script() )() assert_equal(12, v) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # nested lambda with line breaks lines =<< trim END @@ -2310,7 +2310,7 @@ def Test_expr8_lambda_vim9script() synstack('.', col('.')) ->mapnew((_, v) => synIDattr(v, 'name'))->len()) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_funcref() @@ -2321,7 +2321,7 @@ def Test_expr8_funcref() var FuncRef = RetNumber assert_equal(123, FuncRef()) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END vim9script @@ -2344,7 +2344,7 @@ def Test_expr8_funcref() enddef Test() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef let g:test_space_dict = {'': 'empty', ' ': 'space'} @@ -2425,40 +2425,40 @@ def Test_expr8_dict() var x1: number #{{ fold var x2 = 9 #{{ fold END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # legacy syntax doesn't work - CheckDefAndScriptFailure(["var x = #{key: 8}"], 'E1170:', 1) - CheckDefAndScriptFailure(["var x = 'a' #{a: 1}"], 'E1170:', 1) - CheckDefAndScriptFailure(["var x = 'a' .. #{a: 1}"], 'E1170:', 1) - CheckDefAndScriptFailure(["var x = true ? #{a: 1}"], 'E1170:', 1) - - CheckDefAndScriptFailure(["var x = {a:8}"], 'E1069:', 1) - CheckDefAndScriptFailure(["var x = {a : 8}"], 'E1068:', 1) - CheckDefAndScriptFailure(["var x = {a :8}"], 'E1068:', 1) - CheckDefAndScriptFailure(["var x = {a: 8 , b: 9}"], 'E1068:', 1) - CheckDefAndScriptFailure(["var x = {a: 1,b: 2}"], 'E1069:', 1) - - CheckDefAndScriptFailure(["var x = {xxx}"], 'E720:', 1) - CheckDefAndScriptFailure(["var x = {xxx: 1", "var y = 2"], 'E722:', 2) - CheckDefFailure(["var x = {xxx: 1,"], 'E723:', 2) - CheckScriptFailure(['vim9script', "var x = {xxx: 1,"], 'E723:', 2) - CheckDefAndScriptFailure(["var x = {['a']: xxx}"], ['E1001:', 'E121:'], 1) - CheckDefAndScriptFailure(["var x = {a: 1, a: 2}"], 'E721:', 1) - CheckDefExecAndScriptFailure(["var x = g:anint.member"], ['E715:', 'E488:'], 1) - CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1) - - CheckDefExecAndScriptFailure(['var x: dict = {a: 234, b: "1"}'], 'E1012:', 1) - CheckDefExecAndScriptFailure(['var x: dict = {a: "x", b: 134}'], 'E1012:', 1) - CheckDefExecAndScriptFailure(['var x: dict = {a: 234, b: "1"}'], 'E1012:', 1) - CheckDefExecAndScriptFailure(['var x: dict = {a: "x", b: 134}'], 'E1012:', 1) + v9.CheckDefAndScriptFailure(["var x = #{key: 8}"], 'E1170:', 1) + v9.CheckDefAndScriptFailure(["var x = 'a' #{a: 1}"], 'E1170:', 1) + v9.CheckDefAndScriptFailure(["var x = 'a' .. #{a: 1}"], 'E1170:', 1) + v9.CheckDefAndScriptFailure(["var x = true ? #{a: 1}"], 'E1170:', 1) + + v9.CheckDefAndScriptFailure(["var x = {a:8}"], 'E1069:', 1) + v9.CheckDefAndScriptFailure(["var x = {a : 8}"], 'E1068:', 1) + v9.CheckDefAndScriptFailure(["var x = {a :8}"], 'E1068:', 1) + v9.CheckDefAndScriptFailure(["var x = {a: 8 , b: 9}"], 'E1068:', 1) + v9.CheckDefAndScriptFailure(["var x = {a: 1,b: 2}"], 'E1069:', 1) + + v9.CheckDefAndScriptFailure(["var x = {xxx}"], 'E720:', 1) + v9.CheckDefAndScriptFailure(["var x = {xxx: 1", "var y = 2"], 'E722:', 2) + v9.CheckDefFailure(["var x = {xxx: 1,"], 'E723:', 2) + v9.CheckScriptFailure(['vim9script', "var x = {xxx: 1,"], 'E723:', 2) + v9.CheckDefAndScriptFailure(["var x = {['a']: xxx}"], ['E1001:', 'E121:'], 1) + v9.CheckDefAndScriptFailure(["var x = {a: 1, a: 2}"], 'E721:', 1) + v9.CheckDefExecAndScriptFailure(["var x = g:anint.member"], ['E715:', 'E488:'], 1) + v9.CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1) + + v9.CheckDefExecAndScriptFailure(['var x: dict = {a: 234, b: "1"}'], 'E1012:', 1) + v9.CheckDefExecAndScriptFailure(['var x: dict = {a: "x", b: 134}'], 'E1012:', 1) + v9.CheckDefExecAndScriptFailure(['var x: dict = {a: 234, b: "1"}'], 'E1012:', 1) + v9.CheckDefExecAndScriptFailure(['var x: dict = {a: "x", b: 134}'], 'E1012:', 1) # invalid types for the key - CheckDefAndScriptFailure(["var x = {[[1, 2]]: 0}"], ['E1105:', 'E730:'], 1) + v9.CheckDefAndScriptFailure(["var x = {[[1, 2]]: 0}"], ['E1105:', 'E730:'], 1) - CheckDefFailure(['var x = ({'], 'E723:', 2) - CheckScriptFailure(['vim9script', 'var x = ({'], 'E723:', 2) - CheckDefExecAndScriptFailure(['{}[getftype("file")]'], 'E716: Key not present in Dictionary: ""', 1) + v9.CheckDefFailure(['var x = ({'], 'E723:', 2) + v9.CheckScriptFailure(['vim9script', 'var x = ({'], 'E723:', 2) + v9.CheckDefExecAndScriptFailure(['{}[getftype("file")]'], 'E716: Key not present in Dictionary: ""', 1) enddef def Test_expr8_dict_vim9script() @@ -2484,13 +2484,13 @@ def Test_expr8_dict_vim9script() var dd = {k: 123->len()} assert_equal(3, dd.k) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var d = { ["one"]: "one", ["two"]: "two", } assert_equal({one: 'one', two: 'two'}, d) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var d = {one: 1, @@ -2498,57 +2498,57 @@ def Test_expr8_dict_vim9script() } assert_equal({one: 1, two: 2}, d) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var d = {one:1, two: 2} END - CheckDefAndScriptFailure(lines, 'E1069:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1069:', 1) lines =<< trim END var d = {one: 1,two: 2} END - CheckDefAndScriptFailure(lines, 'E1069:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1069:', 1) lines =<< trim END var d = {one : 1} END - CheckDefAndScriptFailure(lines, 'E1068:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1068:', 1) lines =<< trim END var d = {one:1} END - CheckDefAndScriptFailure(lines, 'E1069:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1069:', 1) lines =<< trim END var d = {one: 1 , two: 2} END - CheckDefAndScriptFailure(lines, 'E1068:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1068:', 1) lines =<< trim END var l: dict = {a: 234, b: 'x'} END - CheckDefAndScriptFailure(lines, 'E1012:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) lines =<< trim END var l: dict = {a: 'x', b: 234} END - CheckDefAndScriptFailure(lines, 'E1012:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) lines =<< trim END var l: dict = {a: 'x', b: 234} END - CheckDefAndScriptFailure(lines, 'E1012:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) lines =<< trim END var l: dict = {a: 234, b: 'x'} END - CheckDefAndScriptFailure(lines, 'E1012:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) lines =<< trim END var d = {['a']: 234, ['b': 'x'} END - CheckDefAndScriptFailure(lines, 'E1139:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1139:', 1) lines =<< trim END def Func() @@ -2556,13 +2556,13 @@ def Test_expr8_dict_vim9script() enddef defcompile END - CheckDefAndScriptFailure(lines, 'E1139:', 0) + v9.CheckDefAndScriptFailure(lines, 'E1139:', 0) lines =<< trim END var d = {'a': END - CheckDefFailure(lines, 'E723:', 2) - CheckScriptFailure(['vim9script'] + lines, 'E15:', 2) + v9.CheckDefFailure(lines, 'E723:', 2) + v9.CheckScriptFailure(['vim9script'] + lines, 'E15:', 2) lines =<< trim END def Func() @@ -2570,7 +2570,7 @@ def Test_expr8_dict_vim9script() enddef defcompile END - CheckDefAndScriptFailure(lines, 'E723:', 0) + v9.CheckDefAndScriptFailure(lines, 'E723:', 0) lines =<< trim END def Failing() @@ -2579,9 +2579,9 @@ def Test_expr8_dict_vim9script() var dict = {name: Failing} END if has('channel') - CheckDefAndScriptFailure(lines, 'E119:', 0) + v9.CheckDefAndScriptFailure(lines, 'E119:', 0) else - CheckDefAndScriptFailure(lines, 'E117:', 0) + v9.CheckDefAndScriptFailure(lines, 'E117:', 0) endif lines =<< trim END @@ -2589,7 +2589,7 @@ def Test_expr8_dict_vim9script() var x = 99 assert_equal({x: 99}, s:) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_expr8_dict_in_block() @@ -2609,7 +2609,7 @@ def Test_expr8_dict_in_block() assert_equal({key: 'value'}, g:global) unlet g:global END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delcommand MyCommand delcommand YourCommand @@ -2631,7 +2631,7 @@ def Test_expr8_call_2bool() TestBrokenCall() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef let g:oneString = 'one' @@ -2656,11 +2656,11 @@ def Test_expr_member() assert_equal('one', {one: 'one'}.one) assert_equal('one', {one: 'one'}[g:oneString]) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(["var x = g:dict_one.#$!"], ['E1002:', 'E15:'], 1) - CheckDefExecAndScriptFailure(["var d: dict", "echo d['a']"], 'E716:', 2) - CheckDefExecAndScriptFailure(["var d: dict", "d = g:list_empty"], 'E1012: Type mismatch; expected dict but got list', 2) + v9.CheckDefAndScriptFailure(["var x = g:dict_one.#$!"], ['E1002:', 'E15:'], 1) + v9.CheckDefExecAndScriptFailure(["var d: dict", "echo d['a']"], 'E716:', 2) + v9.CheckDefExecAndScriptFailure(["var d: dict", "d = g:list_empty"], 'E1012: Type mismatch; expected dict but got list', 2) enddef def Test_expr8_any_index_slice() @@ -2756,16 +2756,16 @@ def Test_expr8_any_index_slice() assert_equal(2, g:testdict['b']) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefExecAndScriptFailure(['echo g:testblob[2]'], 'E979:', 1) - CheckDefExecAndScriptFailure(['echo g:testblob[-3]'], 'E979:', 1) + v9.CheckDefExecAndScriptFailure(['echo g:testblob[2]'], 'E979:', 1) + v9.CheckDefExecAndScriptFailure(['echo g:testblob[-3]'], 'E979:', 1) - CheckDefExecAndScriptFailure(['echo g:testlist[4]'], 'E684: list index out of range: 4', 1) - CheckDefExecAndScriptFailure(['echo g:testlist[-5]'], 'E684:', 1) + v9.CheckDefExecAndScriptFailure(['echo g:testlist[4]'], 'E684: list index out of range: 4', 1) + v9.CheckDefExecAndScriptFailure(['echo g:testlist[-5]'], 'E684:', 1) - CheckDefExecAndScriptFailure(['echo g:testdict["a" : "b"]'], 'E719:', 1) - CheckDefExecAndScriptFailure(['echo g:testdict[1]'], 'E716:', 1) + v9.CheckDefExecAndScriptFailure(['echo g:testdict["a" : "b"]'], 'E719:', 1) + v9.CheckDefExecAndScriptFailure(['echo g:testdict[1]'], 'E716:', 1) unlet g:teststring unlet g:testblob @@ -2790,7 +2790,7 @@ def Test_expr_member_vim9script() 'one' ]) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var l = [1, @@ -2810,7 +2810,7 @@ def Test_expr_member_vim9script() : ]) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def SetSomeVar() @@ -2837,11 +2837,11 @@ def Test_expr8_option() var sval: string = &path # check v_lock is cleared (requires using valgrind, doesn't always show) - SetSomeVar() + g:SetSomeVar() b:someVar = 0 unlet b:someVar END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_environment() @@ -2850,10 +2850,10 @@ def Test_expr8_environment() assert_equal('testvar', $TESTVAR) assert_equal('', $ASDF_ASD_XXX) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(["var x = $$$"], ['E1002:', 'E15:'], 1) - CheckDefAndScriptFailure(["$"], ['E1002:', 'E15:'], 1) + v9.CheckDefAndScriptFailure(["var x = $$$"], ['E1002:', 'E15:'], 1) + v9.CheckDefAndScriptFailure(["$"], ['E1002:', 'E15:'], 1) enddef def Test_expr8_register() @@ -2876,9 +2876,9 @@ def Test_expr8_register() @= = 'equal' assert_equal('equal', @=) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefAndScriptFailure(["@. = 'yes'"], ['E354:', 'E488:'], 1) + v9.CheckDefAndScriptFailure(["@. = 'yes'"], ['E354:', 'E488:'], 1) enddef " This is slow when run under valgrind. @@ -2908,7 +2908,7 @@ def Test_expr8_namespace() assert_equal('xxx', get(t:, 'no_var', 'xxx')) unlet t:some_var END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_namespace_loop_def() @@ -2926,7 +2926,7 @@ def Test_expr8_namespace_loop_def() assert_equal(0, exists) assert_equal(100000, exists_not) END - CheckDefSuccess(lines) + v9.CheckDefSuccess(lines) enddef " NOTE: this is known to be slow. To skip use: @@ -2947,7 +2947,7 @@ def Test_expr8_namespace_loop_script() assert_equal(0, exists) assert_equal(100000, exists_not) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_expr8_parens() @@ -2979,7 +2979,7 @@ def Test_expr8_parens() ) assert_equal('onetwo', s) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_negate_add() @@ -2993,38 +2993,38 @@ def Test_expr8_negate_add() assert_equal(-88, - nr) assert_equal(88, + nr) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var n = 12 echo ++n END - CheckDefAndScriptFailure(lines, 'E15:') + v9.CheckDefAndScriptFailure(lines, 'E15:') lines =<< trim END var n = 12 echo --n END - CheckDefAndScriptFailure(lines, 'E15:') + v9.CheckDefAndScriptFailure(lines, 'E15:') lines =<< trim END var n = 12 echo +-n END - CheckDefAndScriptFailure(lines, 'E15:') + v9.CheckDefAndScriptFailure(lines, 'E15:') lines =<< trim END var n = 12 echo -+n END - CheckDefAndScriptFailure(lines, 'E15:') + v9.CheckDefAndScriptFailure(lines, 'E15:') lines =<< trim END var n = 12 echo - -n END - CheckDefAndScriptFailure(lines, 'E15:') + v9.CheckDefAndScriptFailure(lines, 'E15:') lines =<< trim END var n = 12 echo + +n END - CheckDefAndScriptFailure(lines, 'E15:') + v9.CheckDefAndScriptFailure(lines, 'E15:') enddef def LegacyReturn(): string @@ -3043,9 +3043,9 @@ def Test_expr8_legacy_script() call assert_equal('legacy', GetLocal()) call assert_equal('legacy', GetLocalPrefix()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) - assert_equal('ok', LegacyReturn()) + assert_equal('ok', g:LegacyReturn()) lines =<< trim END vim9script @@ -3054,7 +3054,7 @@ def Test_expr8_legacy_script() enddef echo GetNumber() END - CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got list') + v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got list') enddef def Echo(arg: any): string @@ -3067,21 +3067,41 @@ enddef def Test_expr8_call() var lines =<< trim END - assert_equal('yes', 'yes'->Echo()) + assert_equal('yes', 'yes'->g:Echo()) assert_equal(true, !range(5)->empty()) assert_equal([0, 1, 2], 3->range()) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) assert_equal('yes', 'yes' ->s:Echo4Arg()) - CheckDefAndScriptFailure(["var x = 'yes'->Echo"], 'E107:', 1) - CheckDefAndScriptFailure([ + v9.CheckDefAndScriptFailure(["var x = 'yes'->g:Echo"], 'E107:', 1) + v9.CheckDefAndScriptFailure([ "var x = substitute ('x', 'x', 'x', 'x')" ], ['E1001:', 'E121:'], 1) - CheckDefAndScriptFailure(["var Ref = function('len' [1, 2])"], ['E1123:', 'E116:'], 1) + v9.CheckDefAndScriptFailure(["var Ref = function('len' [1, 2])"], ['E1123:', 'E116:'], 1) +enddef + +def g:ExistingGloba(): string + return 'existing' +enddef + +def Test_expr8_call_global() + assert_equal('existing', g:ExistingGloba()) + + def g:DefinedLater(): string + return 'later' + enddef + assert_equal('later', g:DefinedLater()) + + var lines =<< trim END + echo ExistingGlobal() + END + v9.CheckDefAndScriptFailure(lines, 'E117: Unknown function: ExistingGlobal') +enddef +def Test_expr8_call_autoload() var auto_lines =<< trim END def g:some#func(): string return 'found' @@ -3137,7 +3157,7 @@ def Test_expr8_method_call() -> sort() assert_equal([1, 2, 3], sorted) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END def SetNumber(n: number) @@ -3165,14 +3185,14 @@ def Test_expr8_method_call() unlet g:number END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END def RetVoid() enddef RetVoid()->byteidx(3) END - CheckDefExecFailure(lines, 'E1013:') + v9.CheckDefExecFailure(lines, 'E1013:') enddef def Test_expr8_method_call_linebreak() @@ -3188,7 +3208,7 @@ def Test_expr8_method_call_linebreak() defcompile assert_equal('', v:errmsg) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_expr8_method_call_import() @@ -3212,7 +3232,7 @@ def Test_expr8_method_call_import() assert_equal([0, 10, 40, 90, 160], Test()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -3220,7 +3240,7 @@ def Test_expr8_method_call_import() echo range(5)->Xsquare.NoSuchFunc() END - CheckScriptFailure(lines, 'E1048: Item not found in script: NoSuchFunc') + v9.CheckScriptFailure(lines, 'E1048: Item not found in script: NoSuchFunc') delete('Xsquare.vim') enddef @@ -3273,7 +3293,7 @@ def Test_expr8_not() assert_equal(false, ![1, 2, 3]->reverse()) assert_equal(true, ![]->reverse()) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef let g:anumber = 42 @@ -3284,57 +3304,57 @@ def Test_expr8_negate() assert_equal(-1, -nr) assert_equal(-42, -g:anumber) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef func Test_expr8_fails() - call CheckDefFailure(["var x = (12"], "E1097:", 3) - call CheckScriptFailure(['vim9script', "var x = (12"], 'E110:', 2) + call v9.CheckDefFailure(["var x = (12"], "E1097:", 3) + call v9.CheckScriptFailure(['vim9script', "var x = (12"], 'E110:', 2) - call CheckDefAndScriptFailure(["var x = -'xx'"], "E1030:", 1) - call CheckDefAndScriptFailure(["var x = +'xx'"], "E1030:", 1) - call CheckDefAndScriptFailure(["var x = -0z12"], "E974:", 1) - call CheckDefExecAndScriptFailure(["var x = -[8]"], ["E1012:", 'E745:'], 1) - call CheckDefExecAndScriptFailure(["var x = -{a: 1}"], ["E1012:", 'E728:'], 1) + call v9.CheckDefAndScriptFailure(["var x = -'xx'"], "E1030:", 1) + call v9.CheckDefAndScriptFailure(["var x = +'xx'"], "E1030:", 1) + call v9.CheckDefAndScriptFailure(["var x = -0z12"], "E974:", 1) + call v9.CheckDefExecAndScriptFailure(["var x = -[8]"], ["E1012:", 'E745:'], 1) + call v9.CheckDefExecAndScriptFailure(["var x = -{a: 1}"], ["E1012:", 'E728:'], 1) - call CheckDefAndScriptFailure(["var x = @"], "E1002:", 1) - call CheckDefAndScriptFailure(["var x = @<"], "E354:", 1) + call v9.CheckDefAndScriptFailure(["var x = @"], "E1002:", 1) + call v9.CheckDefAndScriptFailure(["var x = @<"], "E354:", 1) - call CheckDefFailure(["var x = [1, 2"], "E697:", 2) - call CheckScriptFailure(['vim9script', "var x = [1, 2"], 'E696:', 2) + call v9.CheckDefFailure(["var x = [1, 2"], "E697:", 2) + call v9.CheckScriptFailure(['vim9script', "var x = [1, 2"], 'E696:', 2) - call CheckDefAndScriptFailure(["var x = [notfound]"], ["E1001:", 'E121:'], 1) + call v9.CheckDefAndScriptFailure(["var x = [notfound]"], ["E1001:", 'E121:'], 1) - call CheckDefAndScriptFailure(["var X = () => 123)"], 'E488:', 1) - call CheckDefAndScriptFailure(["var x = 123->((x) => x + 5)"], "E107:", 1) + call v9.CheckDefAndScriptFailure(["var X = () => 123)"], 'E488:', 1) + call v9.CheckDefAndScriptFailure(["var x = 123->((x) => x + 5)"], "E107:", 1) - call CheckDefAndScriptFailure(["var x = ¬exist"], 'E113:', 1) - call CheckDefAndScriptFailure(["&grepprg = [343]"], ['E1012:', 'E730:'], 1) + call v9.CheckDefAndScriptFailure(["var x = ¬exist"], 'E113:', 1) + call v9.CheckDefAndScriptFailure(["&grepprg = [343]"], ['E1012:', 'E730:'], 1) - call CheckDefExecAndScriptFailure(["echo s:doesnt_exist"], 'E121:', 1) - call CheckDefExecAndScriptFailure(["echo g:doesnt_exist"], 'E121:', 1) + call v9.CheckDefExecAndScriptFailure(["echo s:doesnt_exist"], 'E121:', 1) + call v9.CheckDefExecAndScriptFailure(["echo g:doesnt_exist"], 'E121:', 1) - call CheckDefAndScriptFailure(["echo a:somevar"], ['E1075:', 'E121:'], 1) - call CheckDefAndScriptFailure(["echo l:somevar"], ['E1075:', 'E121:'], 1) - call CheckDefAndScriptFailure(["echo x:somevar"], ['E1075:', 'E121:'], 1) + call v9.CheckDefAndScriptFailure(["echo a:somevar"], ['E1075:', 'E121:'], 1) + call v9.CheckDefAndScriptFailure(["echo l:somevar"], ['E1075:', 'E121:'], 1) + call v9.CheckDefAndScriptFailure(["echo x:somevar"], ['E1075:', 'E121:'], 1) - call CheckDefExecAndScriptFailure(["var x = +g:astring"], ['E1012:', 'E1030:'], 1) - call CheckDefExecAndScriptFailure(["var x = +g:ablob"], ['E1012:', 'E974:'], 1) - call CheckDefExecAndScriptFailure(["var x = +g:alist"], ['E1012:', 'E745:'], 1) - call CheckDefExecAndScriptFailure(["var x = +g:adict"], ['E1012:', 'E728:'], 1) + call v9.CheckDefExecAndScriptFailure(["var x = +g:astring"], ['E1012:', 'E1030:'], 1) + call v9.CheckDefExecAndScriptFailure(["var x = +g:ablob"], ['E1012:', 'E974:'], 1) + call v9.CheckDefExecAndScriptFailure(["var x = +g:alist"], ['E1012:', 'E745:'], 1) + call v9.CheckDefExecAndScriptFailure(["var x = +g:adict"], ['E1012:', 'E728:'], 1) - call CheckDefAndScriptFailure(["var x = ''", "var y = x.memb"], ['E1229: Expected dictionary for using key "memb", but got string', 'E488:'], 2) + call v9.CheckDefAndScriptFailure(["var x = ''", "var y = x.memb"], ['E1229: Expected dictionary for using key "memb", but got string', 'E488:'], 2) - call CheckDefAndScriptFailure(["'yes'->", "Echo()"], ['E488: Trailing characters: ->', 'E260: Missing name after ->'], 1) + call v9.CheckDefAndScriptFailure(["'yes'->", "Echo()"], ['E488: Trailing characters: ->', 'E260: Missing name after ->'], 1) - call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) - call CheckScriptFailure(['vim9script', "[1, 2->len()"], 'E696:', 2) + call v9.CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) + call v9.CheckScriptFailure(['vim9script', "[1, 2->len()"], 'E696:', 2) - call CheckDefFailure(["{a: 1->len()"], 'E723:', 2) - call CheckScriptFailure(['vim9script', "{a: 1->len()"], 'E722:', 2) + call v9.CheckDefFailure(["{a: 1->len()"], 'E723:', 2) + call v9.CheckScriptFailure(['vim9script', "{a: 1->len()"], 'E722:', 2) - call CheckDefExecFailure(["{['a']: 1->len()"], 'E723:', 2) - call CheckScriptFailure(['vim9script', "{['a']: 1->len()"], 'E722:', 2) + call v9.CheckDefExecFailure(["{['a']: 1->len()"], 'E723:', 2) + call v9.CheckScriptFailure(['vim9script', "{['a']: 1->len()"], 'E722:', 2) endfunc let g:Funcrefs = [function('add')] @@ -3380,7 +3400,7 @@ def Test_expr8_trailing() var d = {key: 123} assert_equal(123, d.key) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_string_subscript() @@ -3438,48 +3458,48 @@ def Test_expr8_string_subscript() assert_equal('sd', g:astring[1 : 2]) assert_equal('asdf', g:astring[:]) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var d = 'asdf'[1 : END - CheckDefFailure(lines, 'E1097:', 3) - CheckScriptFailure(['vim9script'] + lines, 'E15:', 2) + v9.CheckDefFailure(lines, 'E1097:', 3) + v9.CheckScriptFailure(['vim9script'] + lines, 'E15:', 2) lines =<< trim END var d = 'asdf'[1 : xxx] END - CheckDefAndScriptFailure(lines, ['E1001:', 'E121:'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1001:', 'E121:'], 1) lines =<< trim END var d = 'asdf'[1 : 2 END - CheckDefFailure(lines, 'E1097:', 3) - CheckScriptFailure(['vim9script'] + lines, 'E111:', 2) + v9.CheckDefFailure(lines, 'E1097:', 3) + v9.CheckScriptFailure(['vim9script'] + lines, 'E111:', 2) lines =<< trim END var d = 'asdf'[1 : 2 echo d END - CheckDefAndScriptFailure(lines, 'E111:', 2) + v9.CheckDefAndScriptFailure(lines, 'E111:', 2) lines =<< trim END var d = 'asdf'['1'] echo d END - CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"'], 1) lines =<< trim END var d = 'asdf'['1' : 2] echo d END - CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"'], 1) lines =<< trim END var d = 'asdf'[1 : '2'] echo d END - CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "2"'], 1) + v9.CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "2"'], 1) enddef def Test_expr8_list_subscript() @@ -3510,10 +3530,10 @@ def Test_expr8_list_subscript() assert_equal(2, g:alist[0]) assert_equal([2, 3, 4], g:alist[:]) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines = ['var l = [0, 1, 2]', 'echo l[g:astring : g:theone]'] - CheckDefExecAndScriptFailure(lines, ['E1012:', 'E1030:'], 2) + v9.CheckDefExecAndScriptFailure(lines, ['E1012:', 'E1030:'], 2) lines =<< trim END var ld = [] @@ -3522,7 +3542,7 @@ def Test_expr8_list_subscript() enddef defcompile END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_dict_subscript() @@ -3543,7 +3563,7 @@ def Test_expr8_dict_subscript() enddef defcompile END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_blob_subscript() @@ -3555,7 +3575,7 @@ def Test_expr8_blob_subscript() assert_equal(0x01, g:ablob[0]) assert_equal(0z01ab, g:ablob[:]) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_expr8_subscript_linebreak() @@ -3591,38 +3611,38 @@ def Test_expr8_subscript_linebreak() assert_equal(33, d .one) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var d = {one: 33} assert_equal(33, d. one) END - CheckDefAndScriptFailure(lines, ['E1127:', 'E116:'], 2) + v9.CheckDefAndScriptFailure(lines, ['E1127:', 'E116:'], 2) enddef func Test_expr8_trailing_fails() - call CheckDefAndScriptFailure(['var l = [2]', 'l->((ll) => add(ll, 8))'], 'E107:', 2) - call CheckDefAndScriptFailure(['var l = [2]', 'l->((ll) => add(ll, 8)) ()'], 'E274:', 2) + call v9.CheckDefAndScriptFailure(['var l = [2]', 'l->((ll) => add(ll, 8))'], 'E107:', 2) + call v9.CheckDefAndScriptFailure(['var l = [2]', 'l->((ll) => add(ll, 8)) ()'], 'E274:', 2) endfunc func Test_expr_fails() - call CheckDefAndScriptFailure(["var x = '1'is2"], 'E488:', 1) - call CheckDefAndScriptFailure(["var x = '1'isnot2"], 'E488:', 1) + call v9.CheckDefAndScriptFailure(["var x = '1'is2"], 'E488:', 1) + call v9.CheckDefAndScriptFailure(["var x = '1'isnot2"], 'E488:', 1) - call CheckDefAndScriptFailure(["CallMe ('yes')"], ['E476:', 'E492:'], 1) + call v9.CheckDefAndScriptFailure(["CallMe ('yes')"], ['E476:', 'E492:'], 1) - call CheckDefAndScriptFailure(["CallMe2('yes','no')"], 'E1069:', 1) + call v9.CheckDefAndScriptFailure(["CallMe2('yes','no')"], 'E1069:', 1) - call CheckDefAndScriptFailure(["v:nosuch += 3"], ['E1001:', 'E121:'], 1) - call CheckDefAndScriptFailure(["var v:statusmsg = ''"], 'E1016: Cannot declare a v: variable:', 1) - call CheckDefAndScriptFailure(["var asdf = v:nosuch"], ['E1001:', 'E121:'], 1) + call v9.CheckDefAndScriptFailure(["v:nosuch += 3"], ['E1001:', 'E121:'], 1) + call v9.CheckDefAndScriptFailure(["var v:statusmsg = ''"], 'E1016: Cannot declare a v: variable:', 1) + call v9.CheckDefAndScriptFailure(["var asdf = v:nosuch"], ['E1001:', 'E121:'], 1) - call CheckDefFailure(["echo len('asdf'"], 'E110:', 2) - call CheckScriptFailure(['vim9script', "echo len('asdf'"], 'E116:', 2) + call v9.CheckDefFailure(["echo len('asdf'"], 'E110:', 2) + call v9.CheckScriptFailure(['vim9script', "echo len('asdf'"], 'E116:', 2) - call CheckDefAndScriptFailure(["echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()"], ['E1011:', 'E117:'], 1) - call CheckDefAndScriptFailure(["echo doesnotexist()"], 'E117:', 1) + call v9.CheckDefAndScriptFailure(["echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()"], ['E1011:', 'E117:'], 1) + call v9.CheckDefAndScriptFailure(["echo doesnotexist()"], 'E117:', 1) endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index f495ddfd7..9378c1489 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -3,7 +3,7 @@ source check.vim source term_util.vim source view_util.vim -source vim9.vim +import './vim9.vim' as v9 source screendump.vim func Test_def_basic() @@ -30,13 +30,13 @@ def TestCompilingError() defcompile END writefile(lines, 'XTest_compile_error') - var buf = RunVimInTerminal('-S XTest_compile_error', + var buf = g:RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) - WaitForAssert(() => assert_match('Error detected while compiling command line.*Fails.*Variable not found: nothing', - Term_getlines(buf, range(1, 9)))) + g:WaitForAssert(() => assert_match('Error detected while compiling command line.*Fails.*Variable not found: nothing', + g:Term_getlines(buf, range(1, 9)))) # clean up - StopVimInTerminal(buf) + g:StopVimInTerminal(buf) delete('XTest_compile_error') enddef @@ -64,12 +64,12 @@ def TestCompilingErrorInTry() lines[1] = 'set rtp=' .. getcwd() .. '/Xdir' writefile(lines, 'XTest_compile_error') - var buf = RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) - WaitForAssert(() => assert_match('Error detected while compiling command line.*function script#OnlyCompiled.*Invalid command: invalid', - Term_getlines(buf, range(1, 9)))) + var buf = g:RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) + g:WaitForAssert(() => assert_match('Error detected while compiling command line.*function script#OnlyCompiled.*Invalid command: invalid', + g:Term_getlines(buf, range(1, 9)))) # clean up - StopVimInTerminal(buf) + g:StopVimInTerminal(buf) delete('XTest_compile_error') delete('Xdir', 'rf') enddef @@ -87,7 +87,7 @@ def Test_compile_error_in_called_function() silent! Foo() Bar() END - CheckScriptFailureList(lines, ['E1012:', 'E1191:']) + v9.CheckScriptFailureList(lines, ['E1012:', 'E1191:']) enddef def Test_wrong_function_name() @@ -97,7 +97,7 @@ def Test_wrong_function_name() echo 'foo' endfunc END - CheckScriptFailure(lines, 'E128:') + v9.CheckScriptFailure(lines, 'E128:') lines =<< trim END vim9script @@ -105,7 +105,7 @@ def Test_wrong_function_name() echo 'foo' enddef END - CheckScriptFailure(lines, 'E128:') + v9.CheckScriptFailure(lines, 'E128:') enddef def Test_autoload_name_mismatch() @@ -126,7 +126,7 @@ def Test_autoload_name_mismatch() lines =<< trim END call script#Function() END - CheckScriptFailure(lines, 'E746:', 2) + v9.CheckScriptFailure(lines, 'E746:', 2) &rtp = save_rtp delete(dir, 'rf') @@ -154,7 +154,7 @@ def Test_autoload_names() assert_equal('no', foobar#var) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) &rtp = save_rtp delete(dir, 'rf') @@ -179,7 +179,7 @@ def Test_autoload_error_in_script() # The error in the autoload script cannot be checked with assert_fails(), use # CheckDefSuccess() instead of CheckDefFailure() try - CheckDefSuccess(['scripterror#function()']) + v9.CheckDefSuccess(['scripterror#function()']) catch assert_match('E121: Undefined variable: 0', v:exception) endtry @@ -198,7 +198,7 @@ def Test_autoload_error_in_script() writefile(lines, dir .. '/scriptcaught.vim') g:called_function = 'no' - CheckDefSuccess(['scriptcaught#function()']) + v9.CheckDefSuccess(['scriptcaught#function()']) assert_match('E121: Undefined variable: 0', g:caught) assert_equal('yes', g:called_function) @@ -206,11 +206,11 @@ def Test_autoload_error_in_script() delete(dir, 'rf') enddef -def CallRecursive(n: number): number +def s:CallRecursive(n: number): number return CallRecursive(n + 1) enddef -def CallMapRecursive(l: list): number +def s:CallMapRecursive(l: list): number return map(l, (_, v) => CallMapRecursive([v]))[0] enddef @@ -243,7 +243,7 @@ def Test_endfunc_enddef() endfunc enddef END - CheckScriptFailure(lines, 'E1151:', 3) + v9.CheckScriptFailure(lines, 'E1151:', 3) lines =<< trim END def Test() @@ -252,7 +252,7 @@ def Test_endfunc_enddef() enddef enddef END - CheckScriptFailure(lines, 'E1152:', 4) + v9.CheckScriptFailure(lines, 'E1152:', 4) lines =<< trim END def Ok() @@ -262,7 +262,7 @@ def Test_endfunc_enddef() echo 'hello' enddef there END - CheckScriptFailure(lines, 'E1173: Text found after enddef: there', 6) + v9.CheckScriptFailure(lines, 'E1173: Text found after enddef: there', 6) enddef def Test_missing_endfunc_enddef() @@ -272,7 +272,7 @@ def Test_missing_endfunc_enddef() echo 'test' endef END - CheckScriptFailure(lines, 'E1057:', 2) + v9.CheckScriptFailure(lines, 'E1057:', 2) lines =<< trim END vim9script @@ -280,7 +280,7 @@ def Test_missing_endfunc_enddef() echo 'test' enfffunc END - CheckScriptFailure(lines, 'E126:', 2) + v9.CheckScriptFailure(lines, 'E126:', 2) enddef def Test_white_space_before_paren() @@ -290,7 +290,7 @@ def Test_white_space_before_paren() echo 'test' enddef END - CheckScriptFailure(lines, 'E1068:', 2) + v9.CheckScriptFailure(lines, 'E1068:', 2) lines =<< trim END vim9script @@ -298,21 +298,21 @@ def Test_white_space_before_paren() echo 'test' endfunc END - CheckScriptFailure(lines, 'E1068:', 2) + v9.CheckScriptFailure(lines, 'E1068:', 2) lines =<< trim END def Test () echo 'test' enddef END - CheckScriptFailure(lines, 'E1068:', 1) + v9.CheckScriptFailure(lines, 'E1068:', 1) lines =<< trim END func Test () echo 'test' endfunc END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_enddef_dict_key() @@ -338,8 +338,8 @@ def ReturnGlobal(): number enddef def Test_return_something() - ReturnString()->assert_equal('string') - ReturnNumber()->assert_equal(123) + g:ReturnString()->assert_equal('string') + g:ReturnNumber()->assert_equal(123) assert_fails('ReturnGlobal()', 'E1012: Type mismatch; expected number but got string', '', 1, 'ReturnGlobal') var lines =<< trim END @@ -354,7 +354,7 @@ def Test_return_something() enddef defcompile END - CheckScriptFailure(lines, 'E1096:') + v9.CheckScriptFailure(lines, 'E1096:') enddef def Test_check_argument_type() @@ -370,25 +370,25 @@ def Test_check_argument_type() disass Func Func() END - CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got bool', 2) + v9.CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got bool', 2) enddef def Test_missing_return() - CheckDefFailure(['def Missing(): number', + v9.CheckDefFailure(['def Missing(): number', ' if g:cond', ' echo "no return"', ' else', ' return 0', ' endif' 'enddef'], 'E1027:') - CheckDefFailure(['def Missing(): number', + v9.CheckDefFailure(['def Missing(): number', ' if g:cond', ' return 1', ' else', ' echo "no return"', ' endif' 'enddef'], 'E1027:') - CheckDefFailure(['def Missing(): number', + v9.CheckDefFailure(['def Missing(): number', ' if g:cond', ' return 1', ' else', @@ -409,7 +409,7 @@ def Test_return_bool() enddef defcompile END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef let s:nothing = 0 @@ -422,7 +422,7 @@ def ReturnNothing() enddef def Test_return_nothing() - ReturnNothing() + g:ReturnNothing() s:nothing->assert_equal(1) enddef @@ -434,7 +434,7 @@ def Test_return_invalid() enddef defcompile END - CheckScriptFailure(lines, 'E1010:', 2) + v9.CheckScriptFailure(lines, 'E1010:', 2) lines =<< trim END vim9script @@ -448,8 +448,8 @@ def Test_return_invalid() echo Test(Inc) END # doing this twice was leaking memory - CheckScriptFailure(lines, 'E1010:') - CheckScriptFailure(lines, 'E1010:') + v9.CheckScriptFailure(lines, 'E1010:') + v9.CheckScriptFailure(lines, 'E1010:') enddef def Test_return_list_any() @@ -464,7 +464,7 @@ def Test_return_list_any() enddef echo Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -475,10 +475,10 @@ def Test_return_list_any() enddef echo Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef -func Increment() +func s:Increment() let g:counter += 1 endfunc @@ -493,7 +493,7 @@ def Test_call_ufunc_count() unlet g:counter enddef -def MyVarargs(arg: string, ...rest: list): string +def s:MyVarargs(arg: string, ...rest: list): string var res = arg for s in rest res ..= ',' .. s @@ -508,23 +508,23 @@ def Test_call_varargs() enddef def Test_call_white_space() - CheckDefAndScriptFailure(["call Test ('text')"], ['E476:', 'E1068:']) + v9.CheckDefAndScriptFailure(["call Test ('text')"], ['E476:', 'E1068:']) enddef def MyDefaultArgs(name = 'string'): string return name enddef -def MyDefaultSecond(name: string, second: bool = true): string +def s:MyDefaultSecond(name: string, second: bool = true): string return second ? name : 'none' enddef def Test_call_default_args() - MyDefaultArgs()->assert_equal('string') - MyDefaultArgs(v:none)->assert_equal('string') - MyDefaultArgs('one')->assert_equal('one') - assert_fails('MyDefaultArgs("one", "two")', 'E118:', '', 4, 'Test_call_default_args') + g:MyDefaultArgs()->assert_equal('string') + g:MyDefaultArgs(v:none)->assert_equal('string') + g:MyDefaultArgs('one')->assert_equal('one') + assert_fails('g:MyDefaultArgs("one", "two")', 'E118:', '', 4, 'Test_call_default_args') MyDefaultSecond('test')->assert_equal('test') MyDefaultSecond('test', true)->assert_equal('test') @@ -549,13 +549,13 @@ def Test_call_default_args() DefArg(1234)->assert_equal('12341234') DefArg("ok")->assert_equal('okok') END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckScriptFailure(['def Func(arg: number = asdf)', 'enddef', 'defcompile'], 'E1001:') + v9.CheckScriptFailure(['def Func(arg: number = asdf)', 'enddef', 'defcompile'], 'E1001:') delfunc g:Func - CheckScriptFailure(['def Func(arg: number = "text")', 'enddef', 'defcompile'], 'E1013: Argument 1: type mismatch, expected number but got string') + v9.CheckScriptFailure(['def Func(arg: number = "text")', 'enddef', 'defcompile'], 'E1013: Argument 1: type mismatch, expected number but got string') delfunc g:Func - CheckDefFailure(['def Func(x: number = )', 'enddef'], 'E15:') + v9.CheckDefFailure(['def Func(x: number = )', 'enddef'], 'E15:') lines =<< trim END vim9script @@ -563,7 +563,7 @@ def Test_call_default_args() enddef defcompile END - CheckScriptFailure(lines, 'E1001: Variable not found: b') + v9.CheckScriptFailure(lines, 'E1001: Variable not found: b') # using script variable requires matching type or type cast when executed lines =<< trim END @@ -574,8 +574,8 @@ def Test_call_default_args() enddef defcompile END - CheckScriptSuccess(lines + ['a = "text"', 'Func()']) - CheckScriptFailure(lines + ['a = 123', 'Func()'], 'E1013: Argument 1: type mismatch, expected string but got number') + v9.CheckScriptSuccess(lines + ['a = "text"', 'Func()']) + v9.CheckScriptFailure(lines + ['a = 123', 'Func()'], 'E1013: Argument 1: type mismatch, expected string but got number') # using global variable does not require type cast lines =<< trim END @@ -586,10 +586,10 @@ def Test_call_default_args() g:str = 'works' Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef -def FuncWithComment( # comment +def s:FuncWithComment( # comment a: number, #comment b: bool, # comment c: string) #comment @@ -606,7 +606,7 @@ def Test_func_with_comments() arg: string) enddef END - CheckScriptFailure(lines, 'E125:', 1) + v9.CheckScriptFailure(lines, 'E125:', 1) lines =<< trim END def Func( @@ -614,7 +614,7 @@ def Test_func_with_comments() ) enddef END - CheckScriptFailure(lines, 'E475:', 2) + v9.CheckScriptFailure(lines, 'E475:', 2) lines =<< trim END def Func( @@ -622,7 +622,7 @@ def Test_func_with_comments() )# comment enddef END - CheckScriptFailure(lines, 'E488:', 3) + v9.CheckScriptFailure(lines, 'E488:', 3) enddef def Test_nested_function() @@ -636,11 +636,11 @@ def Test_nested_function() endfunc NestedFunc(':func')->assert_equal('nested :func') - CheckDefFailure(['def Nested()', 'enddef', 'Nested(66)'], 'E118:') - CheckDefFailure(['def Nested(arg: string)', 'enddef', 'Nested()'], 'E119:') + v9.CheckDefFailure(['def Nested()', 'enddef', 'Nested(66)'], 'E118:') + v9.CheckDefFailure(['def Nested(arg: string)', 'enddef', 'Nested()'], 'E119:') - CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:') - CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:') + v9.CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:') + v9.CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:') var lines =<< trim END def Outer() @@ -651,7 +651,7 @@ def Test_nested_function() enddef enddef END - CheckDefFailure(lines, 'E1073:') + v9.CheckDefFailure(lines, 'E1073:') lines =<< trim END def Outer() @@ -662,7 +662,7 @@ def Test_nested_function() enddef enddef END - CheckDefFailure(lines, 'E1117:') + v9.CheckDefFailure(lines, 'E1117:') lines =<< trim END vim9script @@ -675,7 +675,7 @@ def Test_nested_function() Outer() Inner() END - CheckScriptFailure(lines, 'E117: Unknown function: Inner') + v9.CheckScriptFailure(lines, 'E117: Unknown function: Inner') assert_equal('ok', g:result) unlet g:result @@ -696,7 +696,7 @@ def Test_nested_function() assert_equal(1, Test()) assert_equal(2, Test()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # also works when "thecount" is inside the "if" block lines =<< trim END @@ -715,7 +715,7 @@ def Test_nested_function() assert_equal(1, Test()) assert_equal(2, Test()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -726,7 +726,7 @@ def Test_nested_function() enddef defcompile END - CheckScriptFailure(lines, 'E1173: Text found after enddef: burp', 3) + v9.CheckScriptFailure(lines, 'E1173: Text found after enddef: burp', 3) enddef def Test_not_nested_function() @@ -759,7 +759,7 @@ def Test_nested_global_function() g:Inner()->assert_equal('inner') delfunc g:Inner END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -779,7 +779,7 @@ def Test_nested_global_function() g:Inner()->assert_equal('inner') delfunc g:Inner END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -792,7 +792,7 @@ def Test_nested_global_function() Outer() Outer() END - CheckScriptFailure(lines, "E122:") + v9.CheckScriptFailure(lines, "E122:") delfunc g:Inner lines =<< trim END @@ -805,7 +805,7 @@ def Test_nested_global_function() enddef Outer() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delfunc g:Inner lines =<< trim END @@ -820,7 +820,7 @@ def Test_nested_global_function() enddef defcompile END - CheckScriptFailure(lines, "E1073:", 1) + v9.CheckScriptFailure(lines, "E1073:", 1) lines =<< trim END vim9script @@ -831,7 +831,7 @@ def Test_nested_global_function() echo 'script' enddef END - CheckScriptFailure(lines, "E1073:", 5) + v9.CheckScriptFailure(lines, "E1073:", 5) enddef def DefListAll() @@ -867,7 +867,7 @@ def Test_nested_def_list() enddef defcompile END - CheckScriptFailure(lines, 'E476:', 1) + v9.CheckScriptFailure(lines, 'E476:', 1) enddef def Test_global_local_function() @@ -883,7 +883,7 @@ def Test_global_local_function() Func()->assert_equal('local') delfunc g:Func END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -892,7 +892,7 @@ def Test_global_local_function() enddef s:Funcy() END - CheckScriptFailure(lines, 'E117:') + v9.CheckScriptFailure(lines, 'E117:') enddef def Test_local_function_shadows_global() @@ -909,7 +909,7 @@ def Test_local_function_shadows_global() AnotherFunc()->assert_equal(7) delfunc g:Gfunc END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -921,10 +921,10 @@ def Test_local_function_shadows_global() enddef AnotherFunc() END - CheckScriptFailure(lines, 'E705:') + v9.CheckScriptFailure(lines, 'E705:') delfunc g:Func - # global function is found without g: prefix + # global function is not found with g: prefix lines =<< trim END vim9script def g:Func(): string @@ -934,9 +934,9 @@ def Test_local_function_shadows_global() return Func() enddef assert_equal('global', AnotherFunc()) - delfunc g:Func END - CheckScriptSuccess(lines) + v9.CheckScriptFailure(lines, 'E117:') + delfunc g:Func lines =<< trim END vim9script @@ -946,7 +946,7 @@ def Test_local_function_shadows_global() assert_equal('global', Func()) delfunc g:Func END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # This does not shadow "i" which is visible only inside the for loop lines =<< trim END @@ -961,7 +961,7 @@ def Test_local_function_shadows_global() Foo(i) endfor END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef func TakesOneArg(arg) @@ -969,10 +969,10 @@ func TakesOneArg(arg) endfunc def Test_call_wrong_args() - CheckDefFailure(['TakesOneArg()'], 'E119:') - CheckDefFailure(['TakesOneArg(11, 22)'], 'E118:') - CheckDefFailure(['bufnr(xxx)'], 'E1001:') - CheckScriptFailure(['def Func(Ref: func(s: string))'], 'E475:') + v9.CheckDefFailure(['g:TakesOneArg()'], 'E119:') + v9.CheckDefFailure(['g:TakesOneArg(11, 22)'], 'E118:') + v9.CheckDefFailure(['bufnr(xxx)'], 'E1001:') + v9.CheckScriptFailure(['def Func(Ref: func(s: string))'], 'E475:') var lines =<< trim END vim9script @@ -981,7 +981,7 @@ def Test_call_wrong_args() enddef Func([]) END - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got list', 5) + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got list', 5) # argument name declared earlier is found when declaring a function lines =<< trim END @@ -991,7 +991,7 @@ def Test_call_wrong_args() echo nr enddef END - CheckScriptFailure(lines, 'E1168:') + v9.CheckScriptFailure(lines, 'E1168:') # argument name declared later is only found when compiling lines =<< trim END @@ -1001,8 +1001,8 @@ def Test_call_wrong_args() enddef var name = 'piet' END - CheckScriptSuccess(lines) - CheckScriptFailure(lines + ['defcompile'], 'E1168:') + v9.CheckScriptSuccess(lines) + v9.CheckScriptFailure(lines + ['defcompile'], 'E1168:') lines =<< trim END vim9script @@ -1062,10 +1062,10 @@ def Test_call_funcref_wrong_args() enddef Testme() END - CheckScriptSuccess(head + ["funcMap['func']('str', 123, [1, 2, 3])"] + tail) + v9.CheckScriptSuccess(head + ["funcMap['func']('str', 123, [1, 2, 3])"] + tail) - CheckScriptFailure(head + ["funcMap['func']('str', 123)"] + tail, 'E119:') - CheckScriptFailure(head + ["funcMap['func']('str', 123, [1], 4)"] + tail, 'E118:') + v9.CheckScriptFailure(head + ["funcMap['func']('str', 123)"] + tail, 'E119:') + v9.CheckScriptFailure(head + ["funcMap['func']('str', 123, [1], 4)"] + tail, 'E118:') var lines =<< trim END vim9script @@ -1073,7 +1073,7 @@ def Test_call_funcref_wrong_args() Ref = (j) => !j echo Ref(false) END - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4) + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4) lines =<< trim END vim9script @@ -1081,7 +1081,7 @@ def Test_call_funcref_wrong_args() Ref = (j) => !j call Ref(false) END - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4) + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4) enddef def Test_call_lambda_args() @@ -1093,42 +1093,42 @@ def Test_call_lambda_args() assert_equal('xyz', ((a: string): string => a)('xyz')) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) - CheckDefFailure(['echo ((i) => 0)()'], + v9.CheckDefFailure(['echo ((i) => 0)()'], 'E119: Not enough arguments for function: ((i) => 0)()') lines =<< trim END var Ref = (x: number, y: number) => x + y echo Ref(1, 'x') END - CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got string') + v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got string') lines =<< trim END var Ref: func(job, string, number) Ref = (x, y) => 0 END - CheckDefAndScriptFailure(lines, 'E1012:') + v9.CheckDefAndScriptFailure(lines, 'E1012:') lines =<< trim END var Ref: func(job, string) Ref = (x, y, z) => 0 END - CheckDefAndScriptFailure(lines, 'E1012:') + v9.CheckDefAndScriptFailure(lines, 'E1012:') lines =<< trim END var one = 1 var l = [1, 2, 3] echo map(l, (one) => one) END - CheckDefFailure(lines, 'E1167:') - CheckScriptFailure(['vim9script'] + lines, 'E1168:') + v9.CheckDefFailure(lines, 'E1167:') + v9.CheckScriptFailure(['vim9script'] + lines, 'E1168:') lines =<< trim END var Ref: func(any, ?any): bool Ref = (_, y = 1) => false END - CheckDefAndScriptFailure(lines, 'E1172:') + v9.CheckDefAndScriptFailure(lines, 'E1172:') lines =<< trim END var a = 0 @@ -1138,7 +1138,7 @@ def Test_call_lambda_args() b = (txt =~ 'x' ? 1 : 2) assert_equal(2, b) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END def ShadowLocal() @@ -1147,7 +1147,7 @@ def Test_call_lambda_args() echo map(l, (one) => one) enddef END - CheckDefFailure(lines, 'E1167:') + v9.CheckDefFailure(lines, 'E1167:') lines =<< trim END def Shadowarg(one: number) @@ -1155,18 +1155,18 @@ def Test_call_lambda_args() echo map(l, (one) => one) enddef END - CheckDefFailure(lines, 'E1167:') + v9.CheckDefFailure(lines, 'E1167:') lines =<< trim END echo ((a) => a)('aa', 'bb') END - CheckDefAndScriptFailure(lines, 'E118:', 1) + v9.CheckDefAndScriptFailure(lines, 'E118:', 1) lines =<< trim END echo 'aa'->((a) => a)('bb') END - CheckDefFailure(lines, 'E118: Too many arguments for function: ->((a) => a)(''bb'')', 1) - CheckScriptFailure(['vim9script'] + lines, 'E118: Too many arguments for function: ', 2) + v9.CheckDefFailure(lines, 'E118: Too many arguments for function: ->((a) => a)(''bb'')', 1) + v9.CheckScriptFailure(['vim9script'] + lines, 'E118: Too many arguments for function: ', 2) enddef def Test_lambda_line_nr() @@ -1180,7 +1180,7 @@ def Test_lambda_line_nr() ->substitute("('\\|')", ' ', 'g')) assert_match('Last set from .* line 4', out) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def FilterWithCond(x: string, Cond: func(string): bool): bool @@ -1191,24 +1191,24 @@ def Test_lambda_return_type() var lines =<< trim END var Ref = (): => 123 END - CheckDefAndScriptFailure(lines, 'E1157:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1157:', 1) # no space before the return type lines =<< trim END var Ref = (x):number => x + 1 END - CheckDefAndScriptFailure(lines, 'E1069:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1069:', 1) # this works for x in ['foo', 'boo'] - echo FilterWithCond(x, (v) => v =~ '^b') + echo g:FilterWithCond(x, (v) => v =~ '^b') endfor # this fails lines =<< trim END - echo FilterWithCond('foo', (v) => v .. '^b') + echo g:FilterWithCond('foo', (v) => v .. '^b') END - CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected func(string): bool but got func(any): string', 1) + v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected func(string): bool but got func(any): string', 1) lines =<< trim END var Lambda1 = (x) => { @@ -1220,7 +1220,7 @@ def Test_lambda_return_type() } assert_equal('foo', Lambda2('foo')) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var Lambda = (x): string => { @@ -1228,11 +1228,11 @@ def Test_lambda_return_type() } echo Lambda(['foo']) END - CheckDefExecAndScriptFailure(lines, 'E1012:') + v9.CheckDefExecAndScriptFailure(lines, 'E1012:') enddef def Test_lambda_uses_assigned_var() - CheckDefSuccess([ + v9.CheckDefSuccess([ 'var x: any = "aaa"' 'x = filter(["bbb"], (_, v) => v =~ x)']) enddef @@ -1247,7 +1247,7 @@ def Test_pass_legacy_lambda_to_def_func() enddef Foo() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1261,7 +1261,7 @@ def Test_pass_legacy_lambda_to_def_func() legacy call g:TestFunc({nr -> 0}) delfunc g:TestFunc END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_lambda_in_reduce_line_break() @@ -1281,7 +1281,7 @@ def Test_lambda_in_reduce_line_break() }, {}) assert_equal({Bob: 2, Sam: 1, Cat: 3}, result) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_set_opfunc_to_lambda() @@ -1303,7 +1303,7 @@ def Test_set_opfunc_to_lambda() assert_equal(4, g:result) bwipe! END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_set_opfunc_to_global_function() @@ -1333,7 +1333,7 @@ def Test_set_opfunc_to_global_function() bwipe! END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) &operatorfunc = '' enddef @@ -1346,7 +1346,7 @@ def Test_use_script_func_name_with_prefix() var Fn = s:Getit assert_equal('it', Fn()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_lambda_type_allocated() @@ -1365,7 +1365,7 @@ def Test_lambda_type_allocated() &omnifunc = string(Lambda) Lambda = (a, b) => strlen(a) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef " Default arg and varargs @@ -1378,13 +1378,13 @@ def MyDefVarargs(one: string, two = 'foo', ...rest: list): string enddef def Test_call_def_varargs() - assert_fails('MyDefVarargs()', 'E119:', '', 1, 'Test_call_def_varargs') - MyDefVarargs('one')->assert_equal('one,foo') - MyDefVarargs('one', 'two')->assert_equal('one,two') - MyDefVarargs('one', 'two', 'three')->assert_equal('one,two,three') - CheckDefFailure(['MyDefVarargs("one", 22)'], + assert_fails('g:MyDefVarargs()', 'E119:', '', 1, 'Test_call_def_varargs') + g:MyDefVarargs('one')->assert_equal('one,foo') + g:MyDefVarargs('one', 'two')->assert_equal('one,two') + g:MyDefVarargs('one', 'two', 'three')->assert_equal('one,two,three') + v9.CheckDefFailure(['g:MyDefVarargs("one", 22)'], 'E1013: Argument 2: type mismatch, expected string but got number') - CheckDefFailure(['MyDefVarargs("one", "two", 123)'], + v9.CheckDefFailure(['g:MyDefVarargs("one", "two", 123)'], 'E1013: Argument 3: type mismatch, expected string but got number') var lines =<< trim END @@ -1394,7 +1394,7 @@ def Test_call_def_varargs() enddef Func('a', 'b', 'c') END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1403,7 +1403,7 @@ def Test_call_def_varargs() enddef Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1412,7 +1412,7 @@ def Test_call_def_varargs() enddef Func(0) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1421,7 +1421,7 @@ def Test_call_def_varargs() enddef Func(0) END - CheckScriptFailure(lines, 'E1180:', 2) + v9.CheckScriptFailure(lines, 'E1180:', 2) lines =<< trim END vim9script @@ -1430,7 +1430,7 @@ def Test_call_def_varargs() enddef Func('a', 'b', 'c') END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1439,7 +1439,7 @@ def Test_call_def_varargs() enddef Func(1, 2, 3) END - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch') + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch') lines =<< trim END vim9script @@ -1448,7 +1448,7 @@ def Test_call_def_varargs() enddef Func('a', 9) END - CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch') + v9.CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch') lines =<< trim END vim9script @@ -1457,7 +1457,7 @@ def Test_call_def_varargs() enddef Func(1, 'a') END - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch') + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch') lines =<< trim END vim9script @@ -1467,7 +1467,7 @@ def Test_call_def_varargs() echo l enddef END - CheckScriptFailure(lines, 'E1160:') + v9.CheckScriptFailure(lines, 'E1160:') lines =<< trim END vim9script @@ -1479,7 +1479,7 @@ def Test_call_def_varargs() enddef DoIt() END - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got string') + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got string') enddef let s:value = '' @@ -1510,8 +1510,8 @@ def Test_func_type_varargs() RefDef2Arg(99)->assert_equal('99text') RefDef2Arg(77, 'some')->assert_equal('77some') - CheckDefFailure(['var RefWrong: func(string?)'], 'E1010:') - CheckDefFailure(['var RefWrong: func(?string, string)'], 'E1007:') + v9.CheckDefFailure(['var RefWrong: func(string?)'], 'E1010:') + v9.CheckDefFailure(['var RefWrong: func(?string, string)'], 'E1007:') var RefVarargs: func(...list): string RefVarargs = FuncVarargs @@ -1519,8 +1519,8 @@ def Test_func_type_varargs() RefVarargs('one')->assert_equal('one') RefVarargs('one', 'two')->assert_equal('one,two') - CheckDefFailure(['var RefWrong: func(...list, string)'], 'E110:') - CheckDefFailure(['var RefWrong: func(...list, ?string)'], 'E110:') + v9.CheckDefFailure(['var RefWrong: func(...list, string)'], 'E110:') + v9.CheckDefFailure(['var RefWrong: func(...list, ?string)'], 'E110:') enddef " Only varargs @@ -1529,11 +1529,11 @@ def MyVarargsOnly(...args: list): string enddef def Test_call_varargs_only() - MyVarargsOnly()->assert_equal('') - MyVarargsOnly('one')->assert_equal('one') - MyVarargsOnly('one', 'two')->assert_equal('one,two') - CheckDefFailure(['MyVarargsOnly(1)'], 'E1013: Argument 1: type mismatch, expected string but got number') - CheckDefFailure(['MyVarargsOnly("one", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number') + g:MyVarargsOnly()->assert_equal('') + g:MyVarargsOnly('one')->assert_equal('one') + g:MyVarargsOnly('one', 'two')->assert_equal('one,two') + v9.CheckDefFailure(['g:MyVarargsOnly(1)'], 'E1013: Argument 1: type mismatch, expected string but got number') + v9.CheckDefFailure(['g:MyVarargsOnly("one", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number') enddef def Test_using_var_as_arg() @@ -1542,7 +1542,7 @@ def Test_using_var_as_arg() var x = 234 enddef END - CheckDefFailure(lines, 'E1006:') + v9.CheckDefFailure(lines, 'E1006:') lines =<< trim END def Func(Ref: number) @@ -1550,14 +1550,14 @@ def Test_using_var_as_arg() enddef enddef END - CheckDefFailure(lines, 'E1073:') + v9.CheckDefFailure(lines, 'E1073:') enddef -def DictArg(arg: dict) +def s:DictArg(arg: dict) arg['key'] = 'value' enddef -def ListArg(arg: list) +def s:ListArg(arg: list) arg[0] = 'value' enddef @@ -1570,12 +1570,12 @@ def Test_assign_to_argument() ListArg(l) l[0]->assert_equal('value') - CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef', 'defcompile'], 'E1090:') + v9.CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef', 'defcompile'], 'E1090:') delfunc! g:Func enddef " These argument names are reserved in legacy functions. -def WithReservedNames(firstline: string, lastline: string): string +def s:WithReservedNames(firstline: string, lastline: string): string return firstline .. lastline enddef @@ -1605,7 +1605,7 @@ def Test_call_funcref() var Funcref: func: number = function('RetNumber') Funcref()->assert_equal(123) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1618,7 +1618,7 @@ def Test_call_funcref() var Funcref = function('RetNumber') Bar(Funcref)->assert_equal(123) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1628,7 +1628,7 @@ def Test_call_funcref() var Funcref: func(number) = function('UseNumber') Funcref(123) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1637,7 +1637,7 @@ def Test_call_funcref() enddef var Funcref: func(string) = function('UseNumber') END - CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(string) but got func(number)') + v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(string) but got func(number)') lines =<< trim END vim9script @@ -1650,7 +1650,7 @@ def Test_call_funcref() Funcref(123) g:echo->assert_equal(123) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1663,7 +1663,7 @@ def Test_call_funcref() Funcref(1, 2, 3) g:echo->assert_equal([1, 2, 3]) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1685,7 +1685,7 @@ def Test_call_funcref() g:optarg->assert_equal(18) g:listarg->assert_equal([1, 2, 3]) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef let SomeFunc = function('len') @@ -1741,7 +1741,7 @@ def Test_nested_function_with_nextcmd() # Compile all functions defcompile END - CheckScriptFailure(lines, 'E1173: Text found after enddef: BBBB') + v9.CheckScriptFailure(lines, 'E1173: Text found after enddef: BBBB') enddef def Test_nested_function_with_args_split() @@ -1758,7 +1758,7 @@ def Test_nested_function_with_args_split() # Compile all functions defcompile END - CheckScriptFailure(lines, 'E1173: Text found after enddef: BBBB') + v9.CheckScriptFailure(lines, 'E1173: Text found after enddef: BBBB') lines =<< trim END vim9script @@ -1768,7 +1768,7 @@ def Test_nested_function_with_args_split() enddef defcompile END - CheckScriptFailure(lines, 'E1173: Text found after endfunction: BBBB') + v9.CheckScriptFailure(lines, 'E1173: Text found after endfunction: BBBB') enddef def Test_error_in_function_args() @@ -1783,30 +1783,30 @@ def Test_error_in_function_args() # Compile all functions defcompile END - CheckScriptFailure(lines, 'E488:') + v9.CheckScriptFailure(lines, 'E488:') enddef def Test_return_type_wrong() - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Func(): number', 'return "a"', 'enddef', 'defcompile'], 'expected number but got string') delfunc! g:Func - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Func(): string', 'return 1', 'enddef', 'defcompile'], 'expected string but got number') delfunc! g:Func - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Func(): void', 'return "a"', 'enddef', 'defcompile'], 'E1096: Returning a value in a function without a return type') delfunc! g:Func - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Func()', 'return "a"', 'enddef', @@ -1814,42 +1814,42 @@ def Test_return_type_wrong() 'E1096: Returning a value in a function without a return type') delfunc! g:Func - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Func(): number', 'return', 'enddef', 'defcompile'], 'E1003:') delfunc! g:Func - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Func():number', 'return 123', 'enddef', 'defcompile'], 'E1069:') delfunc! g:Func - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Func() :number', 'return 123', 'enddef', 'defcompile'], 'E1059:') delfunc! g:Func - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Func() : number', 'return 123', 'enddef', 'defcompile'], 'E1059:') delfunc! g:Func - CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:') + v9.CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:') delfunc! g:Func - CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:') + v9.CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:') delfunc! g:Func - CheckScriptFailure(['def Func()', 'return 1'], 'E1057:') + v9.CheckScriptFailure(['def Func()', 'return 1'], 'E1057:') delfunc! g:Func - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'def FuncB()', ' return 123', @@ -1861,12 +1861,12 @@ def Test_return_type_wrong() enddef def Test_arg_type_wrong() - CheckScriptFailure(['def Func3(items: list)', 'echo "a"', 'enddef'], 'E1008: Missing ') - CheckScriptFailure(['def Func4(...)', 'echo "a"', 'enddef'], 'E1055: Missing name after ...') - CheckScriptFailure(['def Func5(items:string)', 'echo "a"'], 'E1069:') - CheckScriptFailure(['def Func5(items)', 'echo "a"'], 'E1077:') - CheckScriptFailure(['def Func6(...x:list)', 'echo "a"', 'enddef'], 'E1069:') - CheckScriptFailure(['def Func7(...x: int)', 'echo "a"', 'enddef'], 'E1010:') + v9.CheckScriptFailure(['def Func3(items: list)', 'echo "a"', 'enddef'], 'E1008: Missing ') + v9.CheckScriptFailure(['def Func4(...)', 'echo "a"', 'enddef'], 'E1055: Missing name after ...') + v9.CheckScriptFailure(['def Func5(items:string)', 'echo "a"'], 'E1069:') + v9.CheckScriptFailure(['def Func5(items)', 'echo "a"'], 'E1077:') + v9.CheckScriptFailure(['def Func6(...x:list)', 'echo "a"', 'enddef'], 'E1069:') + v9.CheckScriptFailure(['def Func7(...x: int)', 'echo "a"', 'enddef'], 'E1010:') enddef def Test_white_space_before_comma() @@ -1875,7 +1875,7 @@ def Test_white_space_before_comma() def Func(a: number , b: number) enddef END - CheckScriptFailure(lines, 'E1068:') + v9.CheckScriptFailure(lines, 'E1068:') call assert_fails('vim9cmd echo stridx("a" .. "b" , "a")', 'E1068:') enddef @@ -1885,7 +1885,7 @@ def Test_white_space_after_comma() def Func(a: number,b: number) enddef END - CheckScriptFailure(lines, 'E1069:') + v9.CheckScriptFailure(lines, 'E1069:') # OK in legacy function lines =<< trim END @@ -1893,7 +1893,7 @@ def Test_white_space_after_comma() func Func(a,b) endfunc END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_vim9script_call() @@ -1998,7 +1998,7 @@ def Test_vim9script_call_fail_decl() enddef defcompile END - CheckScriptFailure(lines, 'E1054:') + v9.CheckScriptFailure(lines, 'E1054:') enddef def Test_vim9script_call_fail_type() @@ -2009,7 +2009,7 @@ def Test_vim9script_call_fail_type() enddef MyFunc(1234) END - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got number') + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got number') enddef def Test_vim9script_call_fail_const() @@ -2034,7 +2034,7 @@ def Test_vim9script_call_fail_const() call Change() unlet g:Aconst END - CheckScriptFailure(lines, 'E741: Value is locked: Aconst', 2) + v9.CheckScriptFailure(lines, 'E741: Value is locked: Aconst', 2) enddef " Test that inside :function a Python function can be defined, :def is not @@ -2056,7 +2056,7 @@ def Test_delfunc() enddef def CallGoneSoon() - GoneSoon() + g:GoneSoon() enddef defcompile @@ -2099,7 +2099,7 @@ def Run_Test_free_dict_while_in_funcstack() timer_start(1000, (_) => feedkeys("\")) sleep 1500m END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) nunmap set updatetime& enddef @@ -2167,34 +2167,34 @@ def FuncTwoArgNoRet(one: bool, two: number) s:funcResult = two enddef -def FuncOneArgRetString(arg: string): string +def s:FuncOneArgRetString(arg: string): string return arg enddef -def FuncOneArgRetAny(arg: any): any +def s:FuncOneArgRetAny(arg: any): any return arg enddef def Test_func_type() var Ref1: func() s:funcResult = 0 - Ref1 = FuncNoArgNoRet + Ref1 = g:FuncNoArgNoRet Ref1() s:funcResult->assert_equal(11) var Ref2: func s:funcResult = 0 - Ref2 = FuncNoArgNoRet + Ref2 = g:FuncNoArgNoRet Ref2() s:funcResult->assert_equal(11) s:funcResult = 0 - Ref2 = FuncOneArgNoRet + Ref2 = g:FuncOneArgNoRet Ref2(12) s:funcResult->assert_equal(12) s:funcResult = 0 - Ref2 = FuncNoArgRetNumber + Ref2 = g:FuncNoArgRetNumber Ref2()->assert_equal(1234) s:funcResult->assert_equal(22) @@ -2229,51 +2229,51 @@ enddef def Test_func_type_part() var RefVoid: func: void - RefVoid = FuncNoArgNoRet - RefVoid = FuncOneArgNoRet - CheckDefFailure(['var RefVoid: func: void', 'RefVoid = FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func(...) but got func(): number') - CheckDefFailure(['var RefVoid: func: void', 'RefVoid = FuncNoArgRetString'], 'E1012: Type mismatch; expected func(...) but got func(): string') + RefVoid = g:FuncNoArgNoRet + RefVoid = g:FuncOneArgNoRet + v9.CheckDefFailure(['var RefVoid: func: void', 'RefVoid = g:FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func(...) but got func(): number') + v9.CheckDefFailure(['var RefVoid: func: void', 'RefVoid = FuncNoArgRetString'], 'E1012: Type mismatch; expected func(...) but got func(): string') var RefAny: func(): any - RefAny = FuncNoArgRetNumber + RefAny = g:FuncNoArgRetNumber RefAny = FuncNoArgRetString - CheckDefFailure(['var RefAny: func(): any', 'RefAny = FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(): any but got func()') - CheckDefFailure(['var RefAny: func(): any', 'RefAny = FuncOneArgNoRet'], 'E1012: Type mismatch; expected func(): any but got func(number)') + v9.CheckDefFailure(['var RefAny: func(): any', 'RefAny = g:FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(): any but got func()') + v9.CheckDefFailure(['var RefAny: func(): any', 'RefAny = g:FuncOneArgNoRet'], 'E1012: Type mismatch; expected func(): any but got func(number)') var RefAnyNoArgs: func: any = RefAny var RefNr: func: number - RefNr = FuncNoArgRetNumber + RefNr = g:FuncNoArgRetNumber RefNr = FuncOneArgRetNumber - CheckDefFailure(['var RefNr: func: number', 'RefNr = FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(...): number but got func()') - CheckDefFailure(['var RefNr: func: number', 'RefNr = FuncNoArgRetString'], 'E1012: Type mismatch; expected func(...): number but got func(): string') + v9.CheckDefFailure(['var RefNr: func: number', 'RefNr = g:FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(...): number but got func()') + v9.CheckDefFailure(['var RefNr: func: number', 'RefNr = FuncNoArgRetString'], 'E1012: Type mismatch; expected func(...): number but got func(): string') var RefStr: func: string RefStr = FuncNoArgRetString RefStr = FuncOneArgRetString - CheckDefFailure(['var RefStr: func: string', 'RefStr = FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(...): string but got func()') - CheckDefFailure(['var RefStr: func: string', 'RefStr = FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func(...): string but got func(): number') + v9.CheckDefFailure(['var RefStr: func: string', 'RefStr = g:FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(...): string but got func()') + v9.CheckDefFailure(['var RefStr: func: string', 'RefStr = g:FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func(...): string but got func(): number') enddef def Test_func_type_fails() - CheckDefFailure(['var ref1: func()'], 'E704:') + v9.CheckDefFailure(['var ref1: func()'], 'E704:') - CheckDefFailure(['var Ref1: func()', 'Ref1 = FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func() but got func(): number') - CheckDefFailure(['var Ref1: func()', 'Ref1 = FuncOneArgNoRet'], 'E1012: Type mismatch; expected func() but got func(number)') - CheckDefFailure(['var Ref1: func()', 'Ref1 = FuncOneArgRetNumber'], 'E1012: Type mismatch; expected func() but got func(number): number') - CheckDefFailure(['var Ref1: func(bool)', 'Ref1 = FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(bool) but got func(bool, number)') - CheckDefFailure(['var Ref1: func(?bool)', 'Ref1 = FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(?bool) but got func(bool, number)') - CheckDefFailure(['var Ref1: func(...bool)', 'Ref1 = FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(...bool) but got func(bool, number)') + v9.CheckDefFailure(['var Ref1: func()', 'Ref1 = g:FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func() but got func(): number') + v9.CheckDefFailure(['var Ref1: func()', 'Ref1 = g:FuncOneArgNoRet'], 'E1012: Type mismatch; expected func() but got func(number)') + v9.CheckDefFailure(['var Ref1: func()', 'Ref1 = FuncOneArgRetNumber'], 'E1012: Type mismatch; expected func() but got func(number): number') + v9.CheckDefFailure(['var Ref1: func(bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(bool) but got func(bool, number)') + v9.CheckDefFailure(['var Ref1: func(?bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(?bool) but got func(bool, number)') + v9.CheckDefFailure(['var Ref1: func(...bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(...bool) but got func(bool, number)') - CheckDefFailure(['var RefWrong: func(string ,number)'], 'E1068:') - CheckDefFailure(['var RefWrong: func(string,number)'], 'E1069:') - CheckDefFailure(['var RefWrong: func(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool)'], 'E1005:') - CheckDefFailure(['var RefWrong: func(bool):string'], 'E1069:') + v9.CheckDefFailure(['var RefWrong: func(string ,number)'], 'E1068:') + v9.CheckDefFailure(['var RefWrong: func(string,number)'], 'E1069:') + v9.CheckDefFailure(['var RefWrong: func(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool)'], 'E1005:') + v9.CheckDefFailure(['var RefWrong: func(bool):string'], 'E1069:') enddef def Test_func_return_type() var nr: number - nr = FuncNoArgRetNumber() + nr = g:FuncNoArgRetNumber() nr->assert_equal(1234) nr = FuncOneArgRetAny(122) @@ -2283,7 +2283,7 @@ def Test_func_return_type() str = FuncOneArgRetAny('yes') str->assert_equal('yes') - CheckDefFailure(['var str: string', 'str = FuncNoArgRetNumber()'], 'E1012: Type mismatch; expected string but got number') + v9.CheckDefFailure(['var str: string', 'str = g:FuncNoArgRetNumber()'], 'E1012: Type mismatch; expected string but got number') enddef def Test_func_common_type() @@ -2302,7 +2302,7 @@ def Test_func_common_type() assert_equal(7, list[2](3, 'word')) enddef -def MultiLine( +def s:MultiLine( arg1: string, arg2 = 1234, ...rest: list @@ -2326,10 +2326,10 @@ def Test_multiline() enddef func Test_multiline_not_vim9() - call MultiLine('text')->assert_equal('text1234') - call MultiLine('text', 777)->assert_equal('text777') - call MultiLine('text', 777, 'one')->assert_equal('text777one') - call MultiLine('text', 777, 'one', 'two')->assert_equal('text777one-two') + call s:MultiLine('text')->assert_equal('text1234') + call s:MultiLine('text', 777)->assert_equal('text777') + call s:MultiLine('text', 777, 'one')->assert_equal('text777one') + call s:MultiLine('text', 777, 'one', 'two')->assert_equal('text777one-two') endfunc @@ -2426,19 +2426,19 @@ def Test_error_reporting() enddef def Test_deleted_function() - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var RefMe: func = function("g:DelMe")', 'delfunc g:DelMe', 'echo RefMe()'], 'E117:') enddef def Test_unknown_function() - CheckDefExecFailure([ + v9.CheckDefExecFailure([ 'var Ref: func = function("NotExist")', 'delfunc g:NotExist'], 'E700:') enddef -def RefFunc(Ref: func(any): any): string +def s:RefFunc(Ref: func(any): any): string return Ref('more') enddef @@ -2447,7 +2447,7 @@ def Test_closure_simple() RefFunc((s) => local .. s)->assert_equal('some more') enddef -def MakeRef() +def s:MakeRef() var local = 'some ' g:Ref = (s) => local .. s enddef @@ -2458,7 +2458,7 @@ def Test_closure_ref_after_return() unlet g:Ref enddef -def MakeTwoRefs() +def s:MakeTwoRefs() var local = ['some'] g:Extend = (s) => local->add(s) g:Read = () => local @@ -2476,11 +2476,11 @@ def Test_closure_two_refs() unlet g:Read enddef -def ReadRef(Ref: func(): list): string +def s:ReadRef(Ref: func(): list): string return join(Ref(), ' ') enddef -def ExtendRef(Ref: func(string): list, add: string) +def s:ExtendRef(Ref: func(string): list, add: string) Ref(add) enddef @@ -2496,12 +2496,12 @@ def Test_closure_two_indirect_refs() unlet g:Read enddef -def MakeArgRefs(theArg: string) +def s:MakeArgRefs(theArg: string) var local = 'loc_val' g:UseArg = (s) => theArg .. '/' .. local .. '/' .. s enddef -def MakeArgRefsVarargs(theArg: string, ...rest: list) +def s:MakeArgRefsVarargs(theArg: string, ...rest: list) var local = 'the_loc' g:UseVararg = (s) => theArg .. '/' .. local .. '/' .. s .. '/' .. join(rest) enddef @@ -2526,10 +2526,10 @@ def Test_closure_using_argument() enddef assert_equal([3, 4, 5], Test(Inc)) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef -def MakeGetAndAppendRefs() +def s:MakeGetAndAppendRefs() var local = 'a' def Append(arg: string) @@ -2563,7 +2563,7 @@ def Test_nested_closure() Closure('!!!')->assert_equal('text!!!') enddef -func GetResult(Ref) +func s:GetResult(Ref) return a:Ref('some') endfunc @@ -2584,7 +2584,7 @@ def Test_double_closure_fails() enddef Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_nested_closure_used() @@ -2598,7 +2598,7 @@ def Test_nested_closure_used() Func() assert_equal('hello', g:Myclosure()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_nested_closure_fails() @@ -2612,7 +2612,7 @@ def Test_nested_closure_fails() enddef FuncA() END - CheckScriptFailure(lines, 'E1012:') + v9.CheckScriptFailure(lines, 'E1012:') enddef def Test_global_closure() @@ -2632,7 +2632,7 @@ def Test_global_closure() repeat(['aaa', 'bbb', 'ccc'], 3)->setline(1) ReverseEveryNLines(3, 1, 9) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) var expected = repeat(['ccc', 'bbb', 'aaa'], 3) assert_equal(expected, getline(1, 9)) bwipe! @@ -2653,7 +2653,7 @@ def Test_global_closure_called_directly() enddef Outer() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delfunc g:Inner enddef @@ -2669,7 +2669,7 @@ def Test_closure_called_from_legacy() enddef Func() END - CheckScriptFailure(lines, 'E1248') + v9.CheckScriptFailure(lines, 'E1248') enddef def Test_failure_in_called_function() @@ -2692,7 +2692,7 @@ def Test_failure_in_called_function() endtry au! TerminalWinOpen END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_nested_lambda() @@ -2707,7 +2707,7 @@ def Test_nested_lambda() enddef Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_double_nested_lambda() @@ -2720,7 +2720,7 @@ def Test_double_nested_lambda() enddef assert_equal('hello-there', F('hello')('-')('there')) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_nested_inline_lambda() @@ -2733,7 +2733,7 @@ def Test_nested_inline_lambda() enddef assert_equal('--there++', F('++')('there')('--')) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -2743,7 +2743,7 @@ def Test_nested_inline_lambda() }) }) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -2759,7 +2759,7 @@ def Test_nested_inline_lambda() defcomp END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Shadowed(): list @@ -2768,10 +2768,10 @@ def Shadowed(): list enddef def Test_lambda_arg_shadows_func() - assert_equal([42], Shadowed()) + assert_equal([42], g:Shadowed()) enddef -def Line_continuation_in_def(dir: string = ''): string +def s:Line_continuation_in_def(dir: string = ''): string var path: string = empty(dir) \ ? 'empty' \ : 'full' @@ -2788,10 +2788,10 @@ def Test_script_var_in_lambda() var script = 'test' assert_equal(['test'], map(['one'], (_, _) => script)) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef -def Line_continuation_in_lambda(): list +def s:Line_continuation_in_lambda(): list var x = range(97, 100) ->mapnew((_, v) => nr2char(v) ->toupper()) @@ -2812,7 +2812,7 @@ def Test_line_continuation_in_lambda() )) assert_equal(['1:2:yyy'], res) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_list_lambda() @@ -2834,7 +2834,7 @@ def Test_lambda_block_variable() flist[i] = () => inloop endfor END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -2846,7 +2846,7 @@ def Test_lambda_block_variable() endfor endif END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -2858,7 +2858,7 @@ def Test_lambda_block_variable() flist[i] = () => outloop endfor END - CheckScriptFailure(lines, 'E1001: Variable not found: outloop', 1) + v9.CheckScriptFailure(lines, 'E1001: Variable not found: outloop', 1) lines =<< trim END vim9script @@ -2867,7 +2867,7 @@ def Test_lambda_block_variable() endfor assert_equal(0, ((i) => 0)(0)) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_legacy_lambda() @@ -2876,7 +2876,7 @@ def Test_legacy_lambda() var lines =<< trim END echo {x -> 'hello ' .. x}('foo') END - CheckDefAndScriptFailure(lines, 'E720:') + v9.CheckDefAndScriptFailure(lines, 'E720:') lines =<< trim END vim9script @@ -2885,7 +2885,7 @@ def Test_legacy_lambda() enddef legacy call s:Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_legacy() @@ -2902,7 +2902,7 @@ def Test_legacy() unlet g:legacyvar delfunc g:LegacyFunction END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_legacy_errors() @@ -2910,7 +2910,7 @@ def Test_legacy_errors() 'for', 'endfor', 'continue', 'break', 'while', 'endwhile', 'try', 'catch', 'finally', 'endtry'] - CheckDefFailure(['legacy ' .. cmd .. ' expr'], 'E1189:') + v9.CheckDefFailure(['legacy ' .. cmd .. ' expr'], 'E1189:') endfor enddef @@ -2942,10 +2942,10 @@ def Test_call_legacy_with_dict() assert_equal('bar', g:result) unlet g:result END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef -def DoFilterThis(a: string): list +def s:DoFilterThis(a: string): list # closure nested inside another closure using argument var Filter = (l) => filter(l, (_, v) => stridx(v, a) == 0) return ['x', 'y', 'a', 'x2', 'c']->Filter() @@ -2978,12 +2978,12 @@ def Run_Test_silent_echo() writefile(lines, 'XTest_silent_echo') # Check that the balloon shows up after a mouse move - var buf = RunVimInTerminal('-S XTest_silent_echo', {'rows': 6}) + var buf = g:RunVimInTerminal('-S XTest_silent_echo', {'rows': 6}) term_sendkeys(buf, ":abc") - VerifyScreenDump(buf, 'Test_vim9_silent_echo', {}) + g:VerifyScreenDump(buf, 'Test_vim9_silent_echo', {}) # clean up - StopVimInTerminal(buf) + g:StopVimInTerminal(buf) delete('XTest_silent_echo') enddef @@ -2992,7 +2992,7 @@ def SilentlyError() g:did_it = 'yes' enddef -func UserError() +func s:UserError() silent! invalid endfunc @@ -3028,10 +3028,10 @@ def Test_ignore_silent_error_in_filter() popup_create('popup', {filter: Filter}) feedkeys("o\r", 'xnt') END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef -def Fibonacci(n: number): number +def s:Fibonacci(n: number): number if n < 2 return n else @@ -3043,7 +3043,7 @@ def Test_recursive_call() Fibonacci(20)->assert_equal(6765) enddef -def TreeWalk(dir: string): list +def s:TreeWalk(dir: string): list return readdir(dir)->mapnew((_, val) => fnamemodify(dir .. '/' .. val, ':p')->isdirectory() ? {[val]: TreeWalk(dir .. '/' .. val)} @@ -3067,25 +3067,25 @@ def Test_invalid_function_name() vim9script def s: list END - CheckScriptFailure(lines, 'E129:') + v9.CheckScriptFailure(lines, 'E129:') lines =<< trim END vim9script def g: list END - CheckScriptFailure(lines, 'E129:') + v9.CheckScriptFailure(lines, 'E129:') lines =<< trim END vim9script def : list END - CheckScriptFailure(lines, 'E884:') + v9.CheckScriptFailure(lines, 'E884:') lines =<< trim END vim9script def F list END - CheckScriptFailure(lines, 'E488:') + v9.CheckScriptFailure(lines, 'E488:') enddef def Test_partial_call() @@ -3113,7 +3113,7 @@ def Test_partial_call() var RepeatFunc = function('repeat', ['o']) assert_equal('ooooo', RepeatFunc(5)) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END vim9script @@ -3122,12 +3122,12 @@ def Test_partial_call() var Expr: func(dict): dict const Call = Foo(Expr) END - CheckScriptFailure(lines, 'E1235:') + v9.CheckScriptFailure(lines, 'E1235:') enddef def Test_cmd_modifier() tab echo '0' - CheckDefFailure(['5tab echo 3'], 'E16:') + v9.CheckDefFailure(['5tab echo 3'], 'E16:') enddef def Test_restore_modifiers() @@ -3146,7 +3146,7 @@ def Test_restore_modifiers() endfunc Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) g:ei_after->assert_equal('') enddef @@ -3154,7 +3154,7 @@ def StackTop() eval 1 + 2 eval 2 + 3 # call not on fourth line - StackBot() + g:StackBot() enddef def StackBot() @@ -3164,7 +3164,7 @@ enddef def Test_callstack_def() try - StackTop() + g:StackTop() catch v:throwpoint->assert_match('Test_callstack_def\[2\]..StackTop\[4\]..StackBot, line 2') endtry @@ -3185,7 +3185,7 @@ def Test_block_scoped_var() enddef Func() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_reset_did_emsg() @@ -3199,7 +3199,7 @@ def Test_reset_did_emsg() enddef Func() END - CheckScriptFailure(lines, 'E492:', 8) + v9.CheckScriptFailure(lines, 'E492:', 8) delfunc! g:Func enddef @@ -3236,7 +3236,7 @@ def Test_abort_with_silent_call() assert_equal('none', g:result) unlet g:result END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_continues_with_silent_error() @@ -3252,7 +3252,7 @@ def Test_continues_with_silent_error() assert_equal('yes', g:result) unlet g:result END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_abort_even_with_silent() @@ -3267,7 +3267,7 @@ def Test_abort_even_with_silent() assert_equal('none', g:result) unlet g:result END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_cmdmod_silent_restored() @@ -3315,7 +3315,7 @@ def Test_cmdmod_silent_nested() Crash() assert_equal('CbEbEaCa', result) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_dict_member_with_silent() @@ -3333,7 +3333,7 @@ def Test_dict_member_with_silent() assert_equal('0', g:result) unlet g:result END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_skip_cmds_with_silent() @@ -3351,7 +3351,7 @@ def Test_skip_cmds_with_silent() Func(true) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_opfunc() @@ -3396,12 +3396,12 @@ def Run_Test_opfunc_error() END call writefile(lines, 'XTest_opfunc_error') - var buf = RunVimInTerminal('-S XTest_opfunc_error', {rows: 6, wait_for_ruler: 0}) - WaitForAssert(() => assert_match('Press ENTER', term_getline(buf, 6))) - WaitForAssert(() => assert_match('E684: list index out of range: 0', term_getline(buf, 5))) + var buf = g:RunVimInTerminal('-S XTest_opfunc_error', {rows: 6, wait_for_ruler: 0}) + g:WaitForAssert(() => assert_match('Press ENTER', term_getline(buf, 6))) + g:WaitForAssert(() => assert_match('E684: list index out of range: 0', term_getline(buf, 5))) # clean up - StopVimInTerminal(buf) + g:StopVimInTerminal(buf) delete('XTest_opfunc_error') enddef @@ -3419,7 +3419,7 @@ def Test_nested_lambda_in_closure() defcompile # not reached END - if !RunVim([], lines, '--clean -c WriteDone -c quit') + if !g:RunVim([], lines, '--clean -c WriteDone -c quit') return endif assert_equal(['Done'], readfile('XnestedDone')) @@ -3446,8 +3446,8 @@ def Test_check_func_arg_types() enddef END - CheckScriptSuccess(lines + ['echo H(G(F1))']) - CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') + v9.CheckScriptSuccess(lines + ['echo H(G(F1))']) + v9.CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') enddef def Test_list_any_type_checked() @@ -3462,13 +3462,13 @@ def Test_list_any_type_checked() Foo() END lines[2] = 'var l: list' - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) lines[2] = 'var l: list = []' - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) lines[2] = 'var l: list = [11]' - CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) + v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) enddef def Test_compile_error() @@ -3479,7 +3479,7 @@ def Test_compile_error() call g:Broken() END # First call: compilation error - CheckScriptFailure(lines, 'E1051: Wrong argument type for +') + v9.CheckScriptFailure(lines, 'E1051: Wrong argument type for +') # Second call won't try compiling again assert_fails('call g:Broken()', 'E1091: Function is not compiled: Broken') @@ -3492,7 +3492,7 @@ def Test_compile_error() enddef silent! defcompile END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # Calling the function won't try compiling again assert_fails('call g:Broken()', 'E1091: Function is not compiled: Broken') @@ -3520,7 +3520,7 @@ def Test_ignored_argument() assert_equal([[1], [2], [3]], range(3)->mapnew((_, v) => [v]->map((_, w) => w + 1))) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END def Ignore(_: string): string @@ -3528,29 +3528,29 @@ def Test_ignored_argument() enddef defcompile END - CheckScriptFailure(lines, 'E1181:', 1) + v9.CheckScriptFailure(lines, 'E1181:', 1) lines =<< trim END var _ = 1 END - CheckDefAndScriptFailure(lines, 'E1181:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1181:', 1) lines =<< trim END var x = _ END - CheckDefAndScriptFailure(lines, 'E1181:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1181:', 1) enddef def Test_too_many_arguments() var lines =<< trim END echo [0, 1, 2]->map(() => 123) END - CheckDefExecAndScriptFailure(lines, 'E1106: 2 arguments too many', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E1106: 2 arguments too many', 1) lines =<< trim END echo [0, 1, 2]->map((_) => 123) END - CheckDefExecAndScriptFailure(lines, 'E1106: One argument too many', 1) + v9.CheckDefExecAndScriptFailure(lines, 'E1106: One argument too many', 1) enddef def Test_closing_brace_at_start_of_line() @@ -3560,10 +3560,10 @@ def Test_closing_brace_at_start_of_line() Func( ) END - call CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef -func CreateMydict() +func s:CreateMydict() let g:mydict = {} func g:mydict.afunc() let g:result = self.key @@ -3588,7 +3588,7 @@ def Test_go_beyond_end_of_cmd() enddef defcompile END - CheckScriptFailure(lines, 'E476:') + v9.CheckScriptFailure(lines, 'E476:') enddef if has('python3') diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 7878788a0..440bef14b 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -3,7 +3,7 @@ source check.vim source term_util.vim -source vim9.vim +import './vim9.vim' as v9 let s:export_script_lines =<< trim END vim9script @@ -33,7 +33,7 @@ let s:export_script_lines =<< trim END export var AddRef = AddSome END -def Undo_export_script_lines() +def s:Undo_export_script_lines() unlet g:result unlet g:localname enddef @@ -411,7 +411,7 @@ def Test_import_funcref() enddef DoTest() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delete('Xlib.vim') enddef @@ -422,42 +422,42 @@ def Test_import_fails() import './Xfoo.vim' as foo foo = 'bar' END - CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself']) + v9.CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself']) lines =<< trim END vim9script import './Xfoo.vim' as foo var that = foo END - CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') + v9.CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') lines =<< trim END vim9script import './Xfoo.vim' as foo var that: any that += foo END - CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') + v9.CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') lines =<< trim END vim9script import './Xfoo.vim' as foo foo += 9 END - CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') + v9.CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') lines =<< trim END vim9script import './Xfoo.vim' as 9foo END - CheckScriptFailure(lines, 'E1047:') + v9.CheckScriptFailure(lines, 'E1047:') lines =<< trim END vim9script import './Xfoo.vim' as the#foo END - CheckScriptFailure(lines, 'E1047:') + v9.CheckScriptFailure(lines, 'E1047:') lines =<< trim END vim9script import './Xfoo.vim' as g:foo END - CheckScriptFailure(lines, 'E1047:') + v9.CheckScriptFailure(lines, 'E1047:') delete('Xfoo.vim') @@ -474,7 +474,7 @@ def Test_import_fails() import './Xthat.vim' as That That() END - CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) + v9.CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) lines =<< trim END vim9script @@ -484,13 +484,13 @@ def Test_import_fails() enddef Func() END - CheckScriptFailure(lines, 'E1236: Cannot use That itself') + v9.CheckScriptFailure(lines, 'E1236: Cannot use That itself') lines =<< trim END import './Xthat.vim' as one import './Xthat.vim' as two END - CheckScriptFailure(lines, 'E1262:') + v9.CheckScriptFailure(lines, 'E1262:') delete('Xthat.vim') @@ -501,24 +501,24 @@ def Test_import_fails() vim9script import './Ximport/.vim' END - CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"') + v9.CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"') lines =<< trim END vim9script import './Ximport/.vim' as vim END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) writefile(['vim9script'], 'Ximport/.vimrc') lines =<< trim END vim9script import './Ximport/.vimrc' END - CheckScriptFailure(lines, 'E1257: Imported script must use "as" or end in .vim') + v9.CheckScriptFailure(lines, 'E1257: Imported script must use "as" or end in .vim') lines =<< trim END vim9script import './Ximport/.vimrc' as vimrc END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delete('Ximport', 'rf') enddef @@ -626,7 +626,7 @@ def Test_use_import_in_command_completion() feedkeys(":Cmd ab\\#\", 'xnt') assert_equal('#Cmd abcd', @:) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delcommand Cmd delete('Xscript.vim') @@ -665,7 +665,7 @@ def Test_use_autoload_import_in_insert_completion() assert_equal('experiment', getline(1)) assert_equal('yes', g:completion_loaded) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) set thesaurusfunc= bwipe! @@ -698,7 +698,7 @@ def Test_use_autoload_import_partial_in_opfunc() feedkeys("\l", 'xt') assert_equal('yes', g:opfunc_called) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) set opfunc= bwipe! @@ -732,7 +732,7 @@ def Test_set_opfunc_to_autoload_func_directly() feedkeys("\l", 'xt') assert_equal('yes', g:opfunc_called) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) set opfunc= bwipe! @@ -769,7 +769,7 @@ def Test_use_autoload_import_in_fold_expression() new setline(1, ['# one', 'text', '# two', 'text']) g:fold_loaded = 'no' - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_equal('no', g:fold_loaded) redraw assert_equal('yes', g:fold_loaded) @@ -810,7 +810,7 @@ def Run_Test_import_in_diffexpr() set diffexpr=diff.DiffExpr() set diffopt=foldcolumn:0 END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enew! call setline(1, ['one', 'two', 'three']) @@ -842,7 +842,7 @@ def Test_import_in_patchexpr() import './Xpatchexpr' as patch set patchexpr=patch.TPatch() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) call writefile(['input file'], 'Xinput') call writefile(['diff file'], 'Xdiff') @@ -873,7 +873,7 @@ def Test_import_in_formatexpr() import './Xformatter' as format set formatexpr=format.MyFormatExpr() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) new setline(1, ['a', 'b', 'c']) @@ -903,7 +903,7 @@ def Test_import_in_includeexpr() import './Xinclude.vim' set includeexpr=Xinclude.DoSub() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) setline(1, ['Xthatfile']) exe "normal \f" @@ -931,7 +931,7 @@ def Test_import_in_indentexpr() set indentexpr=indent.GetIndent() set debug=throw END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) new setline(1, 'hello') @@ -964,7 +964,7 @@ def Run_Test_import_in_printexpr() import './Xprint.vim' set printexpr=Xprint.PrintFile() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) help hardcopy dummy args @@ -991,7 +991,7 @@ def Test_import_in_charconvert() import './Xconvert.vim' as conv set charconvert=conv.MakeUpper() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) writefile(['one', 'two'], 'Xfile') new Xfile @@ -1024,7 +1024,7 @@ def Run_Test_import_in_spellsuggest_expr() import './Xsuggest.vim' as sugg set spell spellsuggest=expr:sugg.MySuggest() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) set verbose=1 # report errors call assert_equal(['Fox', 'Fop'], spellsuggest('Fo', 2)) @@ -1056,7 +1056,7 @@ def Test_export_shadows_global_function() import autoload 'shadow.vim' assert_equal('Shadow()', shadow.Shadow()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delfunc g:Shadow bwipe! @@ -1065,9 +1065,9 @@ def Test_export_shadows_global_function() enddef def Test_export_fails() - CheckScriptFailure(['export var some = 123'], 'E1042:') - CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') - CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') + v9.CheckScriptFailure(['export var some = 123'], 'E1042:') + v9.CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') + v9.CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') assert_fails('export something', 'E1043:') enddef @@ -1088,12 +1088,12 @@ def Run_Test_import_fails_on_command_line() END writefile(export, 'XexportCmd.vim') - var buf = RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', { + var buf = g:RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', { rows: 6, wait_for_ruler: 0}) - WaitForAssert(() => assert_match('^E1094:', term_getline(buf, 5))) + g:WaitForAssert(() => assert_match('^E1094:', term_getline(buf, 5))) delete('XexportCmd.vim') - StopVimInTerminal(buf) + g:StopVimInTerminal(buf) enddef def Test_vim9_reload_noclear() @@ -1348,7 +1348,7 @@ def Test_vim9_funcref_other_script() enddef TestDirect() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delete('Xfilter.vim') enddef @@ -1461,7 +1461,7 @@ def Test_func_overrules_import_fails() echo 'local to function' enddef END - CheckScriptFailure(lines, 'E1213: Redefining imported item "Func"') + v9.CheckScriptFailure(lines, 'E1213: Redefining imported item "Func"') lines =<< trim END vim9script @@ -1473,7 +1473,7 @@ def Test_func_overrules_import_fails() enddef defcompile END - CheckScriptFailure(lines, 'E1236:') + v9.CheckScriptFailure(lines, 'E1236:') delete('XexportedFunc.vim') enddef @@ -1696,10 +1696,10 @@ def Test_vim9script_autoload() assert_equal('final', prefixed.fname) assert_equal('const', prefixed.cname) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # can source it again, autoload script not loaded again g:expected_loaded = 1 - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # can also get the items by autoload name lines =<< trim END @@ -1709,7 +1709,7 @@ def Test_vim9script_autoload() call assert_equal('final', prefixed#fname) call assert_equal('const', prefixed#cname) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) unlet g:prefixed_loaded unlet g:expected_loaded @@ -1737,42 +1737,42 @@ def Test_import_autoload_not_exported() import autoload 'notExport1.vim' echo notExport1.notFound END - CheckScriptFailure(lines, 'E1048: Item not found in script: notFound') + v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notFound') lines =<< trim END vim9script import autoload 'notExport1.vim' echo notExport1.notExported END - CheckScriptFailure(lines, 'E1049: Item not exported in script: notExported') + v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notExported') lines =<< trim END vim9script import autoload 'notExport1.vim' echo notExport1.NotFunc() END - CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc') + v9.CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc') lines =<< trim END vim9script import autoload 'notExport1.vim' echo notExport1.NotExport() END - CheckScriptFailure(lines, 'E1049: Item not exported in script: NotExport') + v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: NotExport') lines =<< trim END vim9script import autoload 'notExport1.vim' echo 'text'->notExport1.NotFunc() END - CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc') + v9.CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc') lines =<< trim END vim9script import autoload 'notExport1.vim' echo 'text'->notExport1.NotExport() END - CheckScriptFailure(lines, 'E1049: Item not exported in script: NotExport') + v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: NotExport') # using a :def function we use a different autoload script every time so that # the function is compiled without the script loaded @@ -1785,7 +1785,7 @@ def Test_import_autoload_not_exported() enddef Testit() END - CheckScriptFailure(lines, 'E1048: Item not found in script: notExport2#notFound') + v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notExport2#notFound') writefile(exportLines, 'Xdir/autoload/notExport3.vim') lines =<< trim END @@ -1797,7 +1797,7 @@ def Test_import_autoload_not_exported() Testit() END # don't get E1049 because it is too complicated to figure out - CheckScriptFailure(lines, 'E1048: Item not found in script: notExport3#notExported') + v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notExport3#notExported') writefile(exportLines, 'Xdir/autoload/notExport4.vim') lines =<< trim END @@ -1808,7 +1808,7 @@ def Test_import_autoload_not_exported() enddef Testit() END - CheckScriptFailure(lines, 'E117: Unknown function: notExport4#NotFunc') + v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport4#NotFunc') writefile(exportLines, 'Xdir/autoload/notExport5.vim') lines =<< trim END @@ -1819,7 +1819,7 @@ def Test_import_autoload_not_exported() enddef Testit() END - CheckScriptFailure(lines, 'E117: Unknown function: notExport5#NotExport') + v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport5#NotExport') writefile(exportLines, 'Xdir/autoload/notExport6.vim') lines =<< trim END @@ -1830,7 +1830,7 @@ def Test_import_autoload_not_exported() enddef Testit() END - CheckScriptFailure(lines, 'E117: Unknown function: notExport6#NotFunc') + v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport6#NotFunc') writefile(exportLines, 'Xdir/autoload/notExport7.vim') lines =<< trim END @@ -1841,7 +1841,7 @@ def Test_import_autoload_not_exported() enddef Testit() END - CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport') + v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport') delete('Xdir', 'rf') &rtp = save_rtp @@ -1880,7 +1880,7 @@ def Test_vim9script_autoload_call() assert_equal('arg', call('another.RetArg', ['arg'])) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) unlet g:result delete('Xdir', 'rf') @@ -2025,7 +2025,7 @@ def Test_autoload_name_wring() enddef END writefile(lines, 'Xscriptname.vim') - CheckScriptFailure(lines, 'E1263:') + v9.CheckScriptFailure(lines, 'E1263:') delete('Xscriptname.vim') enddef @@ -2056,9 +2056,9 @@ def Test_import_autoload_postponed() enddef defcompile END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_false(exists('g:loaded_postponed')) - CheckScriptSuccess(lines + ['Tryit()']) + v9.CheckScriptSuccess(lines + ['Tryit()']) assert_equal('true', g:loaded_postponed) unlet g:loaded_postponed @@ -2094,7 +2094,7 @@ def Test_import_autoload_override() enddef defcompile END - CheckScriptFailure(lines, 'E1048: Item not found in script: doesNotExist', 1) + v9.CheckScriptFailure(lines, 'E1048: Item not found in script: doesNotExist', 1) test_override('autoload', 0) unlet g:loaded_override @@ -2130,7 +2130,7 @@ def Test_autoload_mapping() nnoremap xx toggle.Doit() nnoremap yy toggle.Doit() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_false(exists("g:toggle_loaded")) assert_false(exists("g:toggle_called")) assert_match('\d A: \f*[/\\]toggle.vim', execute('scriptnames')) @@ -2159,13 +2159,13 @@ def Test_vim9script_autoload_fails() vim9script autoload var n = 0 END - CheckScriptFailure(lines, 'E475: Invalid argument: autoload') + v9.CheckScriptFailure(lines, 'E475: Invalid argument: autoload') lines =<< trim END vim9script noclear noclear var n = 0 END - CheckScriptFailure(lines, 'E983: Duplicate argument: noclear') + v9.CheckScriptFailure(lines, 'E983: Duplicate argument: noclear') enddef def Test_import_autoload_fails() @@ -2173,25 +2173,25 @@ def Test_import_autoload_fails() vim9script import autoload autoload 'prefixed.vim' END - CheckScriptFailure(lines, 'E121: Undefined variable: autoload') + v9.CheckScriptFailure(lines, 'E121: Undefined variable: autoload') lines =<< trim END vim9script import autoload './doesNotExist.vim' END - CheckScriptFailure(lines, 'E1264:') + v9.CheckScriptFailure(lines, 'E1264:') lines =<< trim END vim9script import autoload '/dir/doesNotExist.vim' END - CheckScriptFailure(lines, 'E1264:') + v9.CheckScriptFailure(lines, 'E1264:') lines =<< trim END vim9script import autoload 'doesNotExist.vim' END - CheckScriptFailure(lines, 'E1053: Could not import "doesNotExist.vim"') + v9.CheckScriptFailure(lines, 'E1053: Could not import "doesNotExist.vim"') enddef " test disassembling an auto-loaded function starting with "debug" @@ -2223,7 +2223,7 @@ def Test_vim9_autoload_disass() assert_equal('profile', profileit#test()) disass profileit#test END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) delete('Xdir', 'rf') &rtp = save_rtp @@ -2274,7 +2274,7 @@ def Test_vim9_autoload_case_sensitive() import autoload 'CaseSensitive.vim' assert_equal('done', CaseSensitive.CaseSensitive()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) if !has('fname_case') lines =<< trim END @@ -2282,7 +2282,7 @@ def Test_vim9_autoload_case_sensitive() import autoload 'CaseSensitive.vim' import autoload 'casesensitive.vim' END - CheckScriptFailure(lines, 'E1262:') + v9.CheckScriptFailure(lines, 'E1262:') endif delete('Xdir', 'rf') @@ -2320,7 +2320,7 @@ def Test_vim9_autoload_error() qall! END writefile(lines, 'Xscript') - RunVim([], [], '-S Xscript') + g:RunVim([], [], '-S Xscript') assert_equal(['ok'], readfile('Xdidit')) delete('Xdidit') @@ -2331,7 +2331,7 @@ def Test_vim9_autoload_error() vim9script var foo#bar = 'asdf' END - CheckScriptFailure(lines, 'E461: Illegal variable name: foo#bar', 2) + v9.CheckScriptFailure(lines, 'E461: Illegal variable name: foo#bar', 2) enddef diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index eb84c3589..d6142a695 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -2,7 +2,7 @@ source check.vim source term_util.vim -source vim9.vim +import './vim9.vim' as v9 source screendump.vim source shared.vim @@ -18,7 +18,7 @@ def Test_vim9script_feature() # Vim9 script commands go here g:didit = true END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_equal(true, g:didit) unlet g:didit enddef @@ -35,20 +35,20 @@ def Test_range_only() setline(1, ['one', 'two', 'three']) :2 print - assert_equal('two', Screenline(&lines)) + assert_equal('two', g:Screenline(&lines)) :3 list - assert_equal('three$', Screenline(&lines)) + assert_equal('three$', g:Screenline(&lines)) # missing command does not print the line var lines =<< trim END vim9script :1| - assert_equal('three$', Screenline(&lines)) + assert_equal('three$', g:Screenline(&lines)) :| - assert_equal('three$', Screenline(&lines)) + assert_equal('three$', g:Screenline(&lines)) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) bwipe! @@ -64,7 +64,7 @@ let g:anumber = 123 def Test_delfunction() # Check function is defined in script namespace - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'func CheckMe()', ' return 123', @@ -73,13 +73,13 @@ def Test_delfunction() ]) # Check function in script namespace cannot be deleted - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'func DeleteMe1()', 'endfunc', 'delfunction DeleteMe1', ], 'E1084:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'func DeleteMe2()', 'endfunc', @@ -88,13 +88,13 @@ def Test_delfunction() 'enddef', 'DoThat()', ], 'E1084:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'def DeleteMe3()', 'enddef', 'delfunction DeleteMe3', ], 'E1084:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'def DeleteMe4()', 'enddef', @@ -118,7 +118,7 @@ def Test_delfunction() delfunc g:Global assert_false(exists('*g:Global')) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # Check that global function can be replaced by a :def function and deleted lines =<< trim END @@ -134,7 +134,7 @@ def Test_delfunction() delfunc g:Global assert_false(exists('*g:Global')) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # Check that global :def function can be replaced by a function and deleted lines =<< trim END @@ -150,32 +150,32 @@ def Test_delfunction() delfunc g:Global assert_false(exists('*g:Global')) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_wrong_type() - CheckDefFailure(['var name: list'], 'E1010:') - CheckDefFailure(['var name: list>'], 'E1010:') - CheckDefFailure(['var name: dict'], 'E1010:') - CheckDefFailure(['var name: dict>'], 'E1010:') - - CheckDefFailure(['var name: dict'], 'E1009:') - - CheckDefFailure(['var name: ally'], 'E1010:') - CheckDefFailure(['var name: bram'], 'E1010:') - CheckDefFailure(['var name: cathy'], 'E1010:') - CheckDefFailure(['var name: dom'], 'E1010:') - CheckDefFailure(['var name: freddy'], 'E1010:') - CheckDefFailure(['var name: john'], 'E1010:') - CheckDefFailure(['var name: larry'], 'E1010:') - CheckDefFailure(['var name: ned'], 'E1010:') - CheckDefFailure(['var name: pam'], 'E1010:') - CheckDefFailure(['var name: sam'], 'E1010:') - CheckDefFailure(['var name: vim'], 'E1010:') - - CheckDefFailure(['var Ref: number', 'Ref()'], 'E1085:') - CheckDefFailure(['var Ref: string', 'var res = Ref()'], 'E1085:') + v9.CheckDefFailure(['var name: list'], 'E1010:') + v9.CheckDefFailure(['var name: list>'], 'E1010:') + v9.CheckDefFailure(['var name: dict'], 'E1010:') + v9.CheckDefFailure(['var name: dict>'], 'E1010:') + + v9.CheckDefFailure(['var name: dict'], 'E1009:') + + v9.CheckDefFailure(['var name: ally'], 'E1010:') + v9.CheckDefFailure(['var name: bram'], 'E1010:') + v9.CheckDefFailure(['var name: cathy'], 'E1010:') + v9.CheckDefFailure(['var name: dom'], 'E1010:') + v9.CheckDefFailure(['var name: freddy'], 'E1010:') + v9.CheckDefFailure(['var name: john'], 'E1010:') + v9.CheckDefFailure(['var name: larry'], 'E1010:') + v9.CheckDefFailure(['var name: ned'], 'E1010:') + v9.CheckDefFailure(['var name: pam'], 'E1010:') + v9.CheckDefFailure(['var name: sam'], 'E1010:') + v9.CheckDefFailure(['var name: vim'], 'E1010:') + + v9.CheckDefFailure(['var Ref: number', 'Ref()'], 'E1085:') + v9.CheckDefFailure(['var Ref: string', 'var res = Ref()'], 'E1085:') enddef def Test_script_wrong_type() @@ -184,15 +184,15 @@ def Test_script_wrong_type() var s:dict: dict s:dict['a'] = ['x'] END - CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got list', 3) + v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got list', 3) enddef def Test_const() - CheckDefFailure(['final name = 234', 'name = 99'], 'E1018:') - CheckDefFailure(['final one = 234', 'var one = 99'], 'E1017:') - CheckDefFailure(['final list = [1, 2]', 'var list = [3, 4]'], 'E1017:') - CheckDefFailure(['final two'], 'E1125:') - CheckDefFailure(['final &option'], 'E996:') + v9.CheckDefFailure(['final name = 234', 'name = 99'], 'E1018:') + v9.CheckDefFailure(['final one = 234', 'var one = 99'], 'E1017:') + v9.CheckDefFailure(['final list = [1, 2]', 'var list = [3, 4]'], 'E1017:') + v9.CheckDefFailure(['final two'], 'E1125:') + v9.CheckDefFailure(['final &option'], 'E996:') var lines =<< trim END final list = [1, 2, 3] @@ -217,7 +217,7 @@ def Test_const() cd['six'] = 66 constdict->assert_equal({one: 1, two: {five: 55, six: 66}, three: 3}) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_const_bang() @@ -225,43 +225,43 @@ def Test_const_bang() const var = 234 var = 99 END - CheckDefExecFailure(lines, 'E1018:', 2) - CheckScriptFailure(['vim9script'] + lines, 'E46:', 3) + v9.CheckDefExecFailure(lines, 'E1018:', 2) + v9.CheckScriptFailure(['vim9script'] + lines, 'E46:', 3) lines =<< trim END const ll = [2, 3, 4] ll[0] = 99 END - CheckDefExecFailure(lines, 'E1119:', 2) - CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) + v9.CheckDefExecFailure(lines, 'E1119:', 2) + v9.CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) lines =<< trim END const ll = [2, 3, 4] ll[3] = 99 END - CheckDefExecFailure(lines, 'E1118:', 2) - CheckScriptFailure(['vim9script'] + lines, 'E684:', 3) + v9.CheckDefExecFailure(lines, 'E1118:', 2) + v9.CheckScriptFailure(['vim9script'] + lines, 'E684:', 3) lines =<< trim END const dd = {one: 1, two: 2} dd["one"] = 99 END - CheckDefExecFailure(lines, 'E1121:', 2) - CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) + v9.CheckDefExecFailure(lines, 'E1121:', 2) + v9.CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) lines =<< trim END const dd = {one: 1, two: 2} dd["three"] = 99 END - CheckDefExecFailure(lines, 'E1120:') - CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) + v9.CheckDefExecFailure(lines, 'E1120:') + v9.CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) enddef def Test_range_no_colon() - CheckDefFailure(['%s/a/b/'], 'E1050:') - CheckDefFailure(['+ s/a/b/'], 'E1050:') - CheckDefFailure(['- s/a/b/'], 'E1050:') - CheckDefFailure(['. s/a/b/'], 'E1050:') + v9.CheckDefFailure(['%s/a/b/'], 'E1050:') + v9.CheckDefFailure(['+ s/a/b/'], 'E1050:') + v9.CheckDefFailure(['- s/a/b/'], 'E1050:') + v9.CheckDefFailure(['. s/a/b/'], 'E1050:') enddef @@ -278,9 +278,9 @@ def Test_block() enddef def Test_block_failure() - CheckDefFailure(['{', 'var inner = 1', '}', 'echo inner'], 'E1001:') - CheckDefFailure(['}'], 'E1025:') - CheckDefFailure(['{', 'echo 1'], 'E1026:') + v9.CheckDefFailure(['{', 'var inner = 1', '}', 'echo inner'], 'E1001:') + v9.CheckDefFailure(['}'], 'E1025:') + v9.CheckDefFailure(['{', 'echo 1'], 'E1026:') enddef def Test_block_local_vars() @@ -322,7 +322,7 @@ def Test_block_local_vars() # need to execute this with a separate Vim instance to avoid the current # context gets garbage collected. writefile(lines, 'Xscript') - RunVim([], [], '-S Xscript') + g:RunVim([], [], '-S Xscript') assert_equal(['ok'], readfile('Xdidit')) delete('Xscript') @@ -345,11 +345,11 @@ def Test_block_local_vars_with_func() # "foo" and "bar" assert_equal(['foo', 'bar'], Func()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef " legacy func for command that's defined later -func InvokeSomeCommand() +func s:InvokeSomeCommand() SomeCommand endfunc @@ -557,7 +557,7 @@ def Test_try_catch_throw() assert_equal(333, n) try - l = DeletedFunc() + l = g:DeletedFunc() catch /E933:/ n = 344 endtry @@ -679,7 +679,7 @@ def Test_try_catch_throw() g:caught = v:exception endtry END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_match('E1219: Float or Number required for argument 1', g:caught) unlet g:caught @@ -690,7 +690,7 @@ def Test_try_catch_throw() echo 'something' endtry END - CheckScriptFailure(lines, 'E1032:') + v9.CheckScriptFailure(lines, 'E1032:') # skipping try-finally-endtry when try-finally-endtry is used in another block lines =<< trim END @@ -704,7 +704,7 @@ def Test_try_catch_throw() endtry endif END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_try_ends_in_return() @@ -719,7 +719,7 @@ def Test_try_ends_in_return() enddef assert_equal('foo', Foo()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -733,7 +733,7 @@ def Test_try_ends_in_return() enddef assert_equal('foo', Foo()) END - CheckScriptFailure(lines, 'E1095:') + v9.CheckScriptFailure(lines, 'E1095:') lines =<< trim END vim9script @@ -746,7 +746,7 @@ def Test_try_ends_in_return() enddef assert_equal('foo', Foo()) END - CheckScriptFailure(lines, 'E1027:') + v9.CheckScriptFailure(lines, 'E1027:') lines =<< trim END vim9script @@ -761,7 +761,7 @@ def Test_try_ends_in_return() enddef assert_equal('done', Foo()) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef @@ -799,11 +799,11 @@ def Test_error_in_catch() eval [][0] endtry END - CheckDefExecFailure(lines, 'E684:', 4) + v9.CheckDefExecFailure(lines, 'E684:', 4) enddef " :while at the very start of a function that :continue jumps to -def TryContinueFunc() +def s:TryContinueFunc() while g:Count < 2 g:sequence ..= 't' try @@ -867,7 +867,7 @@ def Test_cnext_works_in_catch() qall END writefile(lines, 'XCatchCnext') - RunVim([], [], '--clean -S XCatchCnext') + g:RunVim([], [], '--clean -S XCatchCnext') assert_equal(['1'], readfile('Xresult')) delete('Xfile1') @@ -901,19 +901,19 @@ enddef defcompile delfunc DeletedFunc -def ThrowFromDef() +def s:ThrowFromDef() throw "getout" # comment enddef -func CatchInFunc() +func s:CatchInFunc() try - call ThrowFromDef() + call s:ThrowFromDef() catch let g:thrown_func = v:exception endtry endfunc -def CatchInDef() +def s:CatchInDef() try ThrowFromDef() catch @@ -921,7 +921,7 @@ def CatchInDef() endtry enddef -def ReturnFinally(): string +def s:ReturnFinally(): string try return 'intry' finall @@ -984,7 +984,7 @@ def Test_try_catch_nested() assert_equal(['1', '2', '3', '4'], l) enddef -def TryOne(): number +def s:TryOne(): number try return 0 catch @@ -992,7 +992,7 @@ def TryOne(): number return 0 enddef -def TryTwo(n: number): string +def s:TryTwo(n: number): string try var x = {} catch @@ -1023,19 +1023,19 @@ def Test_try_catch_match() enddef def Test_try_catch_fails() - CheckDefFailure(['catch'], 'E603:') - CheckDefFailure(['try', 'echo 0', 'catch', 'catch'], 'E1033:') - CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:') - CheckDefFailure(['finally'], 'E606:') - CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:') - CheckDefFailure(['endtry'], 'E602:') - CheckDefFailure(['while 1', 'endtry'], 'E170:') - CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:') - CheckDefFailure(['if 1', 'endtry'], 'E171:') - CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:') + v9.CheckDefFailure(['catch'], 'E603:') + v9.CheckDefFailure(['try', 'echo 0', 'catch', 'catch'], 'E1033:') + v9.CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:') + v9.CheckDefFailure(['finally'], 'E606:') + v9.CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:') + v9.CheckDefFailure(['endtry'], 'E602:') + v9.CheckDefFailure(['while 1', 'endtry'], 'E170:') + v9.CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:') + v9.CheckDefFailure(['if 1', 'endtry'], 'E171:') + v9.CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:') - CheckDefFailure(['throw'], 'E1143:') - CheckDefFailure(['throw xxx'], 'E1001:') + v9.CheckDefFailure(['throw'], 'E1143:') + v9.CheckDefFailure(['throw xxx'], 'E1001:') enddef def Try_catch_skipped() @@ -1070,7 +1070,7 @@ def Test_throw_vimscript() assert_equal('onetwo', v:exception) endtry END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -1086,7 +1086,7 @@ def Test_throw_vimscript() endtry assert_equal('caught', result) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_error_in_nested_function() @@ -1103,7 +1103,7 @@ def Test_error_in_nested_function() Func() END g:test_var = 0 - CheckScriptFailure(lines, 'E684:') + v9.CheckScriptFailure(lines, 'E684:') assert_equal(0, g:test_var) enddef @@ -1116,7 +1116,7 @@ def Test_abort_after_error() g:gotthere = true END g:gotthere = false - CheckScriptFailure(lines, 'E121:') + v9.CheckScriptFailure(lines, 'E121:') assert_false(g:gotthere) unlet g:gotthere enddef @@ -1131,7 +1131,7 @@ def Test_cexpr_vimscript() ' line 19' assert_equal(19, getqflist()[0].lnum) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) set errorformat& enddef @@ -1146,7 +1146,7 @@ def Test_statusline_syntax() redrawstatus set laststatus statusline= END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_list_vimscript() @@ -1162,7 +1162,7 @@ def Test_list_vimscript() ] assert_equal(['one', 'two', 'three'], mylist) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) # check all lines from heredoc are kept lines =<< trim END @@ -1179,7 +1179,7 @@ def Test_list_vimscript() [{ a: 0}]->string()->assert_equal("[{'a': 0}]") END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef if has('channel') @@ -1210,21 +1210,21 @@ def Test_vim9script_mix() END g:feature = 'eval' g:legacy = -1 - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_equal(1, g:legacy) g:feature = 'noteval' g:legacy = -1 - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) assert_equal(0, g:legacy) enddef def Test_vim9script_fails() - CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:') - CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:') + v9.CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:') + v9.CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:') - CheckScriptFailure(['vim9script', 'var str: string', 'str = 1234'], 'E1012:') - CheckScriptFailure(['vim9script', 'const str = "asdf"', 'str = "xxx"'], 'E46:') + v9.CheckScriptFailure(['vim9script', 'var str: string', 'str = 1234'], 'E1012:') + v9.CheckScriptFailure(['vim9script', 'const str = "asdf"', 'str = "xxx"'], 'E46:') assert_fails('vim9script', 'E1038:') enddef @@ -1237,7 +1237,7 @@ def Test_script_var_shadows_function() enddef var Func = 1 END - CheckScriptFailure(lines, 'E1041:', 5) + v9.CheckScriptFailure(lines, 'E1041:', 5) enddef def Test_function_shadows_script_var() @@ -1248,7 +1248,7 @@ def Test_function_shadows_script_var() return 123 enddef END - CheckScriptFailure(lines, 'E1041:', 3) + v9.CheckScriptFailure(lines, 'E1041:', 3) enddef def Test_script_var_shadows_command() @@ -1257,13 +1257,13 @@ def Test_script_var_shadows_command() undo = 2 assert_equal(2, undo) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var undo = 1 undo END - CheckDefAndScriptFailure(lines, 'E1207:', 2) + v9.CheckDefAndScriptFailure(lines, 'E1207:', 2) enddef def Test_vim9script_call_wrong_type() @@ -1272,7 +1272,7 @@ def Test_vim9script_call_wrong_type() var Time = 'localtime' Time() END - CheckScriptFailure(lines, 'E1085:') + v9.CheckScriptFailure(lines, 'E1085:') enddef def Test_vim9script_reload_delfunc() @@ -1371,7 +1371,7 @@ def Test_func_redefine_fails() echo 'two' enddef END - CheckScriptFailure(lines, 'E1073:') + v9.CheckScriptFailure(lines, 'E1073:') lines =<< trim END vim9script @@ -1383,7 +1383,7 @@ def Test_func_redefine_fails() enddef defcompile END - CheckScriptFailure(lines, 'E1073:') + v9.CheckScriptFailure(lines, 'E1073:') enddef def Test_fixed_size_list() @@ -1396,26 +1396,26 @@ def Test_fixed_size_list() enddef def Test_no_insert_xit() - CheckDefExecFailure(['a = 1'], 'E1100:') - CheckDefExecFailure(['c = 1'], 'E1100:') - CheckDefExecFailure(['i = 1'], 'E1100:') - CheckDefExecFailure(['t = 1'], 'E1100:') - CheckDefExecFailure(['x = 1'], 'E1100:') - - CheckScriptFailure(['vim9script', 'a = 1'], 'E488:') - CheckScriptFailure(['vim9script', 'a'], 'E1100:') - CheckScriptFailure(['vim9script', 'c = 1'], 'E488:') - CheckScriptFailure(['vim9script', 'c'], 'E1100:') - CheckScriptFailure(['vim9script', 'i = 1'], 'E488:') - CheckScriptFailure(['vim9script', 'i'], 'E1100:') - CheckScriptFailure(['vim9script', 'o = 1'], 'E1100:') - CheckScriptFailure(['vim9script', 'o'], 'E1100:') - CheckScriptFailure(['vim9script', 't'], 'E1100:') - CheckScriptFailure(['vim9script', 't = 1'], 'E1100:') - CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:') -enddef - -def IfElse(what: number): string + v9.CheckDefExecFailure(['a = 1'], 'E1100:') + v9.CheckDefExecFailure(['c = 1'], 'E1100:') + v9.CheckDefExecFailure(['i = 1'], 'E1100:') + v9.CheckDefExecFailure(['t = 1'], 'E1100:') + v9.CheckDefExecFailure(['x = 1'], 'E1100:') + + v9.CheckScriptFailure(['vim9script', 'a = 1'], 'E488:') + v9.CheckScriptFailure(['vim9script', 'a'], 'E1100:') + v9.CheckScriptFailure(['vim9script', 'c = 1'], 'E488:') + v9.CheckScriptFailure(['vim9script', 'c'], 'E1100:') + v9.CheckScriptFailure(['vim9script', 'i = 1'], 'E488:') + v9.CheckScriptFailure(['vim9script', 'i'], 'E1100:') + v9.CheckScriptFailure(['vim9script', 'o = 1'], 'E1100:') + v9.CheckScriptFailure(['vim9script', 'o'], 'E1100:') + v9.CheckScriptFailure(['vim9script', 't'], 'E1100:') + v9.CheckScriptFailure(['vim9script', 't = 1'], 'E1100:') + v9.CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:') +enddef + +def s:IfElse(what: number): string var res = '' if what == 1 res = "one" @@ -1434,18 +1434,18 @@ def Test_if_elseif_else() enddef def Test_if_elseif_else_fails() - CheckDefFailure(['elseif true'], 'E582:') - CheckDefFailure(['else'], 'E581:') - CheckDefFailure(['endif'], 'E580:') - CheckDefFailure(['if g:abool', 'elseif xxx'], 'E1001:') - CheckDefFailure(['if true', 'echo 1'], 'E171:') + v9.CheckDefFailure(['elseif true'], 'E582:') + v9.CheckDefFailure(['else'], 'E581:') + v9.CheckDefFailure(['endif'], 'E580:') + v9.CheckDefFailure(['if g:abool', 'elseif xxx'], 'E1001:') + v9.CheckDefFailure(['if true', 'echo 1'], 'E171:') var lines =<< trim END var s = '' if s = '' endif END - CheckDefFailure(lines, 'E488:') + v9.CheckDefFailure(lines, 'E488:') lines =<< trim END var s = '' @@ -1453,7 +1453,7 @@ def Test_if_elseif_else_fails() elseif s = '' endif END - CheckDefFailure(lines, 'E488:') + v9.CheckDefFailure(lines, 'E488:') enddef let g:bool_true = v:true @@ -1590,13 +1590,13 @@ def Test_if_const_expr() enddef def Test_if_const_expr_fails() - CheckDefFailure(['if "aaa" == "bbb'], 'E114:') - CheckDefFailure(["if 'aaa' == 'bbb"], 'E115:') - CheckDefFailure(["if has('aaa'"], 'E110:') - CheckDefFailure(["if has('aaa') ? true false"], 'E109:') + v9.CheckDefFailure(['if "aaa" == "bbb'], 'E114:') + v9.CheckDefFailure(["if 'aaa' == 'bbb"], 'E115:') + v9.CheckDefFailure(["if has('aaa'"], 'E110:') + v9.CheckDefFailure(["if has('aaa') ? true false"], 'E109:') enddef -def RunNested(i: number): number +def s:RunNested(i: number): number var x: number = 0 if i % 2 if 1 @@ -1645,14 +1645,14 @@ def Test_execute_cmd() var n = true execute 'echomsg' (n ? '"true"' : '"no"') - assert_match('^true$', Screenline(&lines)) + assert_match('^true$', g:Screenline(&lines)) echomsg [1, 2, 3] {a: 1, b: 2} - assert_match('^\[1, 2, 3\] {''a'': 1, ''b'': 2}$', Screenline(&lines)) + assert_match('^\[1, 2, 3\] {''a'': 1, ''b'': 2}$', g:Screenline(&lines)) - CheckDefFailure(['execute xxx'], 'E1001:', 1) - CheckDefExecFailure(['execute "tabnext " .. 8'], 'E475:', 1) - CheckDefFailure(['execute "cmd"# comment'], 'E488:', 1) + v9.CheckDefFailure(['execute xxx'], 'E1001:', 1) + v9.CheckDefExecFailure(['execute "tabnext " .. 8'], 'E475:', 1) + v9.CheckDefFailure(['execute "cmd"# comment'], 'E488:', 1) enddef def Test_execute_cmd_vimscript() @@ -1665,34 +1665,34 @@ def Test_execute_cmd_vimscript() assert_equal(28, g:someVar) unlet g:someVar END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_echo_cmd() echo 'some' # comment echon 'thing' - assert_match('^something$', Screenline(&lines)) + assert_match('^something$', g:Screenline(&lines)) echo "some" # comment echon "thing" - assert_match('^something$', Screenline(&lines)) + assert_match('^something$', g:Screenline(&lines)) var str1 = 'some' var str2 = 'more' echo str1 str2 - assert_match('^some more$', Screenline(&lines)) + assert_match('^some more$', g:Screenline(&lines)) - CheckDefFailure(['echo "xxx"# comment'], 'E488:') + v9.CheckDefFailure(['echo "xxx"# comment'], 'E488:') enddef def Test_echomsg_cmd() echomsg 'some' 'more' # comment - assert_match('^some more$', Screenline(&lines)) + assert_match('^some more$', g:Screenline(&lines)) echo 'clear' :1messages - assert_match('^some more$', Screenline(&lines)) + assert_match('^some more$', g:Screenline(&lines)) - CheckDefFailure(['echomsg "xxx"# comment'], 'E488:') + v9.CheckDefFailure(['echomsg "xxx"# comment'], 'E488:') enddef def Test_echomsg_cmd_vimscript() @@ -1702,9 +1702,9 @@ def Test_echomsg_cmd_vimscript() echomsg 'here' .. ' is ' .. 'a message' - assert_match('^here is a message$', Screenline(&lines)) + assert_match('^here is a message$', g:Screenline(&lines)) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_echoerr_cmd() @@ -1728,7 +1728,7 @@ def Test_echoerr_cmd_vimscript() assert_match('this is wrong', v:exception) endtry END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_echoconsole_cmd() @@ -1786,7 +1786,7 @@ def Test_for_skipped_block() endif assert_equal([3, 4], result) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # test skipped blocks at inside of function lines =<< trim END @@ -1820,7 +1820,7 @@ def Test_for_skipped_block() enddef DefFalse() END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_for_loop() @@ -1931,7 +1931,7 @@ def Test_for_loop() endfor assert_equal(['x', 'x', 'x'], reslist) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_for_loop_with_closure() @@ -1945,7 +1945,7 @@ def Test_for_loop_with_closure() assert_equal(4, flist[i]()) endfor END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END var flist: list @@ -1959,29 +1959,29 @@ def Test_for_loop_with_closure() assert_equal(4, flist[i]()) endfor END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_for_loop_fails() - CheckDefAndScriptFailure(['for '], ['E1097:', 'E690:']) - CheckDefAndScriptFailure(['for x'], ['E1097:', 'E690:']) - CheckDefAndScriptFailure(['for x in'], ['E1097:', 'E15:']) - CheckDefAndScriptFailure(['for # in range(5)'], 'E690:') - CheckDefAndScriptFailure(['for i In range(5)'], 'E690:') - CheckDefAndScriptFailure(['var x = 5', 'for x in range(5)', 'endfor'], ['E1017:', 'E1041:']) - CheckScriptFailure(['vim9script', 'var x = 5', 'for x in range(5)', '# comment', 'endfor'], 'E1041:', 3) - CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:') + v9.CheckDefAndScriptFailure(['for '], ['E1097:', 'E690:']) + v9.CheckDefAndScriptFailure(['for x'], ['E1097:', 'E690:']) + v9.CheckDefAndScriptFailure(['for x in'], ['E1097:', 'E15:']) + v9.CheckDefAndScriptFailure(['for # in range(5)'], 'E690:') + v9.CheckDefAndScriptFailure(['for i In range(5)'], 'E690:') + v9.CheckDefAndScriptFailure(['var x = 5', 'for x in range(5)', 'endfor'], ['E1017:', 'E1041:']) + v9.CheckScriptFailure(['vim9script', 'var x = 5', 'for x in range(5)', '# comment', 'endfor'], 'E1041:', 3) + v9.CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:') delfunc! g:Func - CheckDefFailure(['for i in xxx'], 'E1001:') - CheckDefFailure(['endfor'], 'E588:') - CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:') + v9.CheckDefFailure(['for i in xxx'], 'E1001:') + v9.CheckDefFailure(['endfor'], 'E588:') + v9.CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:') # wrong type detected at compile time - CheckDefFailure(['for i in {a: 1}', 'echo 3', 'endfor'], 'E1177: For loop on dict not supported') + v9.CheckDefFailure(['for i in {a: 1}', 'echo 3', 'endfor'], 'E1177: For loop on dict not supported') # wrong type detected at runtime g:adict = {a: 1} - CheckDefExecFailure(['for i in g:adict', 'echo 3', 'endfor'], 'E1177: For loop on dict not supported') + v9.CheckDefExecFailure(['for i in g:adict', 'echo 3', 'endfor'], 'E1177: For loop on dict not supported') unlet g:adict var lines =<< trim END @@ -1990,20 +1990,20 @@ def Test_for_loop_fails() e = {a: 0, b: ''} endfor END - CheckDefAndScriptFailure(lines, ['E1018:', 'E46:'], 3) + v9.CheckDefAndScriptFailure(lines, ['E1018:', 'E46:'], 3) lines =<< trim END for nr: number in ['foo'] endfor END - CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got string', 1) + v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got string', 1) lines =<< trim END for n : number in [1, 2] echo n endfor END - CheckDefAndScriptFailure(lines, 'E1059:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1059:', 1) lines =<< trim END var d: dict = {a: 1, b: 2} @@ -2011,7 +2011,7 @@ def Test_for_loop_fails() echo k v endfor END - CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected job but got string', 2) + v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected job but got string', 2) lines =<< trim END var i = 0 @@ -2019,7 +2019,7 @@ def Test_for_loop_fails() echo i endfor END - CheckDefExecAndScriptFailure(lines, ['E1017:', 'E1041:']) + v9.CheckDefExecAndScriptFailure(lines, ['E1017:', 'E1041:']) lines =<< trim END var l = [0] @@ -2027,7 +2027,7 @@ def Test_for_loop_fails() echo l[0] endfor END - CheckDefExecAndScriptFailure(lines, ['E461:', 'E1017:']) + v9.CheckDefExecAndScriptFailure(lines, ['E461:', 'E1017:']) lines =<< trim END var d = {x: 0} @@ -2035,12 +2035,12 @@ def Test_for_loop_fails() echo d.x endfor END - CheckDefExecAndScriptFailure(lines, ['E461:', 'E1017:']) + v9.CheckDefExecAndScriptFailure(lines, ['E461:', 'E1017:']) enddef def Test_for_loop_script_var() # cannot use s:var in a :def function - CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E1254:') + v9.CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E1254:') # can use s:var in Vim9 script, with or without s: var lines =<< trim END @@ -2107,28 +2107,28 @@ def Test_for_loop_unpack() endfor assert_equal([2, 5], res) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) lines =<< trim END for [v1, v2] in [[1, 2, 3], [3, 4]] echo v1 v2 endfor END - CheckDefExecFailure(lines, 'E710:', 1) + v9.CheckDefExecFailure(lines, 'E710:', 1) lines =<< trim END for [v1, v2] in [[1], [3, 4]] echo v1 v2 endfor END - CheckDefExecFailure(lines, 'E711:', 1) + v9.CheckDefExecFailure(lines, 'E711:', 1) lines =<< trim END for [v1, v1] in [[1, 2], [3, 4]] echo v1 endfor END - CheckDefExecFailure(lines, 'E1017:', 1) + v9.CheckDefExecFailure(lines, 'E1017:', 1) enddef def Test_for_loop_with_try_continue() @@ -2148,7 +2148,7 @@ def Test_for_loop_with_try_continue() assert_equal(3, looped) assert_equal(3, cleanup) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_while_skipped_block() @@ -2187,7 +2187,7 @@ def Test_while_skipped_block() endif assert_equal([3, 4], result) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) # test skipped blocks at inside of function lines =<< trim END @@ -2231,7 +2231,7 @@ def Test_while_skipped_block() enddef DefFalse() END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef def Test_while_loop() @@ -2266,24 +2266,24 @@ def Test_while_loop_in_script() endwhile assert_equal('v0v1v2', result) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_while_loop_fails() - CheckDefFailure(['while xxx'], 'E1001:') - CheckDefFailure(['endwhile'], 'E588:') - CheckDefFailure(['continue'], 'E586:') - CheckDefFailure(['if true', 'continue'], 'E586:') - CheckDefFailure(['break'], 'E587:') - CheckDefFailure(['if true', 'break'], 'E587:') - CheckDefFailure(['while 1', 'echo 3'], 'E170:') + v9.CheckDefFailure(['while xxx'], 'E1001:') + v9.CheckDefFailure(['endwhile'], 'E588:') + v9.CheckDefFailure(['continue'], 'E586:') + v9.CheckDefFailure(['if true', 'continue'], 'E586:') + v9.CheckDefFailure(['break'], 'E587:') + v9.CheckDefFailure(['if true', 'break'], 'E587:') + v9.CheckDefFailure(['while 1', 'echo 3'], 'E170:') var lines =<< trim END var s = '' while s = '' endwhile END - CheckDefFailure(lines, 'E488:') + v9.CheckDefFailure(lines, 'E488:') enddef def Test_interrupt_loop() @@ -2342,7 +2342,7 @@ def Test_automatic_line_continuation() enddef def Test_vim9_comment() - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', '# something', '#something', @@ -2350,126 +2350,126 @@ def Test_vim9_comment() ]) split Xfile - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'edit #something', ]) - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'edit #{something', ]) close - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', ':# something', ], 'E488:') - CheckScriptFailure([ + v9.CheckScriptFailure([ '# something', ], 'E488:') - CheckScriptFailure([ + v9.CheckScriptFailure([ ':# something', ], 'E488:') { # block start } # block end - CheckDefFailure([ + v9.CheckDefFailure([ '{# comment', ], 'E488:') - CheckDefFailure([ + v9.CheckDefFailure([ '{', '}# comment', ], 'E488:') echo "yes" # comment - CheckDefFailure([ + v9.CheckDefFailure([ 'echo "yes"# comment', ], 'E488:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'echo "yes" # something', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'echo "yes"# something', ], 'E121:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'echo# something', ], 'E1144:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'echo "yes" # something', ], 'E121:') exe "echo" # comment - CheckDefFailure([ + v9.CheckDefFailure([ 'exe "echo"# comment', ], 'E488:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'exe "echo" # something', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'exe "echo"# something', ], 'E121:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'exe# something', ], 'E1144:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'exe "echo" # something', ], 'E121:') - CheckDefFailure([ + v9.CheckDefFailure([ 'try# comment', ' echo "yes"', 'catch', 'endtry', ], 'E1144:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'try# comment', 'echo "yes"', ], 'E1144:') - CheckDefFailure([ + v9.CheckDefFailure([ 'try', ' throw#comment', 'catch', 'endtry', ], 'E1144:') - CheckDefFailure([ + v9.CheckDefFailure([ 'try', ' throw "yes"#comment', 'catch', 'endtry', ], 'E488:') - CheckDefFailure([ + v9.CheckDefFailure([ 'try', ' echo "yes"', 'catch# comment', 'endtry', ], 'E1144:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'try', ' echo "yes"', 'catch# comment', 'endtry', ], 'E1144:') - CheckDefFailure([ + v9.CheckDefFailure([ 'try', ' echo "yes"', 'catch /pat/# comment', 'endtry', ], 'E488:') - CheckDefFailure([ + v9.CheckDefFailure([ 'try', 'echo "yes"', 'catch', 'endtry# comment', ], 'E1144:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'try', ' echo "yes"', @@ -2477,192 +2477,192 @@ def Test_vim9_comment() 'endtry# comment', ], 'E1144:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'hi # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'hi# comment', ], 'E1144:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'hi Search # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'hi Search# comment', ], 'E416:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'hi link This Search # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'hi link This That# comment', ], 'E413:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'hi clear This # comment', 'hi clear # comment', ]) # not tested, because it doesn't give an error but a warning: # hi clear This# comment', - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'hi clear# comment', ], 'E416:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'hi Group term=bold', 'match Group /todo/ # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'hi Group term=bold', 'match Group /todo/# comment', ], 'E488:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'match # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'match# comment', ], 'E1144:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'match none # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'match none# comment', ], 'E475:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'menutrans clear # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'menutrans clear# comment text', ], 'E474:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax clear # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax clear# comment text', ], 'E28:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax keyword Word some', 'syntax clear Word # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax keyword Word some', 'syntax clear Word# comment text', ], 'E28:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax list # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax list# comment text', ], 'E28:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax match Word /pat/ oneline # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax match Word /pat/ oneline# comment', ], 'E475:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax keyword Word word # comm[ent', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax keyword Word word# comm[ent', ], 'E789:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax match Word /pat/ # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax match Word /pat/# comment', ], 'E402:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax match Word /pat/ contains=Something # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax match Word /pat/ contains=Something# comment', ], 'E475:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax match Word /pat/ contains= # comment', ], 'E406:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax match Word /pat/ contains=# comment', ], 'E475:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax region Word start=/pat/ end=/pat/ # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax region Word start=/pat/ end=/pat/# comment', ], 'E402:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax sync # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax sync# comment', ], 'E404:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax sync ccomment # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax sync ccomment# comment', ], 'E404:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'syntax cluster Some contains=Word # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'syntax cluster Some contains=Word# comment', ], 'E475:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'command Echo echo # comment', 'command Echo # comment', 'delcommand Echo', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'command Echo echo# comment', 'Echo', @@ -2670,18 +2670,18 @@ def Test_vim9_comment() delcommand Echo var curdir = getcwd() - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'command Echo cd " comment', 'Echo', 'delcommand Echo', ]) - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'command Echo cd # comment', 'Echo', 'delcommand Echo', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'command Echo cd " comment', 'Echo', @@ -2689,86 +2689,88 @@ def Test_vim9_comment() delcommand Echo chdir(curdir) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'command Echo# comment', ], 'E182:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'command Echo echo', 'command Echo# comment', ], 'E182:') delcommand Echo - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'function # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'function " comment', ], 'E129:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'function# comment', ], 'E1144:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', - 'function CheckScriptSuccess # comment', + 'import "./vim9.vim" as v9', + 'function v9.CheckScriptSuccess # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', - 'function CheckScriptSuccess# comment', - ], 'E488:') + 'import "./vim9.vim" as v9', + 'function v9.CheckScriptSuccess# comment', + ], 'E1048: Item not found in script: CheckScriptSuccess#') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'func g:DeleteMeA()', 'endfunc', 'delfunction g:DeleteMeA # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'func g:DeleteMeB()', 'endfunc', 'delfunction g:DeleteMeB# comment', ], 'E488:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'call execute("ls") # comment', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'call execute("ls")# comment', ], 'E488:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'def Test() " comment', 'enddef', ], 'E488:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'def Test() " comment', 'enddef', ], 'E488:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'func Test() " comment', 'endfunc', 'delfunc Test', ]) - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'func Test() " comment', 'endfunc', ]) - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'def Test() # comment', 'enddef', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'func Test() # comment', 'endfunc', ], 'E488:') @@ -2783,7 +2785,7 @@ def Test_vim9_comment() #\ comment \ end='bar' END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -2792,17 +2794,17 @@ def Test_vim9_comment() "\ comment \ end='bar' END - CheckScriptFailure(lines, 'E399:') + v9.CheckScriptFailure(lines, 'E399:') enddef def Test_vim9_comment_gui() CheckCanRunGui - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'gui#comment' ], 'E1144:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'gui -f#comment' ], 'E194:') @@ -2828,7 +2830,7 @@ def Test_vim9_comment_not_compiled() au! TabEnter unlet g:entered - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'g:var = 123', 'b:var = 456', @@ -2837,53 +2839,53 @@ def Test_vim9_comment_not_compiled() 'unlet g:var w:var # something', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'let var = 123', ], 'E1126: Cannot use :let in Vim9 script') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var g:var = 123', ], 'E1016: Cannot declare a global variable:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var b:var = 123', ], 'E1016: Cannot declare a buffer variable:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var w:var = 123', ], 'E1016: Cannot declare a window variable:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var t:var = 123', ], 'E1016: Cannot declare a tab variable:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var v:version = 123', ], 'E1016: Cannot declare a v: variable:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var $VARIABLE = "text"', ], 'E1016: Cannot declare an environment variable:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'g:var = 123', 'unlet g:var# comment1', ], 'E108:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'let g:var = 123', 'unlet g:var # something', ], 'E488:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'if 1 # comment2', ' echo "yes"', @@ -2892,14 +2894,14 @@ def Test_vim9_comment_not_compiled() 'endif', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'if 1# comment3', ' echo "yes"', 'endif', ], 'E488:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'if 0 # comment4', ' echo "yes"', @@ -2908,17 +2910,17 @@ def Test_vim9_comment_not_compiled() 'endif', ], 'E488:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'var v = 1 # comment5', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'var v = 1# comment6', ], 'E488:') - CheckScriptSuccess([ + v9.CheckScriptSuccess([ 'vim9script', 'new' 'setline(1, ["# define pat", "last"])', @@ -2927,7 +2929,7 @@ def Test_vim9_comment_not_compiled() 'bwipe!', ]) - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'new' 'setline(1, ["# define pat", "last"])', @@ -2936,7 +2938,7 @@ def Test_vim9_comment_not_compiled() 'bwipe!', ], 'E488:') - CheckScriptFailure([ + v9.CheckScriptFailure([ 'vim9script', 'func! SomeFunc()', ], 'E477:') @@ -3005,7 +3007,7 @@ def Test_declare_script_in_func() endtry assert_match('E741: Value is locked: local', error) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef @@ -3065,7 +3067,7 @@ def Test_script_var_in_autocmd() call assert_equal(2, s:counter) au! CursorHold END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) enddef def Test_error_in_autoload_script() @@ -3102,7 +3104,7 @@ def Test_error_in_autoload_script() Legacy() END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) &rtp = save_rtp delete(dir, 'rf') @@ -3111,7 +3113,7 @@ enddef def Test_invalid_sid() assert_fails('func 1234_func', 'E123:') - if RunVim([], ['wq! Xdidit'], '+"func 1_func"') + if g:RunVim([], ['wq! Xdidit'], '+"func 1_func"') assert_equal([], readfile('Xdidit')) endif delete('Xdidit') @@ -3120,7 +3122,7 @@ enddef def Test_restoring_cpo() writefile(['vim9script', 'set nocp'], 'Xsourced') writefile(['call writefile(["done"], "Xdone")', 'quit!'], 'Xclose') - if RunVim([], [], '-u NONE +"set cpo+=a" -S Xsourced -S Xclose') + if g:RunVim([], [], '-u NONE +"set cpo+=a" -S Xsourced -S Xclose') assert_equal(['done'], readfile('Xdone')) endif delete('Xsourced') @@ -3169,7 +3171,7 @@ def Test_restoring_cpo() END writefile(lines, 'Xvim9') - var cmd = GetVimCommand() .. " -S Xlegacy -S Xvim9" + var cmd = g:GetVimCommand() .. " -S Xlegacy -S Xvim9" cmd = substitute(cmd, '-u NONE', '', '') exe "silent !" .. cmd @@ -3208,13 +3210,13 @@ func Test_no_redraw_when_restoring_cpo() setline(1, 'some text') END call writefile(lines, 'XTest_redraw_cpo') - let buf = RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6}) + let buf = g:RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6}) call term_sendkeys(buf, "V:") call VerifyScreenDump(buf, 'Test_vim9_no_redraw', {}) " clean up call term_sendkeys(buf, "\u") - call StopVimInTerminal(buf) + call g:StopVimInTerminal(buf) call delete('XTest_redraw_cpo') call delete('Xdir', 'rf') endfunc @@ -3225,7 +3227,7 @@ def Test_unset_any_variable() var name: any assert_equal(0, name) END - CheckDefAndScriptSuccess(lines) + v9.CheckDefAndScriptSuccess(lines) enddef func Test_define_func_at_command_line() @@ -3245,13 +3247,13 @@ def Run_Test_define_func_at_command_line() END writefile([''], 'Xdidcmd') writefile(lines, 'XcallFunc') - var buf = RunVimInTerminal('-S XcallFunc', {rows: 6}) + var buf = g:RunVimInTerminal('-S XcallFunc', {rows: 6}) # define Afunc() on the command line term_sendkeys(buf, ":def Afunc()\Bfunc()\enddef\") term_sendkeys(buf, ":call CheckAndQuit()\") - WaitForAssert(() => assert_equal(['errors: []'], readfile('Xdidcmd'))) + g:WaitForAssert(() => assert_equal(['errors: []'], readfile('Xdidcmd'))) - call StopVimInTerminal(buf) + call g:StopVimInTerminal(buf) delete('XcallFunc') delete('Xdidcmd') enddef @@ -3267,7 +3269,7 @@ def Test_script_var_scope() echo one endif END - CheckScriptFailure(lines, 'E121:', 7) + v9.CheckScriptFailure(lines, 'E121:', 7) lines =<< trim END vim9script @@ -3282,7 +3284,7 @@ def Test_script_var_scope() echo one endif END - CheckScriptFailure(lines, 'E121:', 10) + v9.CheckScriptFailure(lines, 'E121:', 10) lines =<< trim END vim9script @@ -3293,7 +3295,7 @@ def Test_script_var_scope() endwhile echo one END - CheckScriptFailure(lines, 'E121:', 7) + v9.CheckScriptFailure(lines, 'E121:', 7) lines =<< trim END vim9script @@ -3303,7 +3305,7 @@ def Test_script_var_scope() endfor echo one END - CheckScriptFailure(lines, 'E121:', 6) + v9.CheckScriptFailure(lines, 'E121:', 6) lines =<< trim END vim9script @@ -3314,7 +3316,7 @@ def Test_script_var_scope() assert_false(exists('one')) assert_false(exists('s:one')) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) lines =<< trim END vim9script @@ -3324,7 +3326,7 @@ def Test_script_var_scope() } echo one END - CheckScriptFailure(lines, 'E121:', 6) + v9.CheckScriptFailure(lines, 'E121:', 6) enddef def Test_catch_exception_in_callback() @@ -3344,7 +3346,7 @@ def Test_catch_exception_in_callback() popup_menu('popup', {callback: Callback}) feedkeys("\r", 'xt') END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) unlet g:caught enddef @@ -3396,12 +3398,12 @@ def Test_white_space_after_command() var lines =<< trim END exit_cb: Func}) END - CheckDefAndScriptFailure(lines, 'E1144:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1144:', 1) lines =<< trim END e# END - CheckDefAndScriptFailure(lines, 'E1144:', 1) + v9.CheckDefAndScriptFailure(lines, 'E1144:', 1) enddef def Test_script_var_gone_when_sourced_twice() @@ -3438,32 +3440,32 @@ def Test_unsupported_commands() var lines =<< trim END ka END - CheckDefFailure(lines, 'E476:') - CheckScriptFailure(['vim9script'] + lines, 'E492:') + v9.CheckDefFailure(lines, 'E476:') + v9.CheckScriptFailure(['vim9script'] + lines, 'E492:') lines =<< trim END :1ka END - CheckDefFailure(lines, 'E476:') - CheckScriptFailure(['vim9script'] + lines, 'E492:') + v9.CheckDefFailure(lines, 'E476:') + v9.CheckScriptFailure(['vim9script'] + lines, 'E492:') lines =<< trim END t END - CheckDefFailure(lines, 'E1100:') - CheckScriptFailure(['vim9script'] + lines, 'E1100:') + v9.CheckDefFailure(lines, 'E1100:') + v9.CheckScriptFailure(['vim9script'] + lines, 'E1100:') lines =<< trim END x END - CheckDefFailure(lines, 'E1100:') - CheckScriptFailure(['vim9script'] + lines, 'E1100:') + v9.CheckDefFailure(lines, 'E1100:') + v9.CheckScriptFailure(['vim9script'] + lines, 'E1100:') lines =<< trim END xit END - CheckDefFailure(lines, 'E1100:') - CheckScriptFailure(['vim9script'] + lines, 'E1100:') + v9.CheckDefFailure(lines, 'E1100:') + v9.CheckScriptFailure(['vim9script'] + lines, 'E1100:') enddef def Test_mapping_line_number() @@ -3485,7 +3487,7 @@ def Test_mapping_line_number() .. 'c' enddef END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) var res = execute('verbose nmap ') assert_match('No mapping found', res) @@ -3503,7 +3505,7 @@ def Test_option_set() set foldlevel =11 call assert_equal(11, &foldlevel) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) set foldlevel set foldlevel=12 @@ -3516,22 +3518,22 @@ def Test_option_set() lines =<< trim END set foldlevel =1 END - CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: =1') + v9.CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: =1') lines =<< trim END set foldlevel +=1 END - CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: +=1') + v9.CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: +=1') lines =<< trim END set foldlevel ^=1 END - CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: ^=1') + v9.CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: ^=1') lines =<< trim END set foldlevel -=1 END - CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: -=1') + v9.CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: -=1') set foldlevel& enddef @@ -3542,7 +3544,7 @@ def Test_option_modifier() set hlsearch & hlsearch ! call assert_equal(1, &hlsearch) END - CheckScriptSuccess(lines) + v9.CheckScriptSuccess(lines) set hlsearch set hlsearch! @@ -3555,12 +3557,12 @@ def Test_option_modifier() lines =<< trim END set hlsearch & END - CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: &') + v9.CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: &') lines =<< trim END set hlsearch ! END - CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: !') + v9.CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: !') set hlsearch& enddef @@ -3572,7 +3574,7 @@ def Test_xxx_echoerr_line_number() .. ' error' .. ' continued' END - CheckDefExecAndScriptFailure(lines, 'some error continued', 1) + v9.CheckDefExecAndScriptFailure(lines, 'some error continued', 1) enddef func Test_debug_with_lambda() @@ -3593,13 +3595,13 @@ def Run_Test_debug_with_lambda() Func() END writefile(lines, 'XdebugFunc') - var buf = RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) - WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) + var buf = g:RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) + g:WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) term_sendkeys(buf, "cont\") - WaitForAssert(() => assert_match('\[0\]', term_getline(buf, 5))) + g:WaitForAssert(() => assert_match('\[0\]', term_getline(buf, 5))) - StopVimInTerminal(buf) + g:StopVimInTerminal(buf) delete('XdebugFunc') enddef @@ -3629,26 +3631,26 @@ def Run_Test_debug_running_out_of_lines() Crash() END writefile(lines, 'XdebugFunc') - var buf = RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) - WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) + var buf = g:RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) + g:WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) term_sendkeys(buf, "next\") - TermWait(buf) - WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) + g:TermWait(buf) + g:WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) term_sendkeys(buf, "cont\") - TermWait(buf) + g:TermWait(buf) - StopVimInTerminal(buf) + g:StopVimInTerminal(buf) delete('XdebugFunc') enddef -def ProfiledWithLambda() +def s:ProfiledWithLambda() var n = 3 echo [[1, 2], [3, 4]]->filter((_, l) => l[0] == n) enddef -def ProfiledNested() +def s:ProfiledNested() var x = 0 def Nested(): any return x @@ -3671,7 +3673,7 @@ def Test_ambigous_command_error() command CmdB echomsg 'CmdB' Cmd END - CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 4) + v9.CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 4) lines =<< trim END vim9script @@ -3680,14 +3682,14 @@ def Test_ambigous_command_error() enddef Func() END - CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 1) + v9.CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 1) lines =<< trim END vim9script nnoremap Cmd feedkeys("\", 'xt') END - CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 3) + v9.CheckScriptFailure(lines, 'E464: Ambiguous use of user-defined command: Cmd', 3) delcommand CmdA delcommand CmdB @@ -3709,7 +3711,7 @@ def Test_xx_profile_with_lambda() # Also profile the nested function. Use a different function, although the # contents is the same, to make sure it was not already compiled. profile func * - ProfiledNestedProfiled() + g:ProfiledNestedProfiled() profdel func * profile pause diff --git a/src/testdir/vim9.vim b/src/testdir/vim9.vim index 89f3c7917..92ea0bad7 100644 --- a/src/testdir/vim9.vim +++ b/src/testdir/vim9.vim @@ -1,10 +1,12 @@ -" Utility functions for testing vim9 script +vim9script -" Use a different file name for each run. -let s:sequence = 1 +# Utility functions for testing vim9 script -" Check that "lines" inside a ":def" function has no error when called. -func CheckDefSuccess(lines) +# Use a different file name for each run. +var sequence = 1 + +# Check that "lines" inside a ":def" function has no error when called. +export func CheckDefSuccess(lines) let cwd = getcwd() let fname = 'XdefSuccess' .. s:sequence let s:sequence += 1 @@ -19,8 +21,8 @@ func CheckDefSuccess(lines) endtry endfunc -" Check that "lines" inside a ":def" function has no error when compiled. -func CheckDefCompileSuccess(lines) +# Check that "lines" inside a ":def" function has no error when compiled. +export func CheckDefCompileSuccess(lines) let fname = 'XdefSuccess' .. s:sequence let s:sequence += 1 call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname) @@ -32,11 +34,11 @@ func CheckDefCompileSuccess(lines) endtry endfunc -" Check that "lines" inside ":def" results in an "error" message. -" If "lnum" is given check that the error is reported for this line. -" Add a line before and after to make it less likely that the line number is -" accidentally correct. -func CheckDefFailure(lines, error, lnum = -3) +# Check that "lines" inside ":def" results in an "error" message. +# If "lnum" is given check that the error is reported for this line. +# Add a line before and after to make it less likely that the line number is +# accidentally correct. +export func CheckDefFailure(lines, error, lnum = -3) let cwd = getcwd() let fname = 'XdefFailure' .. s:sequence let s:sequence += 1 @@ -50,11 +52,11 @@ func CheckDefFailure(lines, error, lnum = -3) endtry endfunc -" Check that "lines" inside ":def" results in an "error" message when executed. -" If "lnum" is given check that the error is reported for this line. -" Add a line before and after to make it less likely that the line number is -" accidentally correct. -func CheckDefExecFailure(lines, error, lnum = -3) +# Check that "lines" inside ":def" results in an "error" message when executed. +# If "lnum" is given check that the error is reported for this line. +# Add a line before and after to make it less likely that the line number is +# accidentally correct. +export func CheckDefExecFailure(lines, error, lnum = -3) let cwd = getcwd() let fname = 'XdefExecFailure' .. s:sequence let s:sequence += 1 @@ -69,7 +71,7 @@ func CheckDefExecFailure(lines, error, lnum = -3) endtry endfunc -def CheckScriptFailure(lines: list, error: string, lnum = -3) +export def CheckScriptFailure(lines: list, error: string, lnum = -3) var cwd = getcwd() var fname = 'XScriptFailure' .. s:sequence s:sequence += 1 @@ -82,7 +84,7 @@ def CheckScriptFailure(lines: list, error: string, lnum = -3) endtry enddef -def CheckScriptFailureList(lines: list, errors: list, lnum = -3) +export def CheckScriptFailureList(lines: list, errors: list, lnum = -3) var cwd = getcwd() var fname = 'XScriptFailure' .. s:sequence s:sequence += 1 @@ -95,7 +97,7 @@ def CheckScriptFailureList(lines: list, errors: list, lnum = -3) endtry enddef -def CheckScriptSuccess(lines: list) +export def CheckScriptSuccess(lines: list) var cwd = getcwd() var fname = 'XScriptSuccess' .. s:sequence s:sequence += 1 @@ -108,17 +110,17 @@ def CheckScriptSuccess(lines: list) endtry enddef -def CheckDefAndScriptSuccess(lines: list) +export def CheckDefAndScriptSuccess(lines: list) CheckDefSuccess(lines) CheckScriptSuccess(['vim9script'] + lines) enddef -" Check that a command fails when used in a :def function and when used in -" Vim9 script. -" When "error" is a string, both with the same error. -" When "error" is a list, the :def function fails with "error[0]" , the script -" fails with "error[1]". -def CheckDefAndScriptFailure(lines: list, error: any, lnum = -3) +# Check that a command fails when used in a :def function and when used in +# Vim9 script. +# When "error" is a string, both with the same error. +# When "error" is a list, the :def function fails with "error[0]" , the script +# fails with "error[1]". +export def CheckDefAndScriptFailure(lines: list, error: any, lnum = -3) var errorDef: string var errorScript: string if type(error) == v:t_string @@ -135,12 +137,12 @@ def CheckDefAndScriptFailure(lines: list, error: any, lnum = -3) CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1) enddef -" Check that a command fails when executed in a :def function and when used in -" Vim9 script. -" When "error" is a string, both with the same error. -" When "error" is a list, the :def function fails with "error[0]" , the script -" fails with "error[1]". -def CheckDefExecAndScriptFailure(lines: list, error: any, lnum = -3) +# Check that a command fails when executed in a :def function and when used in +# Vim9 script. +# When "error" is a string, both with the same error. +# When "error" is a list, the :def function fails with "error[0]" , the script +# fails with "error[1]". +export def CheckDefExecAndScriptFailure(lines: list, error: any, lnum = -3) var errorDef: string var errorScript: string if type(error) == v:t_string @@ -158,8 +160,8 @@ def CheckDefExecAndScriptFailure(lines: list, error: any, lnum = -3) enddef -" Check that "lines" inside a legacy function has no error. -func CheckLegacySuccess(lines) +# Check that "lines" inside a legacy function has no error. +export func CheckLegacySuccess(lines) let cwd = getcwd() let fname = 'XlegacySuccess' .. s:sequence let s:sequence += 1 @@ -174,8 +176,8 @@ func CheckLegacySuccess(lines) endtry endfunc -" Check that "lines" inside a legacy function results in the expected error -func CheckLegacyFailure(lines, error) +# Check that "lines" inside a legacy function results in the expected error +export func CheckLegacyFailure(lines, error) let cwd = getcwd() let fname = 'XlegacyFails' .. s:sequence let s:sequence += 1 @@ -189,9 +191,9 @@ func CheckLegacyFailure(lines, error) endtry endfunc -" Execute "lines" in a legacy function, translated as in -" CheckLegacyAndVim9Success() -def CheckTransLegacySuccess(lines: list) +# Execute "lines" in a legacy function, translated as in +# CheckLegacyAndVim9Success() +export def CheckTransLegacySuccess(lines: list) var legacylines = lines->mapnew((_, v) => v->substitute('\', 'let', 'g') ->substitute('\', 'let', 'g') @@ -204,7 +206,7 @@ def CheckTransLegacySuccess(lines: list) CheckLegacySuccess(legacylines) enddef -def Vim9Trans(lines: list): list +export def Vim9Trans(lines: list): list return lines->mapnew((_, v) => v->substitute('\', 'var', 'g') ->substitute('\): list ->substitute('\', 'false', 'g')) enddef -" Execute "lines" in a :def function, translated as in -" CheckLegacyAndVim9Success() -def CheckTransDefSuccess(lines: list) +# Execute "lines" in a :def function, translated as in +# CheckLegacyAndVim9Success() +export def CheckTransDefSuccess(lines: list) CheckDefSuccess(Vim9Trans(lines)) enddef -" Execute "lines" in a Vim9 script, translated as in -" CheckLegacyAndVim9Success() -def CheckTransVim9Success(lines: list) +# Execute "lines" in a Vim9 script, translated as in +# CheckLegacyAndVim9Success() +export def CheckTransVim9Success(lines: list) CheckScriptSuccess(['vim9script'] + Vim9Trans(lines)) enddef -" Execute "lines" in a legacy function, :def function and Vim9 script. -" Use 'VAR' for a declaration. -" Use 'LET' for an assignment -" Use ' #"' for a comment -" Use LSTART arg LMIDDLE expr LEND for lambda -" Use 'TRUE' for 1 in legacy, true in Vim9 -" Use 'FALSE' for 0 in legacy, false in Vim9 -def CheckLegacyAndVim9Success(lines: list) +# Execute "lines" in a legacy function, :def function and Vim9 script. +# Use 'VAR' for a declaration. +# Use 'LET' for an assignment +# Use ' #"' for a comment +# Use LSTART arg LMIDDLE expr LEND for lambda +# Use 'TRUE' for 1 in legacy, true in Vim9 +# Use 'FALSE' for 0 in legacy, false in Vim9 +export def CheckLegacyAndVim9Success(lines: list) CheckTransLegacySuccess(lines) CheckTransDefSuccess(lines) CheckTransVim9Success(lines) enddef -" Execute "lines" in a legacy function, :def function and Vim9 script. -" Use 'VAR' for a declaration. -" Use 'LET' for an assignment -" Use ' #"' for a comment -def CheckLegacyAndVim9Failure(lines: list, error: any) +# Execute "lines" in a legacy function, :def function and Vim9 script. +# Use 'VAR' for a declaration. +# Use 'LET' for an assignment +# Use ' #"' for a comment +export def CheckLegacyAndVim9Failure(lines: list, error: any) var legacyError: string var defError: string var scriptError: string -- cgit v1.2.1