mirror of
https://github.com/zoriya/vim.git
synced 2025-12-22 23:25:31 +00:00
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.
This commit is contained in:
@@ -963,7 +963,7 @@ get_lval(
|
|||||||
if (lp->ll_name == NULL)
|
if (lp->ll_name == NULL)
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
if (*p == '.' && in_vim9script())
|
if (*p == '.')
|
||||||
{
|
{
|
||||||
imported_T *import = find_imported(lp->ll_name, p - lp->ll_name,
|
imported_T *import = find_imported(lp->ll_name, p - lp->ll_name,
|
||||||
TRUE, NULL);
|
TRUE, NULL);
|
||||||
|
|||||||
@@ -3830,14 +3830,7 @@ f_exists(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
else if (*p == '*') // internal or user defined function
|
else if (*p == '*') // internal or user defined function
|
||||||
{
|
{
|
||||||
int save_version = current_sctx.sc_version;
|
|
||||||
|
|
||||||
// Vim9 script assumes a function is script-local, but here we want to
|
|
||||||
// find any matching function.
|
|
||||||
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9)
|
|
||||||
current_sctx.sc_version = SCRIPT_VERSION_MAX;
|
|
||||||
n = function_exists(p + 1, FALSE);
|
n = function_exists(p + 1, FALSE);
|
||||||
current_sctx.sc_version = save_version;
|
|
||||||
}
|
}
|
||||||
else if (*p == '?') // internal function only
|
else if (*p == '?') // internal function only
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
" Tests for the Blob types
|
" Tests for the Blob types
|
||||||
|
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func TearDown()
|
func TearDown()
|
||||||
" Run garbage collection after every test
|
" 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(0, len(test_null_blob()))
|
||||||
call assert_equal(0z, copy(test_null_blob()))
|
call assert_equal(0z, copy(test_null_blob()))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" assignment to a blob
|
" assignment to a blob
|
||||||
@@ -75,49 +75,49 @@ func Test_blob_assign()
|
|||||||
VAR m = deepcopy(l)
|
VAR m = deepcopy(l)
|
||||||
LET m[0] = 0z34 #" E742 or E741 should not occur.
|
LET m[0] = 0z34 #" E742 or E741 should not occur.
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
LET b[2 : 3] = 0z112233
|
LET b[2 : 3] = 0z112233
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E972:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E972:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
LET b[2 : 3] = 0z11
|
LET b[2 : 3] = 0z11
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E972:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E972:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
LET b[3 : 2] = 0z
|
LET b[3 : 2] = 0z
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
LET b ..= 0z33
|
LET b ..= 0z33
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
LET b ..= "xx"
|
LET b ..= "xx"
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1019:', 'E734:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
LET b += "xx"
|
LET b += "xx"
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
LET b[1 : 1] ..= 0z55
|
LET b[1 : 1] ..= 0z55
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1183:', 'E734:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_get_range()
|
func Test_blob_get_range()
|
||||||
@@ -133,7 +133,7 @@ func Test_blob_get_range()
|
|||||||
call assert_equal(0z, b[5 : 6])
|
call assert_equal(0z, b[5 : 6])
|
||||||
call assert_equal(0z0011, b[-10 : 1])
|
call assert_equal(0z0011, b[-10 : 1])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" legacy script white space
|
" legacy script white space
|
||||||
let b = 0z0011223344
|
let b = 0z0011223344
|
||||||
@@ -158,19 +158,19 @@ func Test_blob_get()
|
|||||||
call assert_equal(0x44, b[4])
|
call assert_equal(0x44, b[4])
|
||||||
call assert_equal(0x44, b[-1])
|
call assert_equal(0x44, b[-1])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0z0011223344
|
VAR b = 0z0011223344
|
||||||
echo b[5]
|
echo b[5]
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0z0011223344
|
VAR b = 0z0011223344
|
||||||
echo b[-8]
|
echo b[-8]
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_to_string()
|
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(b))
|
||||||
call assert_equal('0z', string(test_null_blob()))
|
call assert_equal('0z', string(test_null_blob()))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_compare()
|
func Test_blob_compare()
|
||||||
@@ -211,54 +211,54 @@ func Test_blob_compare()
|
|||||||
call assert_false(b1 is b2)
|
call assert_false(b1 is b2)
|
||||||
call assert_true(b1 isnot b2)
|
call assert_true(b1 isnot b2)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b1 = 0z0011
|
VAR b1 = 0z0011
|
||||||
echo b1 == 9
|
echo b1 == 9
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b1 = 0z0011
|
VAR b1 = 0z0011
|
||||||
echo b1 != 9
|
echo b1 != 9
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E977:', 'E1072', 'E1072'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b1 = 0z0011
|
VAR b1 = 0z0011
|
||||||
VAR b2 = 0z1100
|
VAR b2 = 0z1100
|
||||||
VAR x = b1 > b2
|
VAR x = b1 > b2
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b1 = 0z0011
|
VAR b1 = 0z0011
|
||||||
VAR b2 = 0z1100
|
VAR b2 = 0z1100
|
||||||
VAR x = b1 < b2
|
VAR x = b1 < b2
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E978:', 'E1072:', 'E1072:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b1 = 0z0011
|
VAR b1 = 0z0011
|
||||||
VAR b2 = 0z1100
|
VAR b2 = 0z1100
|
||||||
VAR x = b1 - b2
|
VAR x = b1 - b2
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b1 = 0z0011
|
VAR b1 = 0z0011
|
||||||
VAR b2 = 0z1100
|
VAR b2 = 0z1100
|
||||||
VAR x = b1 / b2
|
VAR x = b1 / b2
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b1 = 0z0011
|
VAR b1 = 0z0011
|
||||||
VAR b2 = 0z1100
|
VAR b2 = 0z1100
|
||||||
VAR x = b1 * b2
|
VAR x = b1 * b2
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E974:', 'E1036:', 'E974:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_index_assign()
|
func Test_blob_index_assign()
|
||||||
@@ -268,19 +268,19 @@ func Test_blob_index_assign()
|
|||||||
LET b[2] = 0x22
|
LET b[2] = 0x22
|
||||||
call assert_equal(0z001122, b)
|
call assert_equal(0z001122, b)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0z00
|
VAR b = 0z00
|
||||||
LET b[2] = 0x33
|
LET b[2] = 0x33
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0z00
|
VAR b = 0z00
|
||||||
LET b[-2] = 0x33
|
LET b[-2] = 0x33
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_for_loop()
|
func Test_blob_for_loop()
|
||||||
@@ -313,7 +313,7 @@ func Test_blob_for_loop()
|
|||||||
endfor
|
endfor
|
||||||
call assert_equal(5, i)
|
call assert_equal(5, i)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_concatenate()
|
func Test_blob_concatenate()
|
||||||
@@ -325,19 +325,19 @@ func Test_blob_concatenate()
|
|||||||
LET b = 0zDEAD + 0zBEEF
|
LET b = 0zDEAD + 0zBEEF
|
||||||
call assert_equal(0zDEADBEEF, b)
|
call assert_equal(0zDEADBEEF, b)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0z0011
|
VAR b = 0z0011
|
||||||
LET b += "a"
|
LET b += "a"
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0z0011
|
VAR b = 0z0011
|
||||||
LET b += 88
|
LET b += 88
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E734:', 'E1012:', 'E734:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_add()
|
func Test_blob_add()
|
||||||
@@ -346,7 +346,7 @@ func Test_blob_add()
|
|||||||
call add(b, 0x22)
|
call add(b, 0x22)
|
||||||
call assert_equal(0z001122, b)
|
call assert_equal(0z001122, b)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Only works in legacy script
|
" Only works in legacy script
|
||||||
let b = 0z0011
|
let b = 0z0011
|
||||||
@@ -358,18 +358,18 @@ func Test_blob_add()
|
|||||||
VAR b = 0z0011
|
VAR b = 0z0011
|
||||||
call add(b, [9])
|
call add(b, [9])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E1210:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1012:', 'E1210:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0z0011
|
VAR b = 0z0011
|
||||||
call add("", 0x01)
|
call add("", 0x01)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E897:', 'E1013:', 'E1226:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E897:', 'E1013:', 'E1226:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
add(test_null_blob(), 0x22)
|
add(test_null_blob(), 0x22)
|
||||||
END
|
END
|
||||||
call CheckDefExecAndScriptFailure(lines, 'E1131:')
|
call v9.CheckDefExecAndScriptFailure(lines, 'E1131:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
let b = 0zDEADBEEF
|
let b = 0zDEADBEEF
|
||||||
@@ -377,7 +377,7 @@ func Test_blob_add()
|
|||||||
call add(b, 0)
|
call add(b, 0)
|
||||||
unlockvar b
|
unlockvar b
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_empty()
|
func Test_blob_empty()
|
||||||
@@ -411,32 +411,32 @@ func Test_blob_func_remove()
|
|||||||
call assert_equal(0zADBE, remove(b, 1, 2))
|
call assert_equal(0zADBE, remove(b, 1, 2))
|
||||||
call assert_equal(0zDEEF, b)
|
call assert_equal(0zDEEF, b)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test invalid cases
|
" Test invalid cases
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call remove(b, 5)
|
call remove(b, 5)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call remove(b, 1, 5)
|
call remove(b, 1, 5)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call remove(b, 3, 2)
|
call remove(b, 3, 2)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call remove(test_null_blob(), 1, 2)
|
call remove(test_null_blob(), 1, 2)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E979:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E979:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
let b = 0zDEADBEEF
|
let b = 0zDEADBEEF
|
||||||
@@ -444,7 +444,7 @@ func Test_blob_func_remove()
|
|||||||
call remove(b, 0)
|
call remove(b, 0)
|
||||||
unlockvar b
|
unlockvar b
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
|
|
||||||
" can only check at script level, not in a :def function
|
" can only check at script level, not in a :def function
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -453,7 +453,7 @@ func Test_blob_func_remove()
|
|||||||
lockvar b
|
lockvar b
|
||||||
remove(b, 0)
|
remove(b, 0)
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
|
|
||||||
call assert_fails('echo remove(0z1020, [])', 'E745:')
|
call assert_fails('echo remove(0z1020, [])', 'E745:')
|
||||||
call assert_fails('echo remove(0z1020, 0, [])', 'E745:')
|
call assert_fails('echo remove(0z1020, 0, [])', 'E745:')
|
||||||
@@ -467,7 +467,7 @@ func Test_blob_read_write()
|
|||||||
call assert_equal(b, br)
|
call assert_equal(b, br)
|
||||||
call delete('Xblob')
|
call delete('Xblob')
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" This was crashing when calling readfile() with a directory.
|
" This was crashing when calling readfile() with a directory.
|
||||||
call assert_fails("call readfile('.', 'B')", 'E17: "." is 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(0z01030103, filter(0z010203010203, 'v:val != 0x02'))
|
||||||
call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2'))
|
call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2'))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
call assert_fails('echo filter(0z10, "a10")', 'E121:')
|
call assert_fails('echo filter(0z10, "a10")', 'E121:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -496,12 +496,12 @@ func Test_blob_map()
|
|||||||
call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key'))
|
call assert_equal(0z00010203, map(0zDEADBEEF, 'v:key'))
|
||||||
call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val'))
|
call assert_equal(0zDEAEC0F2, map(0zDEADBEEF, 'v:key + v:val'))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
call map(0z00, '[9]')
|
call map(0z00, '[9]')
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E978:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E978:')
|
||||||
call assert_fails('echo map(0z10, "a10")', 'E121:')
|
call assert_fails('echo map(0z10, "a10")', 'E121:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -516,7 +516,7 @@ func Test_blob_index()
|
|||||||
call assert_equal(0, index(0z11110111, 0x11, -10))
|
call assert_equal(0, index(0z11110111, 0x11, -10))
|
||||||
call assert_equal(-1, index(test_null_blob(), 1))
|
call assert_equal(-1, index(test_null_blob(), 1))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_insert()
|
func Test_blob_insert()
|
||||||
@@ -529,7 +529,7 @@ func Test_blob_insert()
|
|||||||
call insert(b, 0x33, 2)
|
call insert(b, 0x33, 2)
|
||||||
call assert_equal(0zDEAD33BEEF, b)
|
call assert_equal(0zDEAD33BEEF, b)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" only works in legacy script
|
" only works in legacy script
|
||||||
call assert_equal(0, insert(test_null_blob(), 0x33))
|
call assert_equal(0, insert(test_null_blob(), 0x33))
|
||||||
@@ -538,42 +538,42 @@ func Test_blob_insert()
|
|||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call insert(b, -1)
|
call insert(b, -1)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E475:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E475:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call insert(b, 257)
|
call insert(b, 257)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E475:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E475:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call insert(b, 0, [9])
|
call insert(b, 0, [9])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call insert(b, 0, -20)
|
call insert(b, 0, -20)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E475:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E475:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call insert(b, 0, 20)
|
call insert(b, 0, 20)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E475:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E475:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR b = 0zDEADBEEF
|
VAR b = 0zDEADBEEF
|
||||||
call insert(b, [])
|
call insert(b, [])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:'])
|
call v9.CheckLegacyAndVim9Failure(lines, ['E745:', 'E1013:', 'E1210:'])
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
insert(test_null_blob(), 0x33)
|
insert(test_null_blob(), 0x33)
|
||||||
END
|
END
|
||||||
call CheckDefExecAndScriptFailure(lines, 'E1131:')
|
call v9.CheckDefExecAndScriptFailure(lines, 'E1131:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
let b = 0zDEADBEEF
|
let b = 0zDEADBEEF
|
||||||
@@ -581,7 +581,7 @@ func Test_blob_insert()
|
|||||||
call insert(b, 3)
|
call insert(b, 3)
|
||||||
unlockvar b
|
unlockvar b
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -589,7 +589,7 @@ func Test_blob_insert()
|
|||||||
lockvar b
|
lockvar b
|
||||||
insert(b, 3)
|
insert(b, 3)
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_reverse()
|
func Test_blob_reverse()
|
||||||
@@ -600,7 +600,7 @@ func Test_blob_reverse()
|
|||||||
call assert_equal(0zDE, reverse(0zDE))
|
call assert_equal(0zDE, reverse(0zDE))
|
||||||
call assert_equal(0z, reverse(test_null_blob()))
|
call assert_equal(0z, reverse(test_null_blob()))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_json_encode()
|
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('[222,173,190,239]', json_encode(0zDEADBEEF))
|
||||||
call assert_equal('[]', json_encode(0z))
|
call assert_equal('[]', json_encode(0z))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_lock()
|
func Test_blob_lock()
|
||||||
@@ -618,7 +618,7 @@ func Test_blob_lock()
|
|||||||
unlockvar b
|
unlockvar b
|
||||||
let b = 0z44
|
let b = 0z44
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -627,14 +627,14 @@ func Test_blob_lock()
|
|||||||
unlockvar b
|
unlockvar b
|
||||||
b = 0z44
|
b = 0z44
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
let b = 0z112233
|
let b = 0z112233
|
||||||
lockvar b
|
lockvar b
|
||||||
let b = 0z44
|
let b = 0z44
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -642,14 +642,14 @@ func Test_blob_lock()
|
|||||||
lockvar b
|
lockvar b
|
||||||
b = 0z44
|
b = 0z44
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_blob_sort()
|
func Test_blob_sort()
|
||||||
if has('float')
|
if has('float')
|
||||||
call CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:')
|
call v9.CheckLegacyAndVim9Failure(['call sort([1.0, 0z11], "f")'], 'E975:')
|
||||||
endif
|
endif
|
||||||
call CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:')
|
call v9.CheckLegacyAndVim9Failure(['call sort([11, 0z11], "N")'], 'E974:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Tests for the blob2list() function
|
" Tests for the blob2list() function
|
||||||
|
|||||||
@@ -360,16 +360,16 @@ def Test_Debugger_breakadd_expr()
|
|||||||
writefile(lines, 'Xtest.vim')
|
writefile(lines, 'Xtest.vim')
|
||||||
|
|
||||||
# Start Vim in a terminal
|
# Start Vim in a terminal
|
||||||
var buf = RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0})
|
var buf = g:RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0})
|
||||||
call TermWait(buf)
|
call g:TermWait(buf)
|
||||||
|
|
||||||
# Despite the failure the functions are defined
|
# Despite the failure the functions are defined
|
||||||
RunDbgCmd(buf, ':function g:EarlyFunc',
|
g:RunDbgCmd(buf, ':function g:EarlyFunc',
|
||||||
['function EarlyFunc()', 'endfunction'], {match: 'pattern'})
|
['function EarlyFunc()', 'endfunction'], {match: 'pattern'})
|
||||||
RunDbgCmd(buf, ':function g:LaterFunc',
|
g:RunDbgCmd(buf, ':function g:LaterFunc',
|
||||||
['function LaterFunc()', 'endfunction'], {match: 'pattern'})
|
['function LaterFunc()', 'endfunction'], {match: 'pattern'})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call g:StopVimInTerminal(buf)
|
||||||
call delete('Xtest.vim')
|
call delete('Xtest.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
@@ -386,13 +386,13 @@ def Test_Debugger_break_at_return()
|
|||||||
writefile(lines, 'Xtest.vim')
|
writefile(lines, 'Xtest.vim')
|
||||||
|
|
||||||
# Start Vim in a terminal
|
# Start Vim in a terminal
|
||||||
var buf = RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0})
|
var buf = g:RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0})
|
||||||
call TermWait(buf)
|
call g:TermWait(buf)
|
||||||
|
|
||||||
RunDbgCmd(buf, ':call GetNum()',
|
g:RunDbgCmd(buf, ':call GetNum()',
|
||||||
['line 1: return 1 + 2 + 3'], {match: 'pattern'})
|
['line 1: return 1 + 2 + 3'], {match: 'pattern'})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call g:StopVimInTerminal(buf)
|
||||||
call delete('Xtest.vim')
|
call delete('Xtest.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
source view_util.vim
|
source view_util.vim
|
||||||
source check.vim
|
source check.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
source term_util.vim
|
source term_util.vim
|
||||||
|
|
||||||
func NestedEval()
|
func NestedEval()
|
||||||
@@ -41,7 +41,7 @@ func Test_execute_string()
|
|||||||
if has('float')
|
if has('float')
|
||||||
call assert_fails('call execute(3.4)', 'E492:')
|
call assert_fails('call execute(3.4)', 'E492:')
|
||||||
call assert_equal("\nx", execute("echo \"x\"", 3.4))
|
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
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
" Tests for expressions.
|
" Tests for expressions.
|
||||||
|
|
||||||
source check.vim
|
source check.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func Test_equal()
|
func Test_equal()
|
||||||
let base = {}
|
let base = {}
|
||||||
@@ -51,12 +51,12 @@ func Test_op_trinary()
|
|||||||
call assert_fails('echo [1] ? "yes" : "no"', 'E745:')
|
call assert_fails('echo [1] ? "yes" : "no"', 'E745:')
|
||||||
call assert_fails('echo {} ? "yes" : "no"', 'E728:')
|
call assert_fails('echo {} ? "yes" : "no"', 'E728:')
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call assert_equal('no', 'x' ? 'yes' : 'no')
|
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 assert_equal('yes', '1x' ? 'yes' : 'no')
|
||||||
call CheckDefAndScriptFailure(["'1x' ? 'yes' : 'no'"], 'E1135:')
|
call v9.CheckDefAndScriptFailure(["'1x' ? 'yes' : 'no'"], 'E1135:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_op_falsy()
|
func Test_op_falsy()
|
||||||
@@ -81,7 +81,7 @@ func Test_op_falsy()
|
|||||||
call assert_equal(456, 0.0 ?? 456)
|
call assert_equal(456, 0.0 ?? 456)
|
||||||
endif
|
endif
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_dict()
|
func Test_dict()
|
||||||
@@ -101,9 +101,9 @@ func Test_dict()
|
|||||||
LET d[ 'b' ] = 'bbb'
|
LET d[ 'b' ] = 'bbb'
|
||||||
call assert_equal('bbb', d[ 'b' ])
|
call assert_equal('bbb', d[ 'b' ])
|
||||||
END
|
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
|
endfunc
|
||||||
|
|
||||||
func Test_strgetchar()
|
func Test_strgetchar()
|
||||||
@@ -116,10 +116,10 @@ func Test_strgetchar()
|
|||||||
call assert_equal(-1, strgetchar('axb', 3))
|
call assert_equal(-1, strgetchar('axb', 3))
|
||||||
call assert_equal(-1, strgetchar('', 0))
|
call assert_equal(-1, strgetchar('', 0))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call CheckLegacyAndVim9Failure(["VAR c = strgetchar([], 1)"], ['E730:', 'E1013:', 'E1174:'])
|
call v9.CheckLegacyAndVim9Failure(["VAR c = strgetchar([], 1)"], ['E730:', 'E1013:', 'E1174:'])
|
||||||
call CheckLegacyAndVim9Failure(["VAR c = strgetchar('axb', [])"], ['E745:', 'E1013:', 'E1210:'])
|
call v9.CheckLegacyAndVim9Failure(["VAR c = strgetchar('axb', [])"], ['E745:', 'E1013:', 'E1210:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_strcharpart()
|
func Test_strcharpart()
|
||||||
@@ -138,7 +138,7 @@ func Test_strcharpart()
|
|||||||
|
|
||||||
call assert_equal('edit', "editor"[-10 : 3])
|
call assert_equal('edit', "editor"[-10 : 3])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_getreg_empty_list()
|
func Test_getreg_empty_list()
|
||||||
@@ -150,9 +150,9 @@ func Test_getreg_empty_list()
|
|||||||
call add(x, 'foo')
|
call add(x, 'foo')
|
||||||
call assert_equal(['foo'], y)
|
call assert_equal(['foo'], y)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call CheckLegacyAndVim9Failure(['call getreg([])'], ['E730:', 'E1013:', 'E1174:'])
|
call v9.CheckLegacyAndVim9Failure(['call getreg([])'], ['E730:', 'E1013:', 'E1174:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_loop_over_null_list()
|
func Test_loop_over_null_list()
|
||||||
@@ -162,19 +162,19 @@ func Test_loop_over_null_list()
|
|||||||
call assert_report('should not get here')
|
call assert_report('should not get here')
|
||||||
endfor
|
endfor
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_setreg_null_list()
|
func Test_setreg_null_list()
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
call setreg('x', test_null_list())
|
call setreg('x', test_null_list())
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_special_char()
|
func Test_special_char()
|
||||||
" The failure is only visible using valgrind.
|
" The failure is only visible using valgrind.
|
||||||
call CheckLegacyAndVim9Failure(['echo "\<C-">'], ['E15:', 'E1004:', 'E1004:'])
|
call v9.CheckLegacyAndVim9Failure(['echo "\<C-">'], ['E15:', 'E1004:', 'E1004:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_method_with_prefix()
|
func Test_method_with_prefix()
|
||||||
@@ -182,13 +182,13 @@ func Test_method_with_prefix()
|
|||||||
call assert_equal(TRUE, !range(5)->empty())
|
call assert_equal(TRUE, !range(5)->empty())
|
||||||
call assert_equal(FALSE, !-3)
|
call assert_equal(FALSE, !-3)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call assert_equal([0, 1, 2], --3->range())
|
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 assert_equal(1, !+-+0)
|
||||||
call CheckDefAndScriptFailure(['eval !+-+0'], 'E15')
|
call v9.CheckDefAndScriptFailure(['eval !+-+0'], 'E15')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_option_value()
|
func Test_option_value()
|
||||||
@@ -214,7 +214,7 @@ func Test_option_value()
|
|||||||
call assert_equal("abcdefgi", &cpo)
|
call assert_equal("abcdefgi", &cpo)
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_printf_misc()
|
func Test_printf_misc()
|
||||||
@@ -407,9 +407,9 @@ func Test_printf_misc()
|
|||||||
call assert_equal('1%', printf('%d%%', 1))
|
call assert_equal('1%', printf('%d%%', 1))
|
||||||
call assert_notequal('', printf('%p', "abc"))
|
call assert_notequal('', printf('%p', "abc"))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:")
|
call v9.CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:")
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_printf_float()
|
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))
|
||||||
call assert_equal('nan', printf('%S', -0.0 / 0.0))
|
call assert_equal('nan', printf('%S', -0.0 / 0.0))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:')
|
call v9.CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:')
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_printf_errors()
|
func Test_printf_errors()
|
||||||
call CheckLegacyAndVim9Failure(['echo printf("%d", {})'], 'E728:')
|
call v9.CheckLegacyAndVim9Failure(['echo printf("%d", {})'], 'E728:')
|
||||||
call CheckLegacyAndVim9Failure(['echo printf("%d", [])'], 'E745:')
|
call v9.CheckLegacyAndVim9Failure(['echo printf("%d", [])'], 'E745:')
|
||||||
call CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:')
|
call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:')
|
||||||
call CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:')
|
call v9.CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:')
|
||||||
call CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:')
|
call v9.CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:')
|
||||||
if has('float')
|
if has('float')
|
||||||
call CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:')
|
call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:')
|
||||||
call CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:')
|
call v9.CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:')
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -541,7 +541,7 @@ func Test_printf_64bit()
|
|||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
call assert_equal("123456789012345", printf('%d', 123456789012345))
|
call assert_equal("123456789012345", printf('%d', 123456789012345))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_printf_spec_s()
|
func Test_printf_spec_s()
|
||||||
@@ -571,7 +571,7 @@ func Test_printf_spec_s()
|
|||||||
#" partial
|
#" partial
|
||||||
call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s'])))
|
call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s'])))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_printf_spec_b()
|
func Test_printf_spec_b()
|
||||||
@@ -587,14 +587,14 @@ func Test_printf_spec_b()
|
|||||||
call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345))
|
call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345))
|
||||||
call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1))
|
call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_max_min_errors()
|
func Test_max_min_errors()
|
||||||
call CheckLegacyAndVim9Failure(['call max(v:true)'], ['E712:', 'E1013:', 'E1227:'])
|
call v9.CheckLegacyAndVim9Failure(['call max(v:true)'], ['E712:', 'E1013:', 'E1227:'])
|
||||||
call CheckLegacyAndVim9Failure(['call max(v:true)'], ['max()', 'E1013:', 'E1227:'])
|
call v9.CheckLegacyAndVim9Failure(['call max(v:true)'], ['max()', 'E1013:', 'E1227:'])
|
||||||
call CheckLegacyAndVim9Failure(['call min(v:true)'], ['E712:', 'E1013:', 'E1227:'])
|
call v9.CheckLegacyAndVim9Failure(['call min(v:true)'], ['E712:', 'E1013:', 'E1227:'])
|
||||||
call CheckLegacyAndVim9Failure(['call min(v:true)'], ['min()', 'E1013:', 'E1227:'])
|
call v9.CheckLegacyAndVim9Failure(['call min(v:true)'], ['min()', 'E1013:', 'E1227:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_function_with_funcref()
|
func Test_function_with_funcref()
|
||||||
@@ -615,9 +615,9 @@ func Test_function_with_funcref()
|
|||||||
call execute('VAR Ref = ' .. name)
|
call execute('VAR Ref = ' .. name)
|
||||||
call assert_equal(4, Ref('text'))
|
call assert_equal(4, Ref('text'))
|
||||||
END
|
END
|
||||||
call CheckTransLegacySuccess(lines)
|
call v9.CheckTransLegacySuccess(lines)
|
||||||
" cannot create s: variable in :def function
|
" cannot create s: variable in :def function
|
||||||
call CheckTransVim9Success(lines)
|
call v9.CheckTransVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_funcref()
|
func Test_funcref()
|
||||||
@@ -668,9 +668,9 @@ func Test_setmatches()
|
|||||||
eval set->setmatches()
|
eval set->setmatches()
|
||||||
call assert_equal(exp, getmatches())
|
call assert_equal(exp, getmatches())
|
||||||
END
|
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
|
endfunc
|
||||||
|
|
||||||
func Test_empty_concatenate()
|
func Test_empty_concatenate()
|
||||||
@@ -678,19 +678,19 @@ func Test_empty_concatenate()
|
|||||||
call assert_equal('b', 'a'[4 : 0] .. 'b')
|
call assert_equal('b', 'a'[4 : 0] .. 'b')
|
||||||
call assert_equal('b', 'b' .. 'a'[4 : 0])
|
call assert_equal('b', 'b' .. 'a'[4 : 0])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_broken_number()
|
func Test_broken_number()
|
||||||
call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 1X'], 'E15:')
|
call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 1X'], 'E15:')
|
||||||
call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0b1X'], 'E15:')
|
call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0b1X'], 'E15:')
|
||||||
call CheckLegacyAndVim9Failure(['echo 0b12'], 'E15:')
|
call v9.CheckLegacyAndVim9Failure(['echo 0b12'], 'E15:')
|
||||||
call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0x1X'], 'E15:')
|
call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0x1X'], 'E15:')
|
||||||
call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 011X'], '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 <Char-0b1z> b'], 'E474:')
|
call v9.CheckLegacyAndVim9Failure(['inoremap <Char-0b1z> b'], 'E474:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_eval_after_if()
|
func Test_eval_after_if()
|
||||||
@@ -783,11 +783,11 @@ endfunc
|
|||||||
|
|
||||||
" Test for errors in expression evaluation
|
" Test for errors in expression evaluation
|
||||||
func Test_expr_eval_error()
|
func Test_expr_eval_error()
|
||||||
call CheckLegacyAndVim9Failure(["VAR i = 'abc' .. []"], ['E730:', 'E1105:', 'E730:'])
|
call v9.CheckLegacyAndVim9Failure(["VAR i = 'abc' .. []"], ['E730:', 'E1105:', 'E730:'])
|
||||||
call CheckLegacyAndVim9Failure(["VAR l = [] + 10"], ['E745:', 'E1051:', 'E745'])
|
call v9.CheckLegacyAndVim9Failure(["VAR l = [] + 10"], ['E745:', 'E1051:', 'E745'])
|
||||||
call CheckLegacyAndVim9Failure(["VAR v = 10 + []"], ['E745:', 'E1051:', 'E745:'])
|
call v9.CheckLegacyAndVim9Failure(["VAR v = 10 + []"], ['E745:', 'E1051:', 'E745:'])
|
||||||
call CheckLegacyAndVim9Failure(["VAR v = 10 / []"], ['E745:', 'E1036:', 'E745:'])
|
call v9.CheckLegacyAndVim9Failure(["VAR v = 10 / []"], ['E745:', 'E1036:', 'E745:'])
|
||||||
call CheckLegacyAndVim9Failure(["VAR v = -{}"], ['E728:', 'E1012:', 'E728:'])
|
call v9.CheckLegacyAndVim9Failure(["VAR v = -{}"], ['E728:', 'E1012:', 'E728:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_white_in_function_call()
|
func Test_white_in_function_call()
|
||||||
@@ -795,13 +795,13 @@ func Test_white_in_function_call()
|
|||||||
VAR text = substitute ( 'some text' , 't' , 'T' , 'g' )
|
VAR text = substitute ( 'some text' , 't' , 'T' , 'g' )
|
||||||
call assert_equal('some TexT', text)
|
call assert_equal('some TexT', text)
|
||||||
END
|
END
|
||||||
call CheckTransLegacySuccess(lines)
|
call v9.CheckTransLegacySuccess(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
var text = substitute ( 'some text' , 't' , 'T' , 'g' )
|
var text = substitute ( 'some text' , 't' , 'T' , 'g' )
|
||||||
call assert_equal('some TexT', text)
|
call assert_equal('some TexT', text)
|
||||||
END
|
END
|
||||||
call CheckDefAndScriptFailure(lines, ['E1001:', 'E121:'])
|
call v9.CheckDefAndScriptFailure(lines, ['E1001:', 'E121:'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for float value comparison
|
" Test for float value comparison
|
||||||
@@ -825,7 +825,7 @@ func Test_float_compare()
|
|||||||
#" +infinity != -infinity
|
#" +infinity != -infinity
|
||||||
call assert_true((1.0 / 0) != -(2.0 / 0))
|
call assert_true((1.0 / 0) != -(2.0 / 0))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
" Test filter() and map()
|
" Test filter() and map()
|
||||||
|
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
" list with expression string
|
" list with expression string
|
||||||
func Test_filter_map_list_expr_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('', "v:val == 'a'"))
|
||||||
call assert_equal('', filter(test_null_string(), "v:val == 'a'"))
|
call assert_equal('', filter(test_null_string(), "v:val == 'a'"))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" map()
|
" map()
|
||||||
let lines =<< trim END
|
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", "10")', 'E928:')
|
||||||
call assert_fails('echo map("abc", "a10")', 'E121:')
|
call assert_fails('echo map("abc", "a10")', 'E121:')
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" mapnew()
|
" mapnew()
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -202,7 +202,7 @@ func Test_filter_map_string()
|
|||||||
call assert_equal('', mapnew('', "v:val == 'a'"))
|
call assert_equal('', mapnew('', "v:val == 'a'"))
|
||||||
call assert_equal('', mapnew(test_null_string(), "v:val == 'a'"))
|
call assert_equal('', mapnew(test_null_string(), "v:val == 'a'"))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
#" map() and filter()
|
#" 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(0xc5) .. '\%C' ? '@' : x LEND))
|
||||||
call assert_equal('Åstr@m', map('Åström', LSTART i, x LMIDDLE x =~ nr2char(0xf6) .. '\%C' ? '@' : x LEND))
|
call assert_equal('Åstr@m', map('Åström', LSTART i, x LMIDDLE x =~ nr2char(0xf6) .. '\%C' ? '@' : x LEND))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
source check.vim
|
source check.vim
|
||||||
CheckFeature float
|
CheckFeature float
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func Test_abs()
|
func Test_abs()
|
||||||
call assert_equal('1.23', string(abs(1.23)))
|
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('123456.7', string(str2float("123'456.7'89", 1)))
|
||||||
|
|
||||||
call assert_equal(1.2, str2float(1.2, 0))
|
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([])", 'E730:')
|
||||||
call assert_fails("call str2float({})", 'E731:')
|
call assert_fails("call str2float({})", 'E731:')
|
||||||
call assert_fails("call str2float(function('string'))", 'E729:')
|
call assert_fails("call str2float(function('string'))", 'E729:')
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ source shared.vim
|
|||||||
source check.vim
|
source check.vim
|
||||||
source term_util.vim
|
source term_util.vim
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
" Must be done first, since the alternate buffer must be unset.
|
" Must be done first, since the alternate buffer must be unset.
|
||||||
func Test_00_bufexists()
|
func Test_00_bufexists()
|
||||||
@@ -174,7 +174,7 @@ func Test_strwidth()
|
|||||||
|
|
||||||
if has('float')
|
if has('float')
|
||||||
call assert_equal(3, strwidth(1.2))
|
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
|
endif
|
||||||
|
|
||||||
set ambiwidth&
|
set ambiwidth&
|
||||||
@@ -241,7 +241,7 @@ func Test_str2nr()
|
|||||||
call assert_fails('call str2nr({->2})', 'E729:')
|
call assert_fails('call str2nr({->2})', 'E729:')
|
||||||
if has('float')
|
if has('float')
|
||||||
call assert_equal(1, str2nr(1.2))
|
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
|
endif
|
||||||
call assert_fails('call str2nr(10, [])', 'E745:')
|
call assert_fails('call str2nr(10, [])', 'E745:')
|
||||||
endfunc
|
endfunc
|
||||||
@@ -503,7 +503,7 @@ func Test_simplify()
|
|||||||
call assert_fails('call simplify({})', 'E731:')
|
call assert_fails('call simplify({})', 'E731:')
|
||||||
if has('float')
|
if has('float')
|
||||||
call assert_equal('1.2', simplify(1.2))
|
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
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -2265,7 +2265,7 @@ func Test_call()
|
|||||||
let Time = 'localtime'
|
let Time = 'localtime'
|
||||||
call Time()
|
call Time()
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E1085:')
|
call v9.CheckScriptFailure(lines, 'E1085:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_char2nr()
|
func Test_char2nr()
|
||||||
@@ -2800,7 +2800,7 @@ func Test_builtin_check()
|
|||||||
vim9script
|
vim9script
|
||||||
var s:trim = (x) => " " .. x
|
var s:trim = (x) => " " .. x
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E704:')
|
call v9.CheckScriptFailure(lines, 'E704:')
|
||||||
|
|
||||||
call assert_fails('call extend(g:, #{foo: { -> "foo" }})', 'E704:')
|
call assert_fails('call extend(g:, #{foo: { -> "foo" }})', 'E704:')
|
||||||
let g:bar = 123
|
let g:bar = 123
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
" Test glob2regpat()
|
" Test glob2regpat()
|
||||||
|
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func Test_glob2regpat_invalid()
|
func Test_glob2regpat_invalid()
|
||||||
if has('float')
|
if has('float')
|
||||||
call assert_equal('^1\.33$', glob2regpat(1.33))
|
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
|
endif
|
||||||
call assert_fails('call glob2regpat("}")', 'E219:')
|
call assert_fails('call glob2regpat("}")', 'E219:')
|
||||||
call assert_fails('call glob2regpat("{")', 'E220:')
|
call assert_fails('call glob2regpat("{")', 'E220:')
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ source view_util.vim
|
|||||||
source screendump.vim
|
source screendump.vim
|
||||||
source check.vim
|
source check.vim
|
||||||
source script_util.vim
|
source script_util.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func ClearDict(d)
|
func ClearDict(d)
|
||||||
for k in keys(a: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(test_null_string()))
|
||||||
call assert_equal([], hlget(""))
|
call assert_equal([], hlget(""))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for resolving highlight group links
|
" Test for resolving highlight group links
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -1042,7 +1042,7 @@ func Test_hlget()
|
|||||||
call assert_equal([{'id': hlgCid, 'name': 'hlgC',
|
call assert_equal([{'id': hlgCid, 'name': 'hlgC',
|
||||||
\ 'term': {'bold': v:true}}], hlget('hlgC', v:true))
|
\ 'term': {'bold': v:true}}], hlget('hlgC', v:true))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call assert_fails('call hlget([])', 'E1174:')
|
call assert_fails('call hlget([])', 'E1174:')
|
||||||
call assert_fails('call hlget("abc", "xyz")', 'E1212:')
|
call assert_fails('call hlget("abc", "xyz")', 'E1212:')
|
||||||
@@ -1098,7 +1098,7 @@ func Test_hlset()
|
|||||||
call assert_equal('Search', hlget('NewHLGroup')[0].linksto)
|
call assert_equal('Search', hlget('NewHLGroup')[0].linksto)
|
||||||
highlight clear NewHLGroup
|
highlight clear NewHLGroup
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for clearing the 'term', 'cterm' and 'gui' attributes of a highlight
|
" Test for clearing the 'term', 'cterm' and 'gui' attributes of a highlight
|
||||||
" group.
|
" group.
|
||||||
@@ -1117,7 +1117,7 @@ func Test_hlset()
|
|||||||
\ hlget('myhlg1'))
|
\ hlget('myhlg1'))
|
||||||
highlight clear myhlg1
|
highlight clear myhlg1
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for setting all the 'term', 'cterm' and 'gui' attributes of a
|
" Test for setting all the 'term', 'cterm' and 'gui' attributes of a
|
||||||
" highlight group
|
" highlight group
|
||||||
@@ -1134,7 +1134,7 @@ func Test_hlset()
|
|||||||
call assert_equal([{'id': id2, 'name': 'myhlg2', 'gui': attr,
|
call assert_equal([{'id': id2, 'name': 'myhlg2', 'gui': attr,
|
||||||
\ 'term': attr, 'cterm': attr}], hlget('myhlg2'))
|
\ 'term': attr, 'cterm': attr}], hlget('myhlg2'))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for clearing some of the 'term', 'cterm' and 'gui' attributes of a
|
" Test for clearing some of the 'term', 'cterm' and 'gui' attributes of a
|
||||||
" highlight group
|
" highlight group
|
||||||
@@ -1150,7 +1150,7 @@ func Test_hlset()
|
|||||||
call assert_equal([{'id': id2, 'name': 'myhlg2', 'gui': attr,
|
call assert_equal([{'id': id2, 'name': 'myhlg2', 'gui': attr,
|
||||||
\ 'term': attr, 'cterm': attr}], hlget('myhlg2'))
|
\ 'term': attr, 'cterm': attr}], hlget('myhlg2'))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for clearing the attributes and link of a highlight group
|
" Test for clearing the attributes and link of a highlight group
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -1162,7 +1162,7 @@ func Test_hlset()
|
|||||||
\ hlget('myhlg3'))
|
\ hlget('myhlg3'))
|
||||||
highlight clear hlg3
|
highlight clear hlg3
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for setting default attributes for a highlight group
|
" Test for setting default attributes for a highlight group
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -1187,7 +1187,7 @@ func Test_hlset()
|
|||||||
\ hlget('hlg6'))
|
\ hlget('hlg6'))
|
||||||
highlight clear hlg6
|
highlight clear hlg6
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for setting default links for a highlight group
|
" Test for setting default links for a highlight group
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -1217,7 +1217,7 @@ func Test_hlset()
|
|||||||
\ 'linksto': 'ErrorMsg'}], hlget('hlg9dup'))
|
\ 'linksto': 'ErrorMsg'}], hlget('hlg9dup'))
|
||||||
highlight clear hlg9
|
highlight clear hlg9
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for force creating a link to a highlight group
|
" Test for force creating a link to a highlight group
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -1231,7 +1231,7 @@ func Test_hlset()
|
|||||||
\ 'linksto': 'Search'}], hlget('hlg10'))
|
\ 'linksto': 'Search'}], hlget('hlg10'))
|
||||||
highlight clear hlg10
|
highlight clear hlg10
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for empty values of attributes
|
" Test for empty values of attributes
|
||||||
call hlset([{'name': 'hlg11', 'cterm': {}}])
|
call hlset([{'name': 'hlg11', 'cterm': {}}])
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
source view_util.vim
|
source view_util.vim
|
||||||
source check.vim
|
source check.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
let s:imactivatefunc_called = 0
|
let s:imactivatefunc_called = 0
|
||||||
let s:imstatusfunc_called = 0
|
let s:imstatusfunc_called = 0
|
||||||
@@ -165,28 +165,28 @@ func Test_imactivatefunc_imstatusfunc_callback()
|
|||||||
normal! i
|
normal! i
|
||||||
|
|
||||||
#" Test for using a lambda function
|
#" 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')
|
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
||||||
exe "set imactivatefunc=" .. optval
|
exe "set imactivatefunc=" .. optval
|
||||||
LET optval = "LSTART LMIDDLE IMstatusfunc1() LEND"
|
LET optval = "LSTART LMIDDLE g:IMstatusfunc1() LEND"
|
||||||
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
||||||
exe "set imstatusfunc=" .. optval
|
exe "set imstatusfunc=" .. optval
|
||||||
normal! i
|
normal! i
|
||||||
|
|
||||||
#" Set 'imactivatefunc' and 'imstatusfunc' to a lambda expression
|
#" Set 'imactivatefunc' and 'imstatusfunc' to a lambda expression
|
||||||
LET &imactivatefunc = LSTART a LMIDDLE IMactivatefunc1(a) LEND
|
LET &imactivatefunc = LSTART a LMIDDLE g:IMactivatefunc1(a) LEND
|
||||||
LET &imstatusfunc = LSTART LMIDDLE IMstatusfunc1() LEND
|
LET &imstatusfunc = LSTART LMIDDLE g:IMstatusfunc1() LEND
|
||||||
normal! i
|
normal! i
|
||||||
|
|
||||||
#" Set 'imactivatefunc' and 'imstatusfunc' to a string(lambda expression)
|
#" Set 'imactivatefunc' and 'imstatusfunc' to a string(lambda expression)
|
||||||
LET &imactivatefunc = 'LSTART a LMIDDLE IMactivatefunc1(a) LEND'
|
LET &imactivatefunc = 'LSTART a LMIDDLE g:IMactivatefunc1(a) LEND'
|
||||||
LET &imstatusfunc = 'LSTART LMIDDLE IMstatusfunc1() LEND'
|
LET &imstatusfunc = 'LSTART LMIDDLE g:IMstatusfunc1() LEND'
|
||||||
normal! i
|
normal! i
|
||||||
|
|
||||||
#" Set 'imactivatefunc' 'imstatusfunc' to a variable with a lambda
|
#" Set 'imactivatefunc' 'imstatusfunc' to a variable with a lambda
|
||||||
#" expression
|
#" expression
|
||||||
VAR Lambda1 = LSTART a LMIDDLE IMactivatefunc1(a) LEND
|
VAR Lambda1 = LSTART a LMIDDLE g:IMactivatefunc1(a) LEND
|
||||||
VAR Lambda2 = LSTART LMIDDLE IMstatusfunc1() LEND
|
VAR Lambda2 = LSTART LMIDDLE g:IMstatusfunc1() LEND
|
||||||
LET &imactivatefunc = Lambda1
|
LET &imactivatefunc = Lambda1
|
||||||
LET &imstatusfunc = Lambda2
|
LET &imstatusfunc = Lambda2
|
||||||
normal! i
|
normal! i
|
||||||
@@ -223,7 +223,7 @@ func Test_imactivatefunc_imstatusfunc_callback()
|
|||||||
call assert_equal(14, g:IMactivatefunc_called)
|
call assert_equal(14, g:IMactivatefunc_called)
|
||||||
call assert_equal(28, g:IMstatusfunc_called)
|
call assert_equal(28, g:IMstatusfunc_called)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Using Vim9 lambda expression in legacy context should fail
|
" Using Vim9 lambda expression in legacy context should fail
|
||||||
set imactivatefunc=(a)\ =>\ IMactivatefunc1(a)
|
set imactivatefunc=(a)\ =>\ IMactivatefunc1(a)
|
||||||
@@ -285,7 +285,7 @@ func Test_imactivatefunc_imstatusfunc_callback()
|
|||||||
set imactivatefunc=
|
set imactivatefunc=
|
||||||
set imstatusfunc=
|
set imstatusfunc=
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
" cleanup
|
" cleanup
|
||||||
set iminsert=0
|
set iminsert=0
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
source check.vim
|
source check.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
" Test for insert expansion
|
" Test for insert expansion
|
||||||
func Test_ins_complete()
|
func Test_ins_complete()
|
||||||
@@ -1359,7 +1359,7 @@ func Test_completefunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Test for using a lambda function with set
|
#" 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')
|
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
||||||
exe "set completefunc=" .. optval
|
exe "set completefunc=" .. optval
|
||||||
new
|
new
|
||||||
@@ -1370,7 +1370,7 @@ func Test_completefunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'completefunc' to a lambda expression
|
#" 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
|
new
|
||||||
call setline(1, 'six')
|
call setline(1, 'six')
|
||||||
LET g:CompleteFunc1Args = []
|
LET g:CompleteFunc1Args = []
|
||||||
@@ -1379,7 +1379,7 @@ func Test_completefunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'completefunc' to string(lambda_expression)
|
#" 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
|
new
|
||||||
call setline(1, 'six')
|
call setline(1, 'six')
|
||||||
LET g:CompleteFunc1Args = []
|
LET g:CompleteFunc1Args = []
|
||||||
@@ -1388,7 +1388,7 @@ func Test_completefunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'completefunc' to a variable with a lambda expression
|
#" 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
|
LET &completefunc = Lambda
|
||||||
new
|
new
|
||||||
call setline(1, 'seven')
|
call setline(1, 'seven')
|
||||||
@@ -1398,7 +1398,7 @@ func Test_completefunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'completefunc' to a string(variable with a lambda expression)
|
#" 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)
|
LET &completefunc = string(Lambda)
|
||||||
new
|
new
|
||||||
call setline(1, 'seven')
|
call setline(1, 'seven')
|
||||||
@@ -1431,7 +1431,7 @@ func Test_completefunc_callback()
|
|||||||
call assert_equal([[1, ''], [0, 'five']], g:CompleteFunc2Args)
|
call assert_equal([[1, ''], [0, 'five']], g:CompleteFunc2Args)
|
||||||
bw!
|
bw!
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for using a script-local function name
|
" Test for using a script-local function name
|
||||||
func s:CompleteFunc3(findstart, base)
|
func s:CompleteFunc3(findstart, base)
|
||||||
@@ -1460,7 +1460,7 @@ func Test_completefunc_callback()
|
|||||||
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
|
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
|
||||||
|
|
||||||
" Using Vim9 lambda expression in legacy context should fail
|
" 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
|
new | only
|
||||||
let g:CompleteFunc1Args = []
|
let g:CompleteFunc1Args = []
|
||||||
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:')
|
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:')
|
||||||
@@ -1526,7 +1526,7 @@ func Test_completefunc_callback()
|
|||||||
assert_equal([[1, ''], [0, 'three']], g:LocalCompleteFuncArgs)
|
assert_equal([[1, ''], [0, 'three']], g:LocalCompleteFuncArgs)
|
||||||
bw!
|
bw!
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
" cleanup
|
" cleanup
|
||||||
set completefunc&
|
set completefunc&
|
||||||
@@ -1616,7 +1616,7 @@ func Test_omnifunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Test for using a lambda function with set
|
#" 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')
|
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
||||||
exe "set omnifunc=" .. optval
|
exe "set omnifunc=" .. optval
|
||||||
new
|
new
|
||||||
@@ -1627,7 +1627,7 @@ func Test_omnifunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'omnifunc' to a lambda expression
|
#" 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
|
new
|
||||||
call setline(1, 'six')
|
call setline(1, 'six')
|
||||||
LET g:OmniFunc1Args = []
|
LET g:OmniFunc1Args = []
|
||||||
@@ -1636,7 +1636,7 @@ func Test_omnifunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'omnifunc' to a string(lambda_expression)
|
#" 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
|
new
|
||||||
call setline(1, 'six')
|
call setline(1, 'six')
|
||||||
LET g:OmniFunc1Args = []
|
LET g:OmniFunc1Args = []
|
||||||
@@ -1645,7 +1645,7 @@ func Test_omnifunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'omnifunc' to a variable with a lambda expression
|
#" 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
|
LET &omnifunc = Lambda
|
||||||
new
|
new
|
||||||
call setline(1, 'seven')
|
call setline(1, 'seven')
|
||||||
@@ -1655,7 +1655,7 @@ func Test_omnifunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'omnifunc' to a string(variable with a lambda expression)
|
#" 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)
|
LET &omnifunc = string(Lambda)
|
||||||
new
|
new
|
||||||
call setline(1, 'seven')
|
call setline(1, 'seven')
|
||||||
@@ -1688,7 +1688,7 @@ func Test_omnifunc_callback()
|
|||||||
call assert_equal([[1, ''], [0, 'nine']], g:OmniFunc2Args)
|
call assert_equal([[1, ''], [0, 'nine']], g:OmniFunc2Args)
|
||||||
bw!
|
bw!
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for using a script-local function name
|
" Test for using a script-local function name
|
||||||
func s:OmniFunc3(findstart, base)
|
func s:OmniFunc3(findstart, base)
|
||||||
@@ -1783,7 +1783,7 @@ func Test_omnifunc_callback()
|
|||||||
assert_equal([[1, ''], [0, 'three']], g:LocalOmniFuncArgs)
|
assert_equal([[1, ''], [0, 'three']], g:LocalOmniFuncArgs)
|
||||||
bw!
|
bw!
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
" cleanup
|
" cleanup
|
||||||
set omnifunc&
|
set omnifunc&
|
||||||
@@ -1873,7 +1873,7 @@ func Test_thesaurusfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Test for using a lambda function
|
#" 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')
|
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
||||||
exe "set thesaurusfunc=" .. optval
|
exe "set thesaurusfunc=" .. optval
|
||||||
new
|
new
|
||||||
@@ -1884,7 +1884,7 @@ func Test_thesaurusfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Test for using a lambda function with set
|
#" 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
|
new
|
||||||
call setline(1, 'six')
|
call setline(1, 'six')
|
||||||
LET g:TsrFunc1Args = []
|
LET g:TsrFunc1Args = []
|
||||||
@@ -1893,7 +1893,7 @@ func Test_thesaurusfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'thesaurusfunc' to a string(lambda expression)
|
#" 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
|
new
|
||||||
call setline(1, 'six')
|
call setline(1, 'six')
|
||||||
LET g:TsrFunc1Args = []
|
LET g:TsrFunc1Args = []
|
||||||
@@ -1902,7 +1902,7 @@ func Test_thesaurusfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'thesaurusfunc' to a variable with a lambda expression
|
#" 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
|
LET &thesaurusfunc = Lambda
|
||||||
new
|
new
|
||||||
call setline(1, 'seven')
|
call setline(1, 'seven')
|
||||||
@@ -1912,7 +1912,7 @@ func Test_thesaurusfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'thesaurusfunc' to a string(variable with a lambda expression)
|
#" 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)
|
LET &thesaurusfunc = string(Lambda)
|
||||||
new
|
new
|
||||||
call setline(1, 'seven')
|
call setline(1, 'seven')
|
||||||
@@ -1968,7 +1968,7 @@ func Test_thesaurusfunc_callback()
|
|||||||
call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:TsrFunc1Args)
|
call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:TsrFunc1Args)
|
||||||
:%bw!
|
:%bw!
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for using a script-local function name
|
" Test for using a script-local function name
|
||||||
func s:TsrFunc3(findstart, base)
|
func s:TsrFunc3(findstart, base)
|
||||||
@@ -2076,7 +2076,7 @@ func Test_thesaurusfunc_callback()
|
|||||||
assert_equal([[1, ''], [0, 'three']], g:LocalTsrFuncArgs)
|
assert_equal([[1, ''], [0, 'three']], g:LocalTsrFuncArgs)
|
||||||
bw!
|
bw!
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
" cleanup
|
" cleanup
|
||||||
set thesaurusfunc&
|
set thesaurusfunc&
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
" Tests for the List and Dict types
|
" Tests for the List and Dict types
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func TearDown()
|
func TearDown()
|
||||||
" Run garbage collection after every test
|
" Run garbage collection after every test
|
||||||
@@ -50,7 +50,7 @@ func Test_list_slice()
|
|||||||
call assert_equal([2], l[-1 : -1])
|
call assert_equal([2], l[-1 : -1])
|
||||||
call assert_equal([1, 2], l[-2 : -1])
|
call assert_equal([1, 2], l[-2 : -1])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let l = [1, 2]
|
let l = [1, 2]
|
||||||
call assert_equal([], l[-3 : -1])
|
call assert_equal([], l[-3 : -1])
|
||||||
@@ -59,7 +59,7 @@ func Test_list_slice()
|
|||||||
var l = [1, 2]
|
var l = [1, 2]
|
||||||
assert_equal([1, 2], l[-3 : -1])
|
assert_equal([1, 2], l[-3 : -1])
|
||||||
END
|
END
|
||||||
call CheckDefAndScriptSuccess(lines)
|
call v9.CheckDefAndScriptSuccess(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" List identity
|
" List identity
|
||||||
@@ -75,7 +75,7 @@ func Test_list_identity()
|
|||||||
call assert_false(l is lx)
|
call assert_false(l is lx)
|
||||||
call assert_true(l isnot lx)
|
call assert_true(l isnot lx)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" removing items with :unlet
|
" removing items with :unlet
|
||||||
@@ -118,7 +118,7 @@ func Test_list_unlet()
|
|||||||
unlet l[-6 : 2]
|
unlet l[-6 : 2]
|
||||||
call assert_equal([3], l)
|
call assert_equal([3], l)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let l = [0, 1, 2, 3]
|
let l = [0, 1, 2, 3]
|
||||||
unlet l[2:2]
|
unlet l[2:2]
|
||||||
@@ -131,13 +131,13 @@ func Test_list_unlet()
|
|||||||
VAR l = [0, 1, 2, 3]
|
VAR l = [0, 1, 2, 3]
|
||||||
unlet l[2 : 1]
|
unlet l[2 : 1]
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E684:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E684:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR l = [0, 1, 2, 3]
|
VAR l = [0, 1, 2, 3]
|
||||||
unlet l[-1 : 2]
|
unlet l[-1 : 2]
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E684:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E684:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" assignment to a list
|
" assignment to a list
|
||||||
@@ -149,35 +149,35 @@ func Test_list_assign()
|
|||||||
LET [va, vb] = l[2 : 3]
|
LET [va, vb] = l[2 : 3]
|
||||||
call assert_equal([2, 3], [va, vb])
|
call assert_equal([2, 3], [va, vb])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
let l = [0, 1, 2, 3]
|
let l = [0, 1, 2, 3]
|
||||||
let [va, vb] = l
|
let [va, vb] = l
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E687:')
|
call v9.CheckScriptFailure(lines, 'E687:')
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
var l = [0, 1, 2, 3]
|
var l = [0, 1, 2, 3]
|
||||||
var va = 0
|
var va = 0
|
||||||
var vb = 0
|
var vb = 0
|
||||||
[va, vb] = l
|
[va, vb] = l
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(['vim9script'] + lines, 'E687:')
|
call v9.CheckScriptFailure(['vim9script'] + lines, 'E687:')
|
||||||
call CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 4')
|
call v9.CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 4')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
let l = [0, 1, 2, 3]
|
let l = [0, 1, 2, 3]
|
||||||
let [va, vb] = l[1:1]
|
let [va, vb] = l[1:1]
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E688:')
|
call v9.CheckScriptFailure(lines, 'E688:')
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
var l = [0, 1, 2, 3]
|
var l = [0, 1, 2, 3]
|
||||||
var va = 0
|
var va = 0
|
||||||
var vb = 0
|
var vb = 0
|
||||||
[va, vb] = l[1 : 1]
|
[va, vb] = l[1 : 1]
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(['vim9script'] + lines, 'E688:')
|
call v9.CheckScriptFailure(['vim9script'] + lines, 'E688:')
|
||||||
call CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 1')
|
call v9.CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 1')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" test for range assign
|
" test for range assign
|
||||||
@@ -189,13 +189,13 @@ func Test_list_range_assign()
|
|||||||
LET l[-4 : -1] = [5, 6]
|
LET l[-4 : -1] = [5, 6]
|
||||||
call assert_equal([5, 6], l)
|
call assert_equal([5, 6], l)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
var l = [7]
|
var l = [7]
|
||||||
l[:] = ['text']
|
l[:] = ['text']
|
||||||
END
|
END
|
||||||
call CheckDefAndScriptFailure(lines, 'E1012:', 2)
|
call v9.CheckDefAndScriptFailure(lines, 'E1012:', 2)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test removing items in list
|
" 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([2, 3], remove(l, -3, -2))
|
||||||
call assert_equal([1, 4], l)
|
call assert_equal([1, 4], l)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test invalid cases
|
" Test invalid cases
|
||||||
let l = [1, 2, 3, 4]
|
let l = [1, 2, 3, 4]
|
||||||
@@ -251,7 +251,7 @@ func Test_list_add()
|
|||||||
call add(l, test_null_dict())
|
call add(l, test_null_dict())
|
||||||
call assert_equal([1, [2, 3], [], [], {'k': 3}, {}, {}], l)
|
call assert_equal([1, [2, 3], [], [], {'k': 3}, {}, {}], l)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" weird legacy behavior
|
" weird legacy behavior
|
||||||
call assert_equal(1, add(test_null_list(), 4))
|
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 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)
|
call assert_equal({'c': 'ccc', '1': 99, 'b': [1, 2, function('strlen')], '3': 33, '-1': {'a': 1}}, d)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},}
|
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))
|
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_false(d is dx)
|
||||||
call assert_true(d isnot dx)
|
call assert_true(d isnot dx)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" removing items with :unlet
|
" removing items with :unlet
|
||||||
@@ -331,7 +331,7 @@ func Test_dict_unlet()
|
|||||||
unlet d[-1]
|
unlet d[-1]
|
||||||
call assert_equal({'1': 99, '3': 33}, d)
|
call assert_equal({'1': 99, '3': 33}, d)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" manipulating a big Dictionary (hashtable.c has a border of 1000 entries)
|
" manipulating a big Dictionary (hashtable.c has a border of 1000 entries)
|
||||||
@@ -405,24 +405,24 @@ func Test_dict_assign()
|
|||||||
LET d._ = 2
|
LET d._ = 2
|
||||||
call assert_equal({'a': 1, '_': 2}, d)
|
call assert_equal({'a': 1, '_': 2}, d)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
let n = 0
|
let n = 0
|
||||||
let n.key = 3
|
let n.key = 3
|
||||||
END
|
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
|
let lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
var n = 0
|
var n = 0
|
||||||
n.key = 3
|
n.key = 3
|
||||||
END
|
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
|
let lines =<< trim END
|
||||||
var n = 0
|
var n = 0
|
||||||
n.key = 3
|
n.key = 3
|
||||||
END
|
END
|
||||||
call CheckDefFailure(lines, 'E1141:')
|
call v9.CheckDefFailure(lines, 'E1141:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Function in script-local List or Dict
|
" 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('b', remove(d, 2))
|
||||||
call assert_equal({1: 'a', 3: 'c'}, d)
|
call assert_equal({1: 'a', 3: 'c'}, d)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR d = {1: 'a', 3: 'c'}
|
VAR d = {1: 'a', 3: 'c'}
|
||||||
call remove(d, 1, 2)
|
call remove(d, 1, 2)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E118:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E118:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR d = {1: 'a', 3: 'c'}
|
VAR d = {1: 'a', 3: 'c'}
|
||||||
call remove(d, 'a')
|
call remove(d, 'a')
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E716:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E716:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
let d = {'a-b': 55}
|
let d = {'a-b': 55}
|
||||||
echo d.a-b
|
echo d.a-b
|
||||||
END
|
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
|
let lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
var d = {'a-b': 55}
|
var d = {'a-b': 55}
|
||||||
echo d.a-b
|
echo d.a-b
|
||||||
END
|
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
|
let lines =<< trim END
|
||||||
var d = {'a-b': 55}
|
var d = {'a-b': 55}
|
||||||
echo d.a-b
|
echo d.a-b
|
||||||
END
|
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 lines =<< trim END
|
||||||
let d = {1: 'a', 3: 'c'}
|
let d = {1: 'a', 3: 'c'}
|
||||||
call remove(d, [])
|
call remove(d, [])
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E730:')
|
call v9.CheckScriptFailure(lines, 'E730:')
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
var d = {1: 'a', 3: 'c'}
|
var d = {1: 'a', 3: 'c'}
|
||||||
call remove(d, [])
|
call remove(d, [])
|
||||||
END
|
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
|
let lines =<< trim END
|
||||||
var d = {1: 'a', 3: 'c'}
|
var d = {1: 'a', 3: 'c'}
|
||||||
call remove(d, [])
|
call remove(d, [])
|
||||||
END
|
END
|
||||||
call CheckDefExecFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got list<unknown>')
|
call v9.CheckDefExecFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got list<unknown>')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Nasty: remove func from Dict that's being called (works)
|
" 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'))
|
VAR expected = 'a:' .. string(get(d, 'func'))
|
||||||
call assert_equal(expected, d.func(string(remove(d, 'func'))))
|
call assert_equal(expected, d.func(string(remove(d, 'func'))))
|
||||||
END
|
END
|
||||||
call CheckTransLegacySuccess(lines)
|
call v9.CheckTransLegacySuccess(lines)
|
||||||
call CheckTransVim9Success(lines)
|
call v9.CheckTransVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_dict_literal_keys()
|
func Test_dict_literal_keys()
|
||||||
@@ -535,7 +535,7 @@ func Test_dict_deepcopy()
|
|||||||
VAR dc = deepcopy(d)
|
VAR dc = deepcopy(d)
|
||||||
call deepcopy(d, 1)
|
call deepcopy(d, 1)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Failure(lines, 'E698:')
|
call v9.CheckLegacyAndVim9Failure(lines, 'E698:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
VAR d = {1: 1, 2: '2'}
|
VAR d = {1: 1, 2: '2'}
|
||||||
@@ -546,7 +546,7 @@ func Test_dict_deepcopy()
|
|||||||
VAR l3 = deepcopy(l2)
|
VAR l3 = deepcopy(l2)
|
||||||
call assert_true(l3[1] is l3[2])
|
call assert_true(l3[1] is l3[2])
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call assert_fails("call deepcopy([1, 2], 2)", 'E1023:')
|
call assert_fails("call deepcopy([1, 2], 2)", 'E1023:')
|
||||||
endfunc
|
endfunc
|
||||||
@@ -631,8 +631,8 @@ func Test_list_locked_var()
|
|||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
END
|
END
|
||||||
call CheckTransLegacySuccess(lines)
|
call v9.CheckTransLegacySuccess(lines)
|
||||||
call CheckTransVim9Success(lines)
|
call v9.CheckTransVim9Success(lines)
|
||||||
|
|
||||||
call assert_fails("let x=islocked('a b')", 'E488:')
|
call assert_fails("let x=islocked('a b')", 'E488:')
|
||||||
let mylist = [1, 2, 3]
|
let mylist = [1, 2, 3]
|
||||||
@@ -745,7 +745,7 @@ func Test_dict_item_lock_unlet()
|
|||||||
unlet d.a
|
unlet d.a
|
||||||
call assert_equal({'b': 100}, d)
|
call assert_equal({'b': 100}, d)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" filter() after lock on dict item
|
" filter() after lock on dict item
|
||||||
@@ -756,7 +756,7 @@ func Test_dict_lock_filter()
|
|||||||
call filter(d, 'v:key != "a"')
|
call filter(d, 'v:key != "a"')
|
||||||
call assert_equal({'b': 100}, d)
|
call assert_equal({'b': 100}, d)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" map() after lock on dict
|
" map() after lock on dict
|
||||||
@@ -768,8 +768,8 @@ func Test_dict_lock_map()
|
|||||||
call assert_equal({'a': 299, 'b': 300}, d)
|
call assert_equal({'a': 299, 'b': 300}, d)
|
||||||
END
|
END
|
||||||
" This won't work in a :def function
|
" This won't work in a :def function
|
||||||
call CheckTransLegacySuccess(lines)
|
call v9.CheckTransLegacySuccess(lines)
|
||||||
call CheckTransVim9Success(lines)
|
call v9.CheckTransVim9Success(lines)
|
||||||
|
|
||||||
" For a :def function use a global dict.
|
" For a :def function use a global dict.
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -780,7 +780,7 @@ func Test_dict_lock_map()
|
|||||||
enddef
|
enddef
|
||||||
call Delkey()
|
call Delkey()
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Lock one item in a list
|
" Lock one item in a list
|
||||||
@@ -792,8 +792,8 @@ func Test_list_item_lock_map()
|
|||||||
call assert_equal([299, 100, 101], l)
|
call assert_equal([299, 100, 101], l)
|
||||||
END
|
END
|
||||||
" This won't work in a :def function
|
" This won't work in a :def function
|
||||||
call CheckTransLegacySuccess(lines)
|
call v9.CheckTransLegacySuccess(lines)
|
||||||
call CheckTransVim9Success(lines)
|
call v9.CheckTransVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Lock one item in a dict
|
" 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)
|
call assert_equal({'a': 299, 'b': 100, 'c': 101}, d)
|
||||||
END
|
END
|
||||||
" This won't work in a :def function
|
" This won't work in a :def function
|
||||||
call CheckTransLegacySuccess(lines)
|
call v9.CheckTransLegacySuccess(lines)
|
||||||
call CheckTransVim9Success(lines)
|
call v9.CheckTransVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" No extend() after lock on dict item
|
" No extend() after lock on dict item
|
||||||
@@ -885,7 +885,7 @@ func Test_let_lock_list()
|
|||||||
lockvar! l
|
lockvar! l
|
||||||
call TryUnletListItem(l)
|
call TryUnletListItem(l)
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E741:')
|
call v9.CheckScriptFailure(lines, 'E741:')
|
||||||
unlet g:l
|
unlet g:l
|
||||||
endfunc
|
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)))
|
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
|
endif
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call assert_fails('call reverse("")', 'E899:')
|
call assert_fails('call reverse("")', 'E899:')
|
||||||
call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:')
|
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('Å,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()))
|
call assert_equal(',a,b,c', reduce('abc', LSTART acc, val LMIDDLE acc .. ',' .. val LEND, test_null_string()))
|
||||||
END
|
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 }) }, {}))
|
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 }), {}))
|
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(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1))
|
||||||
call assert_equal(['abc'], split('abc', '\\%('))
|
call assert_equal(['abc'], split('abc', '\\%('))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
call assert_fails("call split('abc', [])", 'E730:')
|
call assert_fails("call split('abc', [])", 'E730:')
|
||||||
call assert_fails("call split('abc', 'b', [])", 'E745:')
|
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(l != deepcopy(l))
|
||||||
call assert_false(d != deepcopy(d))
|
call assert_false(d != deepcopy(d))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" comparison errors
|
" comparison errors
|
||||||
call assert_fails('echo [1, 2] =~ {}', 'E691:')
|
call assert_fails('echo [1, 2] =~ {}', 'E691:')
|
||||||
@@ -1093,7 +1093,7 @@ func Test_listdict_compare_complex()
|
|||||||
call assert_true(l == lcopy)
|
call assert_true(l == lcopy)
|
||||||
call assert_true(dict4 == dict4copy)
|
call assert_true(dict4 == dict4copy)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for extending lists and dictionaries
|
" Test for extending lists and dictionaries
|
||||||
@@ -1130,7 +1130,7 @@ func Test_listdict_extend()
|
|||||||
call extend(l, [4, 5, 6], -3)
|
call extend(l, [4, 5, 6], -3)
|
||||||
call assert_equal([4, 5, 6, 1, 2, 3], l)
|
call assert_equal([4, 5, 6, 1, 2, 3], l)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let l = [1, 2, 3]
|
let l = [1, 2, 3]
|
||||||
call assert_fails("call extend(l, [4, 5, 6], 4)", 'E684:')
|
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 extend(d, {'b': 0, 'c': 'C'}, "keep")
|
||||||
call assert_equal({'a': 'A', 'b': 9, 'c': 'C'}, d)
|
call assert_equal({'a': 'A', 'b': 9, 'c': 'C'}, d)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let d = {'a': 'A', 'b': 'B'}
|
let d = {'a': 'A', 'b': 'B'}
|
||||||
call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:')
|
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 extend(l, l, 3)
|
||||||
call assert_equal([1, 5, 7, 1, 5, 7], l)
|
call assert_equal([1, 5, 7, 1, 5, 7], l)
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_listdict_extendnew()
|
func Test_listdict_extendnew()
|
||||||
@@ -1318,30 +1318,30 @@ endfunc
|
|||||||
|
|
||||||
" List and dict indexing tests
|
" List and dict indexing tests
|
||||||
func Test_listdict_index()
|
func Test_listdict_index()
|
||||||
call CheckLegacyAndVim9Failure(['echo function("min")[0]'], 'E695:')
|
call v9.CheckLegacyAndVim9Failure(['echo function("min")[0]'], 'E695:')
|
||||||
call CheckLegacyAndVim9Failure(['echo v:true[0]'], 'E909:')
|
call v9.CheckLegacyAndVim9Failure(['echo v:true[0]'], 'E909:')
|
||||||
call CheckLegacyAndVim9Failure(['echo v:null[0]'], 'E909:')
|
call v9.CheckLegacyAndVim9Failure(['echo v:null[0]'], 'E909:')
|
||||||
call CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d.'], ['E15:', 'E1127:', 'E15:'])
|
call v9.CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d.'], ['E15:', 'E1127:', 'E15:'])
|
||||||
call CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d[1 : 2]'], 'E719:')
|
call v9.CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d[1 : 2]'], 'E719:')
|
||||||
|
|
||||||
call assert_fails("let v = [4, 6][{-> 1}]", 'E729:')
|
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 assert_fails("let v = range(5)[2:{-> 2}(]", ['E15:', 'E116:'])
|
||||||
call CheckDefAndScriptFailure(['var v = range(5)[2 : () => 2(]'], 'E15:')
|
call v9.CheckDefAndScriptFailure(['var v = range(5)[2 : () => 2(]'], 'E15:')
|
||||||
|
|
||||||
call CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : 3'], ['E111:', 'E1097:', 'E111:'])
|
call v9.CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : 3'], ['E111:', 'E1097:', 'E111:'])
|
||||||
call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, 10)'], 'E684:')
|
call v9.CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, 10)'], 'E684:')
|
||||||
call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, -10)'], 'E684:')
|
call v9.CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, -10)'], 'E684:')
|
||||||
call CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, [])'], ['E745:', 'E1013:', 'E1210:'])
|
call v9.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 v9.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 v9.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 v9.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 v9.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.CheckLegacyAndVim9Failure(['VAR t = test_unknown()', 'echo t[0]'], 'E685:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for a null list
|
" Test for a null list
|
||||||
@@ -1379,7 +1379,7 @@ func Test_null_list()
|
|||||||
call assert_equal([], sort(l))
|
call assert_equal([], sort(l))
|
||||||
call assert_equal('[]', string(l))
|
call assert_equal('[]', string(l))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let l = test_null_list()
|
let l = test_null_list()
|
||||||
call assert_equal([], extend(l, l, 0))
|
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(0, remove(test_null_dict(), 'k'))
|
||||||
call assert_equal('{}', string(d))
|
call assert_equal('{}', string(d))
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
let d = test_null_dict()
|
let d = test_null_dict()
|
||||||
call assert_equal({}, extend(d, d, 'keep'))
|
call assert_equal({}, extend(d, d, 'keep'))
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ source shared.vim
|
|||||||
source check.vim
|
source check.vim
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
source term_util.vim
|
source term_util.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func Test_abbreviation()
|
func Test_abbreviation()
|
||||||
" abbreviation with 0x80 should work
|
" abbreviation with 0x80 should work
|
||||||
@@ -1415,7 +1415,7 @@ func Test_map_script_cmd_restore()
|
|||||||
vim9script
|
vim9script
|
||||||
nnoremap <F3> <ScriptCmd>eval 1 + 2<CR>
|
nnoremap <F3> <ScriptCmd>eval 1 + 2<CR>
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
call feedkeys("\<F3>:let g:result = 3+4\<CR>", 'xtc')
|
call feedkeys("\<F3>:let g:result = 3+4\<CR>", 'xtc')
|
||||||
call assert_equal(7, g:result)
|
call assert_equal(7, g:result)
|
||||||
|
|
||||||
@@ -1431,7 +1431,7 @@ func Test_map_script_cmd_finds_func()
|
|||||||
g:func_called = 'yes'
|
g:func_called = 'yes'
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
call feedkeys("y\<F3>\<Esc>", 'xtc')
|
call feedkeys("y\<F3>\<Esc>", 'xtc')
|
||||||
call assert_equal('yes', g:func_called)
|
call assert_equal('yes', g:func_called)
|
||||||
|
|
||||||
@@ -1449,7 +1449,7 @@ func Test_map_script_cmd_survives_unmap()
|
|||||||
feedkeys("\<F3>\<CR>", 'xct')
|
feedkeys("\<F3>\<CR>", 'xct')
|
||||||
assert_equal(123, b:result)
|
assert_equal(123, b:result)
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
nunmap <F3>
|
nunmap <F3>
|
||||||
unlet b:result
|
unlet b:result
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
source shared.vim
|
source shared.vim
|
||||||
source check.vim
|
source check.vim
|
||||||
source view_util.vim
|
source view_util.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func Setup_NewWindow()
|
func Setup_NewWindow()
|
||||||
10new
|
10new
|
||||||
@@ -626,7 +626,7 @@ func Test_opfunc_callback()
|
|||||||
normal! g@l
|
normal! g@l
|
||||||
call assert_equal([23, 'char'], g:OpFunc1Args)
|
call assert_equal([23, 'char'], g:OpFunc1Args)
|
||||||
END
|
END
|
||||||
call CheckTransLegacySuccess(lines)
|
call v9.CheckTransLegacySuccess(lines)
|
||||||
|
|
||||||
" Test for using a script-local function name
|
" Test for using a script-local function name
|
||||||
func s:OpFunc3(type)
|
func s:OpFunc3(type)
|
||||||
@@ -693,7 +693,7 @@ func Test_opfunc_callback()
|
|||||||
assert_equal(['char'], g:LocalOpFuncArgs)
|
assert_equal(['char'], g:LocalOpFuncArgs)
|
||||||
bw!
|
bw!
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
" setting 'opfunc' to a script local function outside of a script context
|
" setting 'opfunc' to a script local function outside of a script context
|
||||||
" should fail
|
" should fail
|
||||||
|
|||||||
@@ -2801,7 +2801,7 @@ def Popupwin_close_prevwin()
|
|||||||
assert_equal(2, winnr())
|
assert_equal(2, winnr())
|
||||||
var buf = term_start(&shell, {hidden: 1})
|
var buf = term_start(&shell, {hidden: 1})
|
||||||
popup_create(buf, {})
|
popup_create(buf, {})
|
||||||
TermWait(buf, 100)
|
g:TermWait(buf, 100)
|
||||||
popup_clear(true)
|
popup_clear(true)
|
||||||
assert_equal(2, winnr())
|
assert_equal(2, winnr())
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ CheckFeature profile
|
|||||||
|
|
||||||
source shared.vim
|
source shared.vim
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
source vim9.vim
|
|
||||||
|
|
||||||
func Test_profile_func()
|
func Test_profile_func()
|
||||||
call RunProfileFunc('func', 'let', 'let')
|
call RunProfileFunc('func', 'let', 'let')
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
" Test for the quickfix feature.
|
" Test for the quickfix feature.
|
||||||
|
|
||||||
source check.vim
|
source check.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
CheckFeature quickfix
|
CheckFeature quickfix
|
||||||
|
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
@@ -5347,7 +5347,7 @@ func Test_qftextfunc_callback()
|
|||||||
cclose
|
cclose
|
||||||
|
|
||||||
#" Test for using a lambda function with set
|
#" 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')
|
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
||||||
exe "set qftf=" .. optval
|
exe "set qftf=" .. optval
|
||||||
cexpr "F6:6:6:L6"
|
cexpr "F6:6:6:L6"
|
||||||
@@ -5356,21 +5356,21 @@ func Test_qftextfunc_callback()
|
|||||||
cclose
|
cclose
|
||||||
|
|
||||||
#" Set 'quickfixtextfunc' to a lambda expression
|
#" 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"
|
cexpr "F7:7:7:L7"
|
||||||
copen
|
copen
|
||||||
call assert_equal('F7-L7C7-L7', getline(1))
|
call assert_equal('F7-L7C7-L7', getline(1))
|
||||||
cclose
|
cclose
|
||||||
|
|
||||||
#" Set 'quickfixtextfunc' to string(lambda_expression)
|
#" 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"
|
cexpr "F8:8:8:L8"
|
||||||
copen
|
copen
|
||||||
call assert_equal('F8-L8C8-L8', getline(1))
|
call assert_equal('F8-L8C8-L8', getline(1))
|
||||||
cclose
|
cclose
|
||||||
|
|
||||||
#" Set 'quickfixtextfunc' to a variable with a lambda expression
|
#" 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
|
LET &qftf = Lambda
|
||||||
cexpr "F9:9:9:L9"
|
cexpr "F9:9:9:L9"
|
||||||
copen
|
copen
|
||||||
@@ -5378,14 +5378,14 @@ func Test_qftextfunc_callback()
|
|||||||
cclose
|
cclose
|
||||||
|
|
||||||
#" Set 'quickfixtextfunc' to a string(variable with a lambda expression)
|
#" 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)
|
LET &qftf = string(Lambda)
|
||||||
cexpr "F9:9:9:L9"
|
cexpr "F9:9:9:L9"
|
||||||
copen
|
copen
|
||||||
call assert_equal('F9-L9C9-L9', getline(1))
|
call assert_equal('F9-L9C9-L9', getline(1))
|
||||||
cclose
|
cclose
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for using a script-local function name
|
" Test for using a script-local function name
|
||||||
func s:TqfFunc2(info)
|
func s:TqfFunc2(info)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
" Test 'tagfunc'
|
" Test 'tagfunc'
|
||||||
|
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
source check.vim
|
source check.vim
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ func Test_tagfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Test for using a lambda function
|
#" 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')
|
LET optval = substitute(optval, ' ', '\\ ', 'g')
|
||||||
exe "set tagfunc=" .. optval
|
exe "set tagfunc=" .. optval
|
||||||
new
|
new
|
||||||
@@ -210,7 +210,7 @@ func Test_tagfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'tagfunc' to a lambda expression
|
#" 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
|
new
|
||||||
LET g:TagFunc1Args = []
|
LET g:TagFunc1Args = []
|
||||||
call assert_fails('tag a18', 'E433:')
|
call assert_fails('tag a18', 'E433:')
|
||||||
@@ -218,7 +218,7 @@ func Test_tagfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'tagfunc' to a string(lambda expression)
|
#" 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
|
new
|
||||||
LET g:TagFunc1Args = []
|
LET g:TagFunc1Args = []
|
||||||
call assert_fails('tag a18', 'E433:')
|
call assert_fails('tag a18', 'E433:')
|
||||||
@@ -226,7 +226,7 @@ func Test_tagfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'tagfunc' to a variable with a lambda expression
|
#" 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
|
LET &tagfunc = Lambda
|
||||||
new
|
new
|
||||||
LET g:TagFunc1Args = []
|
LET g:TagFunc1Args = []
|
||||||
@@ -235,7 +235,7 @@ func Test_tagfunc_callback()
|
|||||||
bw!
|
bw!
|
||||||
|
|
||||||
#" Set 'tagfunc' to a string(variable with a lambda expression)
|
#" 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)
|
LET &tagfunc = string(Lambda)
|
||||||
new
|
new
|
||||||
LET g:TagFunc1Args = []
|
LET g:TagFunc1Args = []
|
||||||
@@ -265,7 +265,7 @@ func Test_tagfunc_callback()
|
|||||||
call assert_equal([], g:TagFunc2Args)
|
call assert_equal([], g:TagFunc2Args)
|
||||||
bw!
|
bw!
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
|
|
||||||
" Test for using a script-local function name
|
" Test for using a script-local function name
|
||||||
func s:TagFunc3(pat, flags, info)
|
func s:TagFunc3(pat, flags, info)
|
||||||
@@ -380,7 +380,7 @@ func Test_tagfunc_callback()
|
|||||||
assert_equal(['a12', '', {}], g:LocalTagFuncArgs)
|
assert_equal(['a12', '', {}], g:LocalTagFuncArgs)
|
||||||
bw!
|
bw!
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
" cleanup
|
" cleanup
|
||||||
delfunc TagFunc1
|
delfunc TagFunc1
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ source check.vim
|
|||||||
CheckFeature textprop
|
CheckFeature textprop
|
||||||
|
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func Test_proptype_global()
|
func Test_proptype_global()
|
||||||
call prop_type_add('comment', {'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1})
|
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()
|
def Test_prop_remove_vim9()
|
||||||
new
|
new
|
||||||
AddPropTypes()
|
g:AddPropTypes()
|
||||||
SetupPropsInFirstLine()
|
g:SetupPropsInFirstLine()
|
||||||
assert_equal(1, prop_remove({type: 'three', id: 13, both: true, all: true}))
|
assert_equal(1, prop_remove({type: 'three', id: 13, both: true, all: true}))
|
||||||
DeletePropTypes()
|
g:DeletePropTypes()
|
||||||
bwipe!
|
bwipe!
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
@@ -1704,7 +1704,7 @@ enddef
|
|||||||
func Test_prop_list()
|
func Test_prop_list()
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
new
|
new
|
||||||
call AddPropTypes()
|
call g:AddPropTypes()
|
||||||
call setline(1, repeat([repeat('a', 60)], 10))
|
call setline(1, repeat([repeat('a', 60)], 10))
|
||||||
call prop_add(1, 4, {'type': 'one', 'id': 5, 'end_col': 6})
|
call prop_add(1, 4, {'type': 'one', 'id': 5, 'end_col': 6})
|
||||||
call prop_add(1, 5, {'type': 'two', 'id': 10, 'end_col': 7})
|
call prop_add(1, 5, {'type': 'two', 'id': 10, 'end_col': 7})
|
||||||
@@ -1844,10 +1844,10 @@ func Test_prop_list()
|
|||||||
bunload! Xaaa
|
bunload! Xaaa
|
||||||
call assert_equal([], prop_list(1, {'bufnr': bnr, 'end_lnum': -1}))
|
call assert_equal([], prop_list(1, {'bufnr': bnr, 'end_lnum': -1}))
|
||||||
|
|
||||||
call DeletePropTypes()
|
call g:DeletePropTypes()
|
||||||
:%bw!
|
:%bw!
|
||||||
END
|
END
|
||||||
call CheckLegacyAndVim9Success(lines)
|
call v9.CheckLegacyAndVim9Success(lines)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
" Tests for user defined commands
|
" Tests for user defined commands
|
||||||
|
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
" Test for <mods> in user defined commands
|
" Test for <mods> in user defined commands
|
||||||
function Test_cmdmods()
|
function Test_cmdmods()
|
||||||
@@ -287,13 +287,13 @@ func Test_CmdErrors()
|
|||||||
vim9script
|
vim9script
|
||||||
com! -complete=file DoCmd :
|
com! -complete=file DoCmd :
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E1208', 2)
|
call v9.CheckScriptFailure(lines, 'E1208', 2)
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
com! -nargs=0 -complete=file DoCmd :
|
com! -nargs=0 -complete=file DoCmd :
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E1208', 2)
|
call v9.CheckScriptFailure(lines, 'E1208', 2)
|
||||||
|
|
||||||
com! -nargs=0 DoCmd :
|
com! -nargs=0 DoCmd :
|
||||||
call assert_fails('DoCmd x', 'E488:')
|
call assert_fails('DoCmd x', 'E488:')
|
||||||
@@ -645,7 +645,7 @@ func Test_usercmd_with_block()
|
|||||||
command DoesNotEnd {
|
command DoesNotEnd {
|
||||||
echo 'hello'
|
echo 'hello'
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E1026:')
|
call v9.CheckScriptFailure(lines, 'E1026:')
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
command HelloThere {
|
command HelloThere {
|
||||||
@@ -653,7 +653,7 @@ func Test_usercmd_with_block()
|
|||||||
}
|
}
|
||||||
HelloThere
|
HelloThere
|
||||||
END
|
END
|
||||||
call CheckScriptSuccess(lines)
|
call v9.CheckScriptSuccess(lines)
|
||||||
delcommand HelloThere
|
delcommand HelloThere
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@@ -664,7 +664,7 @@ func Test_usercmd_with_block()
|
|||||||
}
|
}
|
||||||
BadCommand
|
BadCommand
|
||||||
END
|
END
|
||||||
call CheckScriptFailure(lines, 'E1128:')
|
call v9.CheckScriptFailure(lines, 'E1128:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_delcommand_buffer()
|
func Test_delcommand_buffer()
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
" Test commands that are not compiled in a :def function
|
" Test commands that are not compiled in a :def function
|
||||||
|
|
||||||
source check.vim
|
source check.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
source term_util.vim
|
source term_util.vim
|
||||||
source view_util.vim
|
source view_util.vim
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ def Test_vim9cmd()
|
|||||||
vim9c assert_equal(123, x)
|
vim9c assert_equal(123, x)
|
||||||
vim9cm assert_equal('yes', y)
|
vim9cm assert_equal('yes', y)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
assert_fails('vim9cmd', 'E1164:')
|
assert_fails('vim9cmd', 'E1164:')
|
||||||
assert_fails('legacy', 'E1234:')
|
assert_fails('legacy', 'E1234:')
|
||||||
@@ -22,7 +22,7 @@ def Test_vim9cmd()
|
|||||||
let str = 'con'
|
let str = 'con'
|
||||||
vim9cmd str .= 'cat'
|
vim9cmd str .= 'cat'
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E492:')
|
v9.CheckScriptFailure(lines, 'E492:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -30,7 +30,7 @@ def Test_vim9cmd()
|
|||||||
legacy let str = 'con'
|
legacy let str = 'con'
|
||||||
legacy let str .= 'cat'
|
legacy let str .= 'cat'
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -39,7 +39,7 @@ def Test_vim9cmd()
|
|||||||
enddef
|
enddef
|
||||||
nmap ,; :vim9cmd <SID>Foo()<CR>
|
nmap ,; :vim9cmd <SID>Foo()<CR>
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
feedkeys(',;', 'xt')
|
feedkeys(',;', 'xt')
|
||||||
assert_equal("bar", g:found_bar)
|
assert_equal("bar", g:found_bar)
|
||||||
@@ -50,23 +50,23 @@ def Test_vim9cmd()
|
|||||||
vim9script
|
vim9script
|
||||||
legacy echo 1'000
|
legacy echo 1'000
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E115:')
|
v9.CheckScriptFailure(lines, 'E115:')
|
||||||
|
|
||||||
if has('float')
|
if has('float')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
echo .10
|
echo .10
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9cmd echo .10
|
vim9cmd echo .10
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
legacy echo .10
|
legacy echo .10
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E15:')
|
v9.CheckScriptFailure(lines, 'E15:')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
echo v:version
|
echo v:version
|
||||||
@@ -75,12 +75,12 @@ def Test_vim9cmd()
|
|||||||
vim9script
|
vim9script
|
||||||
echo version
|
echo version
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E121:')
|
v9.CheckScriptFailure(lines, 'E121:')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
legacy echo version
|
legacy echo version
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_edit_wildcards()
|
def Test_edit_wildcards()
|
||||||
@@ -99,8 +99,8 @@ def Test_edit_wildcards()
|
|||||||
edit X`=filename`xx`=filenr`yy
|
edit X`=filename`xx`=filenr`yy
|
||||||
assert_equal('XXtestxx77yy', bufname())
|
assert_equal('XXtestxx77yy', bufname())
|
||||||
|
|
||||||
CheckDefFailure(['edit `=xxx`'], 'E1001:')
|
v9.CheckDefFailure(['edit `=xxx`'], 'E1001:')
|
||||||
CheckDefFailure(['edit `="foo"'], 'E1083:')
|
v9.CheckDefFailure(['edit `="foo"'], 'E1083:')
|
||||||
|
|
||||||
var files = ['file 1', 'file%2', 'file# 3']
|
var files = ['file 1', 'file%2', 'file# 3']
|
||||||
args `=files`
|
args `=files`
|
||||||
@@ -179,7 +179,7 @@ def Test_expand_alternate_file()
|
|||||||
bwipe! altfoo
|
bwipe! altfoo
|
||||||
bwipe! bar
|
bwipe! bar
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_global_backtick_expansion()
|
def Test_global_backtick_expansion()
|
||||||
@@ -221,7 +221,7 @@ def Test_folddo_backtick_expansion()
|
|||||||
enddef
|
enddef
|
||||||
call Test()
|
call Test()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E15: Invalid expression: "`=g:val`"')
|
v9.CheckScriptFailure(lines, 'E15: Invalid expression: "`=g:val`"')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_hardcopy_wildcards()
|
def Test_hardcopy_wildcards()
|
||||||
@@ -257,7 +257,7 @@ def Test_echo_linebreak()
|
|||||||
redir END
|
redir END
|
||||||
assert_equal("\nonetwo", @a)
|
assert_equal("\nonetwo", @a)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -268,7 +268,7 @@ def Test_echo_linebreak()
|
|||||||
redir END
|
redir END
|
||||||
assert_equal("\n66", @a)
|
assert_equal("\n66", @a)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_condition_types()
|
def Test_condition_types()
|
||||||
@@ -276,21 +276,21 @@ def Test_condition_types()
|
|||||||
if 'text'
|
if 'text'
|
||||||
endif
|
endif
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1135:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E1135:', 1)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
if [1]
|
if [1]
|
||||||
endif
|
endif
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1012:', 1)
|
v9.CheckDefFailure(lines, 'E1012:', 1)
|
||||||
CheckScriptFailure(['vim9script'] + lines, 'E745:', 2)
|
v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g:cond = 'text'
|
g:cond = 'text'
|
||||||
if g:cond
|
if g:cond
|
||||||
endif
|
endif
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E1135:', 2)
|
v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g:cond = 0
|
g:cond = 0
|
||||||
@@ -298,7 +298,7 @@ def Test_condition_types()
|
|||||||
elseif 'text'
|
elseif 'text'
|
||||||
endif
|
endif
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1135:', 3)
|
v9.CheckDefAndScriptFailure(lines, 'E1135:', 3)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g:cond = 0
|
g:cond = 0
|
||||||
@@ -306,7 +306,7 @@ def Test_condition_types()
|
|||||||
elseif 'text' garbage
|
elseif 'text' garbage
|
||||||
endif
|
endif
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E488:', 3)
|
v9.CheckDefAndScriptFailure(lines, 'E488:', 3)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g:cond = 0
|
g:cond = 0
|
||||||
@@ -314,8 +314,8 @@ def Test_condition_types()
|
|||||||
elseif [1]
|
elseif [1]
|
||||||
endif
|
endif
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1012:', 3)
|
v9.CheckDefFailure(lines, 'E1012:', 3)
|
||||||
CheckScriptFailure(['vim9script'] + lines, 'E745:', 4)
|
v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 4)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g:cond = 'text'
|
g:cond = 'text'
|
||||||
@@ -323,28 +323,28 @@ def Test_condition_types()
|
|||||||
elseif g:cond
|
elseif g:cond
|
||||||
endif
|
endif
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E1135:', 3)
|
v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 3)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
while 'text'
|
while 'text'
|
||||||
endwhile
|
endwhile
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1012:', 1)
|
v9.CheckDefFailure(lines, 'E1012:', 1)
|
||||||
CheckScriptFailure(['vim9script'] + lines, 'E1135:', 2)
|
v9.CheckScriptFailure(['vim9script'] + lines, 'E1135:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
while [1]
|
while [1]
|
||||||
endwhile
|
endwhile
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1012:', 1)
|
v9.CheckDefFailure(lines, 'E1012:', 1)
|
||||||
CheckScriptFailure(['vim9script'] + lines, 'E745:', 2)
|
v9.CheckScriptFailure(['vim9script'] + lines, 'E745:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g:cond = 'text'
|
g:cond = 'text'
|
||||||
while g:cond
|
while g:cond
|
||||||
endwhile
|
endwhile
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E1135:', 2)
|
v9.CheckDefExecAndScriptFailure(lines, 'E1135:', 2)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_if_linebreak()
|
def Test_if_linebreak()
|
||||||
@@ -357,7 +357,7 @@ def Test_if_linebreak()
|
|||||||
endif
|
endif
|
||||||
assert_equal(42, g:res)
|
assert_equal(42, g:res)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
unlet g:res
|
unlet g:res
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -372,7 +372,7 @@ def Test_if_linebreak()
|
|||||||
endif
|
endif
|
||||||
assert_equal(12, g:res)
|
assert_equal(12, g:res)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
unlet g:res
|
unlet g:res
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ def Test_while_linebreak()
|
|||||||
endwhile
|
endwhile
|
||||||
assert_equal(16, nr)
|
assert_equal(16, nr)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -403,7 +403,7 @@ def Test_while_linebreak()
|
|||||||
endwhile
|
endwhile
|
||||||
assert_equal(16, nr)
|
assert_equal(16, nr)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_for_linebreak()
|
def Test_for_linebreak()
|
||||||
@@ -417,7 +417,7 @@ def Test_for_linebreak()
|
|||||||
endfor
|
endfor
|
||||||
assert_equal(10, nr)
|
assert_equal(10, nr)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -433,10 +433,10 @@ def Test_for_linebreak()
|
|||||||
endfor
|
endfor
|
||||||
assert_equal(10, nr)
|
assert_equal(10, nr)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def MethodAfterLinebreak(arg: string)
|
def s:MethodAfterLinebreak(arg: string)
|
||||||
arg
|
arg
|
||||||
->setline(1)
|
->setline(1)
|
||||||
enddef
|
enddef
|
||||||
@@ -455,7 +455,7 @@ def Test_method_call_linebreak()
|
|||||||
3]->RetArg()
|
3]->RetArg()
|
||||||
assert_equal([1, 2, 3], res)
|
assert_equal([1, 2, 3], res)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
new
|
new
|
||||||
@@ -466,7 +466,7 @@ def Test_method_call_linebreak()
|
|||||||
assert_equal(['1', '2'], getline(1, 2))
|
assert_equal(['1', '2'], getline(1, 2))
|
||||||
bwipe!
|
bwipe!
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
new
|
new
|
||||||
@@ -484,7 +484,7 @@ def Test_method_call_linebreak()
|
|||||||
assert_equal('the text', getline(1))
|
assert_equal('the text', getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
new
|
new
|
||||||
@@ -495,7 +495,7 @@ def Test_method_call_linebreak()
|
|||||||
bwipe!
|
bwipe!
|
||||||
END
|
END
|
||||||
g:shortlist = [1, 2]
|
g:shortlist = [1, 2]
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
unlet g:shortlist
|
unlet g:shortlist
|
||||||
|
|
||||||
new
|
new
|
||||||
@@ -516,7 +516,7 @@ def Test_method_call_linebreak()
|
|||||||
Foo->Bar()
|
Foo->Bar()
|
||||||
->setline(1)
|
->setline(1)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
assert_equal('# some text', getline(1))
|
assert_equal('# some text', getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
enddef
|
enddef
|
||||||
@@ -532,7 +532,7 @@ def Test_method_call_whitespace()
|
|||||||
assert_equal(['text', 'text', 'text', 'text'], getline(1, 4))
|
assert_equal(['text', 'text', 'text', 'text'], getline(1, 4))
|
||||||
bwipe!
|
bwipe!
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_method_and_user_command()
|
def Test_method_and_user_command()
|
||||||
@@ -559,7 +559,7 @@ def Test_method_and_user_command()
|
|||||||
enddef
|
enddef
|
||||||
InDefFunc()
|
InDefFunc()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_option_use_linebreak()
|
def Test_option_use_linebreak()
|
||||||
@@ -575,7 +575,7 @@ def Test_option_use_linebreak()
|
|||||||
assert_equal(['(:)', '[:]', '{:}'], getline(1, '$'))
|
assert_equal(['(:)', '[:]', '{:}'], getline(1, '$'))
|
||||||
bwipe!
|
bwipe!
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_use_register()
|
def Test_use_register()
|
||||||
@@ -591,46 +591,46 @@ def Test_use_register()
|
|||||||
assert_equal(['one', 'two', 'three'], getline(1, '$'))
|
assert_equal(['one', 'two', 'three'], getline(1, '$'))
|
||||||
bwipe!
|
bwipe!
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@a = 'echo "text"'
|
@a = 'echo "text"'
|
||||||
@a
|
@a
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@/ = 'pattern'
|
@/ = 'pattern'
|
||||||
@/
|
@/
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
&opfunc = 'nothing'
|
&opfunc = 'nothing'
|
||||||
&opfunc
|
&opfunc
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
||||||
&opfunc = ''
|
&opfunc = ''
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
&l:showbreak = 'nothing'
|
&l:showbreak = 'nothing'
|
||||||
&l:showbreak
|
&l:showbreak
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
||||||
&l:showbreak = ''
|
&l:showbreak = ''
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
&g:showbreak = 'nothing'
|
&g:showbreak = 'nothing'
|
||||||
&g:showbreak
|
&g:showbreak
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
||||||
&g:showbreak = ''
|
&g:showbreak = ''
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
$SomeEnv = 'value'
|
$SomeEnv = 'value'
|
||||||
$SomeEnv
|
$SomeEnv
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1207:', 2)
|
||||||
$SomeEnv = ''
|
$SomeEnv = ''
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ def Test_environment_use_linebreak()
|
|||||||
assert_equal(['one', 'two', 'three'], getline(1, '$'))
|
assert_equal(['one', 'two', 'three'], getline(1, '$'))
|
||||||
bwipe!
|
bwipe!
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_skipped_expr_linebreak()
|
def Test_skipped_expr_linebreak()
|
||||||
@@ -671,7 +671,7 @@ def Test_dict_member()
|
|||||||
test.data->sort()
|
test.data->sort()
|
||||||
assert_equal({data: [1, 2, 3]}, test)
|
assert_equal({data: [1, 2, 3]}, test)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_bar_after_command()
|
def Test_bar_after_command()
|
||||||
@@ -680,14 +680,14 @@ def Test_bar_after_command()
|
|||||||
redraw | echo x
|
redraw | echo x
|
||||||
enddef
|
enddef
|
||||||
RedrawAndEcho()
|
RedrawAndEcho()
|
||||||
assert_match('did redraw', Screenline(&lines))
|
assert_match('did redraw', g:Screenline(&lines))
|
||||||
|
|
||||||
def CallAndEcho()
|
def CallAndEcho()
|
||||||
var x = 'did redraw'
|
var x = 'did redraw'
|
||||||
reg_executing() | echo x
|
reg_executing() | echo x
|
||||||
enddef
|
enddef
|
||||||
CallAndEcho()
|
CallAndEcho()
|
||||||
assert_match('did redraw', Screenline(&lines))
|
assert_match('did redraw', g:Screenline(&lines))
|
||||||
|
|
||||||
if has('unix')
|
if has('unix')
|
||||||
# bar in filter write command does not start new command
|
# 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)
|
assert_equal(execute('filter /piyo/ registers abc'), expected)
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
# also do this compiled
|
# also do this compiled
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@a = 'very specific z3d37dh234 string'
|
@a = 'very specific z3d37dh234 string'
|
||||||
filter z3d37dh234 registers
|
filter z3d37dh234 registers
|
||||||
assert_match('very specific z3d37dh234 string', Screenline(&lines))
|
assert_match('very specific z3d37dh234 string', g:Screenline(&lines))
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
edit foobar
|
edit foobar
|
||||||
@@ -747,7 +747,7 @@ def Test_command_modifier_filter()
|
|||||||
assert_match('"foobar"', g:filter_out)
|
assert_match('"foobar"', g:filter_out)
|
||||||
unlet g:filter_out
|
unlet g:filter_out
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_win_command_modifiers()
|
def Test_win_command_modifiers()
|
||||||
@@ -930,7 +930,7 @@ def Test_bar_line_continuation()
|
|||||||
unlet g:readExtra
|
unlet g:readExtra
|
||||||
unlet g:readMore
|
unlet g:readMore
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_command_modifier_other()
|
def Test_command_modifier_other()
|
||||||
@@ -972,10 +972,10 @@ def Test_command_modifier_other()
|
|||||||
unlet g:verbose_now
|
unlet g:verbose_now
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def EchoHere()
|
def s:EchoHere()
|
||||||
echomsg 'here'
|
echomsg 'here'
|
||||||
enddef
|
enddef
|
||||||
def EchoThere()
|
def s:EchoThere()
|
||||||
unsilent echomsg 'there'
|
unsilent echomsg 'there'
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
@@ -1009,21 +1009,21 @@ def Test_modifier_silent_unsilent()
|
|||||||
assert_equal(11, &history)
|
assert_equal(11, &history)
|
||||||
set history&
|
set history&
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_range_after_command_modifier()
|
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
|
new
|
||||||
setline(1, 'xxx')
|
setline(1, 'xxx')
|
||||||
CheckScriptSuccess(['vim9script', 'silent keepjump :1d _'])
|
v9.CheckScriptSuccess(['vim9script', 'silent keepjump :1d _'])
|
||||||
assert_equal('', getline(1))
|
assert_equal('', getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
legacy /pat/
|
legacy /pat/
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E486: Pattern not found: pat')
|
v9.CheckDefExecAndScriptFailure(lines, 'E486: Pattern not found: pat')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_silent_pattern()
|
def Test_silent_pattern()
|
||||||
@@ -1038,50 +1038,50 @@ def Test_useless_command_modifier()
|
|||||||
if g:maybe
|
if g:maybe
|
||||||
silent endif
|
silent endif
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1176:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1176:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
for i in [0]
|
for i in [0]
|
||||||
silent endfor
|
silent endfor
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1176:', 2)
|
v9.CheckDefFailure(lines, 'E1176:', 2)
|
||||||
CheckScriptSuccess(['vim9script'] + lines)
|
v9.CheckScriptSuccess(['vim9script'] + lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
while g:maybe
|
while g:maybe
|
||||||
silent endwhile
|
silent endwhile
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1176:', 2)
|
v9.CheckDefFailure(lines, 'E1176:', 2)
|
||||||
g:maybe = false
|
g:maybe = false
|
||||||
CheckScriptSuccess(['vim9script'] + lines)
|
v9.CheckScriptSuccess(['vim9script'] + lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
silent try
|
silent try
|
||||||
finally
|
finally
|
||||||
endtry
|
endtry
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1176:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E1176:', 1)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
try
|
try
|
||||||
silent catch
|
silent catch
|
||||||
endtry
|
endtry
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1176:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1176:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
try
|
try
|
||||||
silent finally
|
silent finally
|
||||||
endtry
|
endtry
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1176:', 2)
|
v9.CheckDefAndScriptFailure(lines, 'E1176:', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
try
|
try
|
||||||
finally
|
finally
|
||||||
silent endtry
|
silent endtry
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1176:', 3)
|
v9.CheckDefAndScriptFailure(lines, 'E1176:', 3)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_eval_command()
|
def Test_eval_command()
|
||||||
@@ -1109,7 +1109,7 @@ def Test_eval_command()
|
|||||||
assert_equal('yes', g:caught)
|
assert_equal('yes', g:caught)
|
||||||
unlet g:caught
|
unlet g:caught
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_map_command()
|
def Test_map_command()
|
||||||
@@ -1117,8 +1117,8 @@ def Test_map_command()
|
|||||||
nnoremap <F3> :echo 'hit F3 #'<CR>
|
nnoremap <F3> :echo 'hit F3 #'<CR>
|
||||||
assert_equal(":echo 'hit F3 #'<CR>", maparg("<F3>", "n"))
|
assert_equal(":echo 'hit F3 #'<CR>", maparg("<F3>", "n"))
|
||||||
END
|
END
|
||||||
CheckDefSuccess(lines)
|
v9.CheckDefSuccess(lines)
|
||||||
CheckScriptSuccess(['vim9script'] + lines)
|
v9.CheckScriptSuccess(['vim9script'] + lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_normal_command()
|
def Test_normal_command()
|
||||||
@@ -1173,7 +1173,7 @@ def Test_put_command()
|
|||||||
|
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
CheckDefFailure(['put =xxx'], 'E1001:')
|
v9.CheckDefFailure(['put =xxx'], 'E1001:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_put_with_linebreak()
|
def Test_put_with_linebreak()
|
||||||
@@ -1183,7 +1183,7 @@ def Test_put_with_linebreak()
|
|||||||
pu =split('abc', '\zs')
|
pu =split('abc', '\zs')
|
||||||
->join()
|
->join()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
getline(2)->assert_equal('a b c')
|
getline(2)->assert_equal('a b c')
|
||||||
bwipe!
|
bwipe!
|
||||||
enddef
|
enddef
|
||||||
@@ -1215,7 +1215,7 @@ def Test_f_args()
|
|||||||
TestFArgs one two three
|
TestFArgs one two three
|
||||||
assert_equal(['one', 'two', 'three'], g:args)
|
assert_equal(['one', 'two', 'three'], g:args)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_user_command_comment()
|
def Test_user_command_comment()
|
||||||
@@ -1225,13 +1225,13 @@ def Test_user_command_comment()
|
|||||||
vim9script
|
vim9script
|
||||||
Comd # comment
|
Comd # comment
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
Comd# comment
|
Comd# comment
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1144:')
|
v9.CheckScriptFailure(lines, 'E1144:')
|
||||||
delcommand Comd
|
delcommand Comd
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -1239,7 +1239,7 @@ def Test_user_command_comment()
|
|||||||
command Foo echo 'Foo'
|
command Foo echo 'Foo'
|
||||||
Foo3Bar
|
Foo3Bar
|
||||||
END
|
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
|
delcommand Foo
|
||||||
enddef
|
enddef
|
||||||
@@ -1255,7 +1255,7 @@ def Test_star_command()
|
|||||||
set cpo-=*
|
set cpo-=*
|
||||||
assert_fails("exe '*s'", 'E1050:')
|
assert_fails("exe '*s'", 'E1050:')
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_cmd_argument_without_colon()
|
def Test_cmd_argument_without_colon()
|
||||||
@@ -1276,7 +1276,7 @@ def Test_ambiguous_user_cmd()
|
|||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
Cmd
|
Cmd
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E464:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E464:', 1)
|
||||||
delcommand Cmd1
|
delcommand Cmd1
|
||||||
delcommand Cmd2
|
delcommand Cmd2
|
||||||
enddef
|
enddef
|
||||||
@@ -1285,12 +1285,12 @@ def Test_command_not_recognized()
|
|||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
d.key = 'asdf'
|
d.key = 'asdf'
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1146:', 1)
|
v9.CheckDefFailure(lines, 'E1146:', 1)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
d['key'] = 'asdf'
|
d['key'] = 'asdf'
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1146:', 1)
|
v9.CheckDefFailure(lines, 'E1146:', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_magic_not_used()
|
def Test_magic_not_used()
|
||||||
@@ -1378,7 +1378,7 @@ def Test_windo_missing_endif()
|
|||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
windo if 1
|
windo if 1
|
||||||
END
|
END
|
||||||
CheckDefExecFailure(lines, 'E171:', 1)
|
v9.CheckDefExecFailure(lines, 'E171:', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
let s:theList = [1, 2, 3]
|
let s:theList = [1, 2, 3]
|
||||||
@@ -1464,26 +1464,26 @@ def Test_lockvar()
|
|||||||
enddef
|
enddef
|
||||||
SetList()
|
SetList()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1119', 4)
|
v9.CheckScriptFailure(lines, 'E1119', 4)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
var theList = [1, 2, 3]
|
var theList = [1, 2, 3]
|
||||||
lockvar theList
|
lockvar theList
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1178', 2)
|
v9.CheckDefFailure(lines, 'E1178', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
var theList = [1, 2, 3]
|
var theList = [1, 2, 3]
|
||||||
unlockvar theList
|
unlockvar theList
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1178', 2)
|
v9.CheckDefFailure(lines, 'E1178', 2)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
var name = 'john'
|
var name = 'john'
|
||||||
lockvar nameX
|
lockvar nameX
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1246', 3)
|
v9.CheckScriptFailure(lines, 'E1246', 3)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -1493,7 +1493,7 @@ def Test_lockvar()
|
|||||||
enddef
|
enddef
|
||||||
LockIt()
|
LockIt()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1246', 1)
|
v9.CheckScriptFailure(lines, 'E1246', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_substitute_expr()
|
def Test_substitute_expr()
|
||||||
@@ -1520,8 +1520,8 @@ def Test_substitute_expr()
|
|||||||
|
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
CheckDefFailure(['s/from/\="x")/'], 'E488:')
|
v9.CheckDefFailure(['s/from/\="x")/'], 'E488:')
|
||||||
CheckDefFailure(['s/from/\="x"/9'], 'E488:')
|
v9.CheckDefFailure(['s/from/\="x"/9'], 'E488:')
|
||||||
|
|
||||||
# When calling a function the right instruction list needs to be restored.
|
# When calling a function the right instruction list needs to be restored.
|
||||||
g:cond = true
|
g:cond = true
|
||||||
@@ -1545,7 +1545,7 @@ def Test_substitute_expr()
|
|||||||
assert_equal('rep', getline(1))
|
assert_equal('rep', getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
unlet g:cond
|
unlet g:cond
|
||||||
|
|
||||||
# List results in multiple lines
|
# List results in multiple lines
|
||||||
@@ -1594,14 +1594,14 @@ def Test_redir_to_var()
|
|||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
redir => notexist
|
redir => notexist
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1089:')
|
v9.CheckDefFailure(lines, 'E1089:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
var ls = 'asdf'
|
var ls = 'asdf'
|
||||||
redir => ls[1]
|
redir => ls[1]
|
||||||
redir END
|
redir END
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1141:')
|
v9.CheckDefFailure(lines, 'E1141:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
var text: string
|
var text: string
|
||||||
@@ -1610,7 +1610,7 @@ def Test_redir_to_var()
|
|||||||
redir > Xfile
|
redir > Xfile
|
||||||
redir END
|
redir END
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1185:')
|
v9.CheckDefFailure(lines, 'E1185:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
var text: number
|
var text: number
|
||||||
@@ -1618,7 +1618,7 @@ def Test_redir_to_var()
|
|||||||
echo 'hello'
|
echo 'hello'
|
||||||
redir END
|
redir END
|
||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1012:')
|
v9.CheckDefFailure(lines, 'E1012:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_echo_void()
|
def Test_echo_void()
|
||||||
@@ -1629,7 +1629,7 @@ def Test_echo_void()
|
|||||||
enddef
|
enddef
|
||||||
echo NoReturn()
|
echo NoReturn()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1186:', 5)
|
v9.CheckScriptFailure(lines, 'E1186:', 5)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -1641,7 +1641,7 @@ def Test_echo_void()
|
|||||||
enddef
|
enddef
|
||||||
defcompile
|
defcompile
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1186:', 1)
|
v9.CheckScriptFailure(lines, 'E1186:', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_cmdwin_block()
|
def Test_cmdwin_block()
|
||||||
@@ -1661,81 +1661,81 @@ def Test_var_not_cmd()
|
|||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
g:notexist:cmd
|
g:notexist:cmd
|
||||||
END
|
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
|
lines =<< trim END
|
||||||
g-pat-cmd
|
g-pat-cmd
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1241:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E1241:', 1)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g.pat.cmd
|
g.pat.cmd
|
||||||
END
|
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
|
lines =<< trim END
|
||||||
s:notexist:repl
|
s:notexist:repl
|
||||||
END
|
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
|
lines =<< trim END
|
||||||
s-pat-repl
|
s-pat-repl
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1241:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E1241:', 1)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
s.pat.repl
|
s.pat.repl
|
||||||
END
|
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
|
lines =<< trim END
|
||||||
w:notexist->len()
|
w:notexist->len()
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: w:notexist', 1)
|
v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: w:notexist', 1)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
b:notexist->len()
|
b:notexist->len()
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: b:notexist', 1)
|
v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: b:notexist', 1)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
t:notexist->len()
|
t:notexist->len()
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: t:notexist', 1)
|
v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: t:notexist', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_no_space_after_command()
|
def Test_no_space_after_command()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
g /pat/cmd
|
g /pat/cmd
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1242:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E1242:', 1)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g #pat#cmd
|
g #pat#cmd
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1242:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E1242:', 1)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g#pat#cmd
|
g#pat#cmd
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
g# pat#cmd
|
g# pat#cmd
|
||||||
END
|
END
|
||||||
CheckDefAndScriptSuccess(lines)
|
v9.CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
s /pat/repl
|
s /pat/repl
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1242:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E1242:', 1)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
s #pat#repl
|
s #pat#repl
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1242:', 1)
|
v9.CheckDefAndScriptFailure(lines, 'E1242:', 1)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
s#pat#repl
|
s#pat#repl
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E486:', 1)
|
v9.CheckDefExecAndScriptFailure(lines, 'E486:', 1)
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
s# pat#repl
|
s# pat#repl
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E486:', 1)
|
v9.CheckDefExecAndScriptFailure(lines, 'E486:', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Test for the 'previewpopup' option
|
" Test for the 'previewpopup' option
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
" Test the :disassemble command, and compilation as a side effect
|
" Test the :disassemble command, and compilation as a side effect
|
||||||
|
|
||||||
source check.vim
|
source check.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
func NotCompiled()
|
func s:NotCompiled()
|
||||||
echo "not"
|
echo "not"
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ def Test_disassemble_push()
|
|||||||
'2 RETURN void',
|
'2 RETURN void',
|
||||||
res)
|
res)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
delete('Xdir', 'rf')
|
delete('Xdir', 'rf')
|
||||||
&rtp = save_rtp
|
&rtp = save_rtp
|
||||||
@@ -690,22 +690,22 @@ def Test_disassemble_new()
|
|||||||
res)
|
res)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def FuncWithArg(arg: any)
|
def s:FuncWithArg(arg: any)
|
||||||
echo arg
|
echo arg
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
func UserFunc()
|
func s:UserFunc()
|
||||||
echo 'nothing'
|
echo 'nothing'
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func UserFuncWithArg(arg)
|
func s:UserFuncWithArg(arg)
|
||||||
echo a:arg
|
echo a:arg
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
def s:ScriptFuncCall(): string
|
def s:ScriptFuncCall(): string
|
||||||
changenr()
|
changenr()
|
||||||
char2nr("abc")
|
char2nr("abc")
|
||||||
Test_disassemble_new()
|
g:Test_disassemble_new()
|
||||||
FuncWithArg(343)
|
FuncWithArg(343)
|
||||||
ScriptFuncNew()
|
ScriptFuncNew()
|
||||||
s:ScriptFuncNew()
|
s:ScriptFuncNew()
|
||||||
@@ -728,12 +728,12 @@ def Test_disassemble_call()
|
|||||||
'\d PUSHS "abc"\_s*' ..
|
'\d PUSHS "abc"\_s*' ..
|
||||||
'\d BCALL char2nr(argc 1)\_s*' ..
|
'\d BCALL char2nr(argc 1)\_s*' ..
|
||||||
'\d DROP\_s*' ..
|
'\d DROP\_s*' ..
|
||||||
'Test_disassemble_new()\_s*' ..
|
'g:Test_disassemble_new()\_s*' ..
|
||||||
'\d DCALL Test_disassemble_new(argc 0)\_s*' ..
|
'\d DCALL Test_disassemble_new(argc 0)\_s*' ..
|
||||||
'\d DROP\_s*' ..
|
'\d DROP\_s*' ..
|
||||||
'FuncWithArg(343)\_s*' ..
|
'FuncWithArg(343)\_s*' ..
|
||||||
'\d\+ PUSHNR 343\_s*' ..
|
'\d\+ PUSHNR 343\_s*' ..
|
||||||
'\d\+ DCALL FuncWithArg(argc 1)\_s*' ..
|
'\d\+ DCALL <SNR>\d\+_FuncWithArg(argc 1)\_s*' ..
|
||||||
'\d\+ DROP\_s*' ..
|
'\d\+ DROP\_s*' ..
|
||||||
'ScriptFuncNew()\_s*' ..
|
'ScriptFuncNew()\_s*' ..
|
||||||
'\d\+ DCALL <SNR>\d\+_ScriptFuncNew(argc 0)\_s*' ..
|
'\d\+ DCALL <SNR>\d\+_ScriptFuncNew(argc 0)\_s*' ..
|
||||||
@@ -742,11 +742,11 @@ def Test_disassemble_call()
|
|||||||
'\d\+ DCALL <SNR>\d\+_ScriptFuncNew(argc 0)\_s*' ..
|
'\d\+ DCALL <SNR>\d\+_ScriptFuncNew(argc 0)\_s*' ..
|
||||||
'\d\+ DROP\_s*' ..
|
'\d\+ DROP\_s*' ..
|
||||||
'UserFunc()\_s*' ..
|
'UserFunc()\_s*' ..
|
||||||
'\d\+ UCALL UserFunc(argc 0)\_s*' ..
|
'\d\+ UCALL <80><fd>R\d\+_UserFunc(argc 0)\_s*' ..
|
||||||
'\d\+ DROP\_s*' ..
|
'\d\+ DROP\_s*' ..
|
||||||
'UserFuncWithArg("foo")\_s*' ..
|
'UserFuncWithArg("foo")\_s*' ..
|
||||||
'\d\+ PUSHS "foo"\_s*' ..
|
'\d\+ PUSHS "foo"\_s*' ..
|
||||||
'\d\+ UCALL UserFuncWithArg(argc 1)\_s*' ..
|
'\d\+ UCALL <80><fd>R\d\+_UserFuncWithArg(argc 1)\_s*' ..
|
||||||
'\d\+ DROP\_s*' ..
|
'\d\+ DROP\_s*' ..
|
||||||
'var FuncRef = function("UserFunc")\_s*' ..
|
'var FuncRef = function("UserFunc")\_s*' ..
|
||||||
'\d\+ PUSHS "UserFunc"\_s*' ..
|
'\d\+ PUSHS "UserFunc"\_s*' ..
|
||||||
@@ -811,7 +811,7 @@ enddef
|
|||||||
def EchoArg(arg: string): string
|
def EchoArg(arg: string): string
|
||||||
return arg
|
return arg
|
||||||
enddef
|
enddef
|
||||||
def RefThis(): func
|
def s:RefThis(): func
|
||||||
return function('EchoArg')
|
return function('EchoArg')
|
||||||
enddef
|
enddef
|
||||||
def s:ScriptPCall()
|
def s:ScriptPCall()
|
||||||
@@ -822,7 +822,7 @@ def Test_disassemble_pcall()
|
|||||||
var res = execute('disass s:ScriptPCall')
|
var res = execute('disass s:ScriptPCall')
|
||||||
assert_match('<SNR>\d\+_ScriptPCall\_s*' ..
|
assert_match('<SNR>\d\+_ScriptPCall\_s*' ..
|
||||||
'RefThis()("text")\_s*' ..
|
'RefThis()("text")\_s*' ..
|
||||||
'\d DCALL RefThis(argc 0)\_s*' ..
|
'\d DCALL <SNR>\d\+_RefThis(argc 0)\_s*' ..
|
||||||
'\d PUSHS "text"\_s*' ..
|
'\d PUSHS "text"\_s*' ..
|
||||||
'\d PCALL top (argc 1)\_s*' ..
|
'\d PCALL top (argc 1)\_s*' ..
|
||||||
'\d PCALL end\_s*' ..
|
'\d PCALL end\_s*' ..
|
||||||
@@ -1116,7 +1116,7 @@ def Test_disassemble_channel()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def WithLambda(): string
|
def s:WithLambda(): string
|
||||||
var F = (a) => "X" .. a .. "X"
|
var F = (a) => "X" .. a .. "X"
|
||||||
return F("x")
|
return F("x")
|
||||||
enddef
|
enddef
|
||||||
@@ -1149,7 +1149,7 @@ def Test_disassemble_lambda()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def LambdaWithType(): number
|
def s:LambdaWithType(): number
|
||||||
var Ref = (a: number) => a + 10
|
var Ref = (a: number) => a + 10
|
||||||
return Ref(g:value)
|
return Ref(g:value)
|
||||||
enddef
|
enddef
|
||||||
@@ -1210,7 +1210,7 @@ def Test_disassemble_nested_def_list()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def AndOr(arg: any): string
|
def s:AndOr(arg: any): string
|
||||||
if arg == 1 && arg != 2 || arg == 4
|
if arg == 1 && arg != 2 || arg == 4
|
||||||
return 'yes'
|
return 'yes'
|
||||||
endif
|
endif
|
||||||
@@ -1239,7 +1239,7 @@ def Test_disassemble_and_or()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def AndConstant(arg: any): string
|
def s:AndConstant(arg: any): string
|
||||||
if true && arg
|
if true && arg
|
||||||
return "yes"
|
return "yes"
|
||||||
endif
|
endif
|
||||||
@@ -1271,7 +1271,7 @@ def Test_disassemble_and_constant()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def ForLoop(): list<number>
|
def s:ForLoop(): list<number>
|
||||||
var res: list<number>
|
var res: list<number>
|
||||||
for i in range(3)
|
for i in range(3)
|
||||||
res->add(i)
|
res->add(i)
|
||||||
@@ -1304,7 +1304,7 @@ def Test_disassemble_for_loop()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def ForLoopEval(): string
|
def s:ForLoopEval(): string
|
||||||
var res = ""
|
var res = ""
|
||||||
for str in eval('["one", "two"]')
|
for str in eval('["one", "two"]')
|
||||||
res ..= str
|
res ..= str
|
||||||
@@ -1340,7 +1340,7 @@ def Test_disassemble_for_loop_eval()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def ForLoopUnpack()
|
def s:ForLoopUnpack()
|
||||||
for [x1, x2] in [[1, 2], [3, 4]]
|
for [x1, x2] in [[1, 2], [3, 4]]
|
||||||
echo x1 x2
|
echo x1 x2
|
||||||
endfor
|
endfor
|
||||||
@@ -1373,7 +1373,7 @@ def Test_disassemble_for_loop_unpack()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def ForLoopContinue()
|
def s:ForLoopContinue()
|
||||||
for nr in [1, 2]
|
for nr in [1, 2]
|
||||||
try
|
try
|
||||||
echo "ok"
|
echo "ok"
|
||||||
@@ -1432,7 +1432,7 @@ enddef
|
|||||||
|
|
||||||
let g:number = 42
|
let g:number = 42
|
||||||
|
|
||||||
def TypeCast()
|
def s:TypeCast()
|
||||||
var l: list<number> = [23, <number>g:number]
|
var l: list<number> = [23, <number>g:number]
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
@@ -1450,7 +1450,7 @@ def Test_disassemble_typecast()
|
|||||||
instr)
|
instr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Computing()
|
def s:Computing()
|
||||||
var nr = 3
|
var nr = 3
|
||||||
var nrres = nr + 7
|
var nrres = nr + 7
|
||||||
nrres = nr - 7
|
nrres = nr - 7
|
||||||
@@ -1525,7 +1525,7 @@ def Test_disassemble_computing()
|
|||||||
endif
|
endif
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def AddListBlob()
|
def s:AddListBlob()
|
||||||
var reslist = [1, 2] + [3, 4]
|
var reslist = [1, 2] + [3, 4]
|
||||||
var resblob = 0z1122 + 0z3344
|
var resblob = 0z1122 + 0z3344
|
||||||
enddef
|
enddef
|
||||||
@@ -1551,7 +1551,7 @@ def Test_disassemble_add_list_blob()
|
|||||||
enddef
|
enddef
|
||||||
|
|
||||||
let g:aa = 'aa'
|
let g:aa = 'aa'
|
||||||
def ConcatString(): string
|
def s:ConcatString(): string
|
||||||
var res = g:aa .. "bb"
|
var res = g:aa .. "bb"
|
||||||
return res
|
return res
|
||||||
enddef
|
enddef
|
||||||
@@ -1569,7 +1569,7 @@ def Test_disassemble_concat()
|
|||||||
assert_equal('aabb', ConcatString())
|
assert_equal('aabb', ConcatString())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def StringIndex(): string
|
def s:StringIndex(): string
|
||||||
var s = "abcd"
|
var s = "abcd"
|
||||||
var res = s[1]
|
var res = s[1]
|
||||||
return res
|
return res
|
||||||
@@ -1590,7 +1590,7 @@ def Test_disassemble_string_index()
|
|||||||
assert_equal('b', StringIndex())
|
assert_equal('b', StringIndex())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def StringSlice(): string
|
def s:StringSlice(): string
|
||||||
var s = "abcd"
|
var s = "abcd"
|
||||||
var res = s[1 : 8]
|
var res = s[1 : 8]
|
||||||
return res
|
return res
|
||||||
@@ -1612,7 +1612,7 @@ def Test_disassemble_string_slice()
|
|||||||
assert_equal('bcd', StringSlice())
|
assert_equal('bcd', StringSlice())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def ListIndex(): number
|
def s:ListIndex(): number
|
||||||
var l = [1, 2, 3]
|
var l = [1, 2, 3]
|
||||||
var res = l[1]
|
var res = l[1]
|
||||||
return res
|
return res
|
||||||
@@ -1636,7 +1636,7 @@ def Test_disassemble_list_index()
|
|||||||
assert_equal(2, ListIndex())
|
assert_equal(2, ListIndex())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def ListSlice(): list<number>
|
def s:ListSlice(): list<number>
|
||||||
var l = [1, 2, 3]
|
var l = [1, 2, 3]
|
||||||
var res = l[1 : 8]
|
var res = l[1 : 8]
|
||||||
return res
|
return res
|
||||||
@@ -1661,7 +1661,7 @@ def Test_disassemble_list_slice()
|
|||||||
assert_equal([2, 3], ListSlice())
|
assert_equal([2, 3], ListSlice())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def DictMember(): number
|
def s:DictMember(): number
|
||||||
var d = {item: 1}
|
var d = {item: 1}
|
||||||
var res = d.item
|
var res = d.item
|
||||||
res = d["item"]
|
res = d["item"]
|
||||||
@@ -1692,7 +1692,7 @@ def Test_disassemble_dict_member()
|
|||||||
enddef
|
enddef
|
||||||
|
|
||||||
let somelist = [1, 2, 3, 4, 5]
|
let somelist = [1, 2, 3, 4, 5]
|
||||||
def AnyIndex(): number
|
def s:AnyIndex(): number
|
||||||
var res = g:somelist[2]
|
var res = g:somelist[2]
|
||||||
return res
|
return res
|
||||||
enddef
|
enddef
|
||||||
@@ -1713,7 +1713,7 @@ def Test_disassemble_any_index()
|
|||||||
assert_equal(3, AnyIndex())
|
assert_equal(3, AnyIndex())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def AnySlice(): list<number>
|
def s:AnySlice(): list<number>
|
||||||
var res = g:somelist[1 : 3]
|
var res = g:somelist[1 : 3]
|
||||||
return res
|
return res
|
||||||
enddef
|
enddef
|
||||||
@@ -1735,7 +1735,7 @@ def Test_disassemble_any_slice()
|
|||||||
assert_equal([2, 3, 4], AnySlice())
|
assert_equal([2, 3, 4], AnySlice())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def NegateNumber(): number
|
def s:NegateNumber(): number
|
||||||
g:nr = 9
|
g:nr = 9
|
||||||
var plus = +g:nr
|
var plus = +g:nr
|
||||||
var minus = -g:nr
|
var minus = -g:nr
|
||||||
@@ -1761,7 +1761,7 @@ def Test_disassemble_negate_number()
|
|||||||
assert_equal(-9, NegateNumber())
|
assert_equal(-9, NegateNumber())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def InvertBool(): bool
|
def s:InvertBool(): bool
|
||||||
var flag = true
|
var flag = true
|
||||||
var invert = !flag
|
var invert = !flag
|
||||||
var res = !!flag
|
var res = !!flag
|
||||||
@@ -1786,7 +1786,7 @@ def Test_disassemble_invert_bool()
|
|||||||
assert_equal(true, InvertBool())
|
assert_equal(true, InvertBool())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def ReturnBool(): bool
|
def s:ReturnBool(): bool
|
||||||
var one = 1
|
var one = 1
|
||||||
var zero = 0
|
var zero = 0
|
||||||
var none: number
|
var none: number
|
||||||
@@ -1818,7 +1818,7 @@ def Test_disassemble_return_bool()
|
|||||||
assert_equal(true, InvertBool())
|
assert_equal(true, InvertBool())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def AutoInit()
|
def s:AutoInit()
|
||||||
var t: number
|
var t: number
|
||||||
t = 1
|
t = 1
|
||||||
t = 0
|
t = 0
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
source check.vim
|
source check.vim
|
||||||
source term_util.vim
|
source term_util.vim
|
||||||
source vim9.vim
|
import './vim9.vim' as v9
|
||||||
|
|
||||||
let s:export_script_lines =<< trim END
|
let s:export_script_lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -33,7 +33,7 @@ let s:export_script_lines =<< trim END
|
|||||||
export var AddRef = AddSome
|
export var AddRef = AddSome
|
||||||
END
|
END
|
||||||
|
|
||||||
def Undo_export_script_lines()
|
def s:Undo_export_script_lines()
|
||||||
unlet g:result
|
unlet g:result
|
||||||
unlet g:localname
|
unlet g:localname
|
||||||
enddef
|
enddef
|
||||||
@@ -411,7 +411,7 @@ def Test_import_funcref()
|
|||||||
enddef
|
enddef
|
||||||
DoTest()
|
DoTest()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
delete('Xlib.vim')
|
delete('Xlib.vim')
|
||||||
enddef
|
enddef
|
||||||
@@ -422,42 +422,42 @@ def Test_import_fails()
|
|||||||
import './Xfoo.vim' as foo
|
import './Xfoo.vim' as foo
|
||||||
foo = 'bar'
|
foo = 'bar'
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself'])
|
v9.CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself'])
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Xfoo.vim' as foo
|
import './Xfoo.vim' as foo
|
||||||
var that = foo
|
var that = foo
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1060: Expected dot after name: foo')
|
v9.CheckScriptFailure(lines, 'E1060: Expected dot after name: foo')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Xfoo.vim' as foo
|
import './Xfoo.vim' as foo
|
||||||
var that: any
|
var that: any
|
||||||
that += foo
|
that += foo
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1060: Expected dot after name: foo')
|
v9.CheckScriptFailure(lines, 'E1060: Expected dot after name: foo')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Xfoo.vim' as foo
|
import './Xfoo.vim' as foo
|
||||||
foo += 9
|
foo += 9
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1060: Expected dot after name: foo')
|
v9.CheckScriptFailure(lines, 'E1060: Expected dot after name: foo')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Xfoo.vim' as 9foo
|
import './Xfoo.vim' as 9foo
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1047:')
|
v9.CheckScriptFailure(lines, 'E1047:')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Xfoo.vim' as the#foo
|
import './Xfoo.vim' as the#foo
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1047:')
|
v9.CheckScriptFailure(lines, 'E1047:')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Xfoo.vim' as g:foo
|
import './Xfoo.vim' as g:foo
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1047:')
|
v9.CheckScriptFailure(lines, 'E1047:')
|
||||||
|
|
||||||
delete('Xfoo.vim')
|
delete('Xfoo.vim')
|
||||||
|
|
||||||
@@ -474,7 +474,7 @@ def Test_import_fails()
|
|||||||
import './Xthat.vim' as That
|
import './Xthat.vim' as That
|
||||||
That()
|
That()
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself'])
|
v9.CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself'])
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -484,13 +484,13 @@ def Test_import_fails()
|
|||||||
enddef
|
enddef
|
||||||
Func()
|
Func()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1236: Cannot use That itself')
|
v9.CheckScriptFailure(lines, 'E1236: Cannot use That itself')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
import './Xthat.vim' as one
|
import './Xthat.vim' as one
|
||||||
import './Xthat.vim' as two
|
import './Xthat.vim' as two
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1262:')
|
v9.CheckScriptFailure(lines, 'E1262:')
|
||||||
|
|
||||||
delete('Xthat.vim')
|
delete('Xthat.vim')
|
||||||
|
|
||||||
@@ -501,24 +501,24 @@ def Test_import_fails()
|
|||||||
vim9script
|
vim9script
|
||||||
import './Ximport/.vim'
|
import './Ximport/.vim'
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"')
|
v9.CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Ximport/.vim' as vim
|
import './Ximport/.vim' as vim
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
writefile(['vim9script'], 'Ximport/.vimrc')
|
writefile(['vim9script'], 'Ximport/.vimrc')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Ximport/.vimrc'
|
import './Ximport/.vimrc'
|
||||||
END
|
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
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import './Ximport/.vimrc' as vimrc
|
import './Ximport/.vimrc' as vimrc
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
delete('Ximport', 'rf')
|
delete('Ximport', 'rf')
|
||||||
enddef
|
enddef
|
||||||
@@ -626,7 +626,7 @@ def Test_use_import_in_command_completion()
|
|||||||
feedkeys(":Cmd ab\<Tab>\<C-B>#\<CR>", 'xnt')
|
feedkeys(":Cmd ab\<Tab>\<C-B>#\<CR>", 'xnt')
|
||||||
assert_equal('#Cmd abcd', @:)
|
assert_equal('#Cmd abcd', @:)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
delcommand Cmd
|
delcommand Cmd
|
||||||
delete('Xscript.vim')
|
delete('Xscript.vim')
|
||||||
@@ -665,7 +665,7 @@ def Test_use_autoload_import_in_insert_completion()
|
|||||||
assert_equal('experiment', getline(1))
|
assert_equal('experiment', getline(1))
|
||||||
assert_equal('yes', g:completion_loaded)
|
assert_equal('yes', g:completion_loaded)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
set thesaurusfunc=
|
set thesaurusfunc=
|
||||||
bwipe!
|
bwipe!
|
||||||
@@ -698,7 +698,7 @@ def Test_use_autoload_import_partial_in_opfunc()
|
|||||||
feedkeys("\<F3>l", 'xt')
|
feedkeys("\<F3>l", 'xt')
|
||||||
assert_equal('yes', g:opfunc_called)
|
assert_equal('yes', g:opfunc_called)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
set opfunc=
|
set opfunc=
|
||||||
bwipe!
|
bwipe!
|
||||||
@@ -732,7 +732,7 @@ def Test_set_opfunc_to_autoload_func_directly()
|
|||||||
feedkeys("\<F3>l", 'xt')
|
feedkeys("\<F3>l", 'xt')
|
||||||
assert_equal('yes', g:opfunc_called)
|
assert_equal('yes', g:opfunc_called)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
set opfunc=
|
set opfunc=
|
||||||
bwipe!
|
bwipe!
|
||||||
@@ -769,7 +769,7 @@ def Test_use_autoload_import_in_fold_expression()
|
|||||||
new
|
new
|
||||||
setline(1, ['# one', 'text', '# two', 'text'])
|
setline(1, ['# one', 'text', '# two', 'text'])
|
||||||
g:fold_loaded = 'no'
|
g:fold_loaded = 'no'
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
assert_equal('no', g:fold_loaded)
|
assert_equal('no', g:fold_loaded)
|
||||||
redraw
|
redraw
|
||||||
assert_equal('yes', g:fold_loaded)
|
assert_equal('yes', g:fold_loaded)
|
||||||
@@ -810,7 +810,7 @@ def Run_Test_import_in_diffexpr()
|
|||||||
set diffexpr=diff.DiffExpr()
|
set diffexpr=diff.DiffExpr()
|
||||||
set diffopt=foldcolumn:0
|
set diffopt=foldcolumn:0
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
enew!
|
enew!
|
||||||
call setline(1, ['one', 'two', 'three'])
|
call setline(1, ['one', 'two', 'three'])
|
||||||
@@ -842,7 +842,7 @@ def Test_import_in_patchexpr()
|
|||||||
import './Xpatchexpr' as patch
|
import './Xpatchexpr' as patch
|
||||||
set patchexpr=patch.TPatch()
|
set patchexpr=patch.TPatch()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
call writefile(['input file'], 'Xinput')
|
call writefile(['input file'], 'Xinput')
|
||||||
call writefile(['diff file'], 'Xdiff')
|
call writefile(['diff file'], 'Xdiff')
|
||||||
@@ -873,7 +873,7 @@ def Test_import_in_formatexpr()
|
|||||||
import './Xformatter' as format
|
import './Xformatter' as format
|
||||||
set formatexpr=format.MyFormatExpr()
|
set formatexpr=format.MyFormatExpr()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
new
|
new
|
||||||
setline(1, ['a', 'b', 'c'])
|
setline(1, ['a', 'b', 'c'])
|
||||||
@@ -903,7 +903,7 @@ def Test_import_in_includeexpr()
|
|||||||
import './Xinclude.vim'
|
import './Xinclude.vim'
|
||||||
set includeexpr=Xinclude.DoSub()
|
set includeexpr=Xinclude.DoSub()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
setline(1, ['Xthatfile'])
|
setline(1, ['Xthatfile'])
|
||||||
exe "normal \<C-W>f"
|
exe "normal \<C-W>f"
|
||||||
@@ -931,7 +931,7 @@ def Test_import_in_indentexpr()
|
|||||||
set indentexpr=indent.GetIndent()
|
set indentexpr=indent.GetIndent()
|
||||||
set debug=throw
|
set debug=throw
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
new
|
new
|
||||||
setline(1, 'hello')
|
setline(1, 'hello')
|
||||||
@@ -964,7 +964,7 @@ def Run_Test_import_in_printexpr()
|
|||||||
import './Xprint.vim'
|
import './Xprint.vim'
|
||||||
set printexpr=Xprint.PrintFile()
|
set printexpr=Xprint.PrintFile()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
help
|
help
|
||||||
hardcopy dummy args
|
hardcopy dummy args
|
||||||
@@ -991,7 +991,7 @@ def Test_import_in_charconvert()
|
|||||||
import './Xconvert.vim' as conv
|
import './Xconvert.vim' as conv
|
||||||
set charconvert=conv.MakeUpper()
|
set charconvert=conv.MakeUpper()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
writefile(['one', 'two'], 'Xfile')
|
writefile(['one', 'two'], 'Xfile')
|
||||||
new Xfile
|
new Xfile
|
||||||
@@ -1024,7 +1024,7 @@ def Run_Test_import_in_spellsuggest_expr()
|
|||||||
import './Xsuggest.vim' as sugg
|
import './Xsuggest.vim' as sugg
|
||||||
set spell spellsuggest=expr:sugg.MySuggest()
|
set spell spellsuggest=expr:sugg.MySuggest()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
set verbose=1 # report errors
|
set verbose=1 # report errors
|
||||||
call assert_equal(['Fox', 'Fop'], spellsuggest('Fo', 2))
|
call assert_equal(['Fox', 'Fop'], spellsuggest('Fo', 2))
|
||||||
@@ -1056,7 +1056,7 @@ def Test_export_shadows_global_function()
|
|||||||
import autoload 'shadow.vim'
|
import autoload 'shadow.vim'
|
||||||
assert_equal('Shadow()', shadow.Shadow())
|
assert_equal('Shadow()', shadow.Shadow())
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
delfunc g:Shadow
|
delfunc g:Shadow
|
||||||
bwipe!
|
bwipe!
|
||||||
@@ -1065,9 +1065,9 @@ def Test_export_shadows_global_function()
|
|||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_export_fails()
|
def Test_export_fails()
|
||||||
CheckScriptFailure(['export var some = 123'], 'E1042:')
|
v9.CheckScriptFailure(['export var some = 123'], 'E1042:')
|
||||||
CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:')
|
v9.CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:')
|
||||||
CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:')
|
v9.CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:')
|
||||||
|
|
||||||
assert_fails('export something', 'E1043:')
|
assert_fails('export something', 'E1043:')
|
||||||
enddef
|
enddef
|
||||||
@@ -1088,12 +1088,12 @@ def Run_Test_import_fails_on_command_line()
|
|||||||
END
|
END
|
||||||
writefile(export, 'XexportCmd.vim')
|
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})
|
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')
|
delete('XexportCmd.vim')
|
||||||
StopVimInTerminal(buf)
|
g:StopVimInTerminal(buf)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_vim9_reload_noclear()
|
def Test_vim9_reload_noclear()
|
||||||
@@ -1348,7 +1348,7 @@ def Test_vim9_funcref_other_script()
|
|||||||
enddef
|
enddef
|
||||||
TestDirect()
|
TestDirect()
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
delete('Xfilter.vim')
|
delete('Xfilter.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
@@ -1461,7 +1461,7 @@ def Test_func_overrules_import_fails()
|
|||||||
echo 'local to function'
|
echo 'local to function'
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1213: Redefining imported item "Func"')
|
v9.CheckScriptFailure(lines, 'E1213: Redefining imported item "Func"')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -1473,7 +1473,7 @@ def Test_func_overrules_import_fails()
|
|||||||
enddef
|
enddef
|
||||||
defcompile
|
defcompile
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1236:')
|
v9.CheckScriptFailure(lines, 'E1236:')
|
||||||
|
|
||||||
delete('XexportedFunc.vim')
|
delete('XexportedFunc.vim')
|
||||||
enddef
|
enddef
|
||||||
@@ -1696,10 +1696,10 @@ def Test_vim9script_autoload()
|
|||||||
assert_equal('final', prefixed.fname)
|
assert_equal('final', prefixed.fname)
|
||||||
assert_equal('const', prefixed.cname)
|
assert_equal('const', prefixed.cname)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
# can source it again, autoload script not loaded again
|
# can source it again, autoload script not loaded again
|
||||||
g:expected_loaded = 1
|
g:expected_loaded = 1
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
# can also get the items by autoload name
|
# can also get the items by autoload name
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -1709,7 +1709,7 @@ def Test_vim9script_autoload()
|
|||||||
call assert_equal('final', prefixed#fname)
|
call assert_equal('final', prefixed#fname)
|
||||||
call assert_equal('const', prefixed#cname)
|
call assert_equal('const', prefixed#cname)
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
unlet g:prefixed_loaded
|
unlet g:prefixed_loaded
|
||||||
unlet g:expected_loaded
|
unlet g:expected_loaded
|
||||||
@@ -1737,42 +1737,42 @@ def Test_import_autoload_not_exported()
|
|||||||
import autoload 'notExport1.vim'
|
import autoload 'notExport1.vim'
|
||||||
echo notExport1.notFound
|
echo notExport1.notFound
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1048: Item not found in script: notFound')
|
v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notFound')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload 'notExport1.vim'
|
import autoload 'notExport1.vim'
|
||||||
echo notExport1.notExported
|
echo notExport1.notExported
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1049: Item not exported in script: notExported')
|
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notExported')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload 'notExport1.vim'
|
import autoload 'notExport1.vim'
|
||||||
echo notExport1.NotFunc()
|
echo notExport1.NotFunc()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc')
|
v9.CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload 'notExport1.vim'
|
import autoload 'notExport1.vim'
|
||||||
echo notExport1.NotExport()
|
echo notExport1.NotExport()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1049: Item not exported in script: NotExport')
|
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: NotExport')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload 'notExport1.vim'
|
import autoload 'notExport1.vim'
|
||||||
echo 'text'->notExport1.NotFunc()
|
echo 'text'->notExport1.NotFunc()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc')
|
v9.CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload 'notExport1.vim'
|
import autoload 'notExport1.vim'
|
||||||
echo 'text'->notExport1.NotExport()
|
echo 'text'->notExport1.NotExport()
|
||||||
END
|
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
|
# using a :def function we use a different autoload script every time so that
|
||||||
# the function is compiled without the script loaded
|
# the function is compiled without the script loaded
|
||||||
@@ -1785,7 +1785,7 @@ def Test_import_autoload_not_exported()
|
|||||||
enddef
|
enddef
|
||||||
Testit()
|
Testit()
|
||||||
END
|
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')
|
writefile(exportLines, 'Xdir/autoload/notExport3.vim')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -1797,7 +1797,7 @@ def Test_import_autoload_not_exported()
|
|||||||
Testit()
|
Testit()
|
||||||
END
|
END
|
||||||
# don't get E1049 because it is too complicated to figure out
|
# 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')
|
writefile(exportLines, 'Xdir/autoload/notExport4.vim')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -1808,7 +1808,7 @@ def Test_import_autoload_not_exported()
|
|||||||
enddef
|
enddef
|
||||||
Testit()
|
Testit()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E117: Unknown function: notExport4#NotFunc')
|
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport4#NotFunc')
|
||||||
|
|
||||||
writefile(exportLines, 'Xdir/autoload/notExport5.vim')
|
writefile(exportLines, 'Xdir/autoload/notExport5.vim')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -1819,7 +1819,7 @@ def Test_import_autoload_not_exported()
|
|||||||
enddef
|
enddef
|
||||||
Testit()
|
Testit()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E117: Unknown function: notExport5#NotExport')
|
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport5#NotExport')
|
||||||
|
|
||||||
writefile(exportLines, 'Xdir/autoload/notExport6.vim')
|
writefile(exportLines, 'Xdir/autoload/notExport6.vim')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -1830,7 +1830,7 @@ def Test_import_autoload_not_exported()
|
|||||||
enddef
|
enddef
|
||||||
Testit()
|
Testit()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E117: Unknown function: notExport6#NotFunc')
|
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport6#NotFunc')
|
||||||
|
|
||||||
writefile(exportLines, 'Xdir/autoload/notExport7.vim')
|
writefile(exportLines, 'Xdir/autoload/notExport7.vim')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -1841,7 +1841,7 @@ def Test_import_autoload_not_exported()
|
|||||||
enddef
|
enddef
|
||||||
Testit()
|
Testit()
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport')
|
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport')
|
||||||
|
|
||||||
delete('Xdir', 'rf')
|
delete('Xdir', 'rf')
|
||||||
&rtp = save_rtp
|
&rtp = save_rtp
|
||||||
@@ -1880,7 +1880,7 @@ def Test_vim9script_autoload_call()
|
|||||||
|
|
||||||
assert_equal('arg', call('another.RetArg', ['arg']))
|
assert_equal('arg', call('another.RetArg', ['arg']))
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
unlet g:result
|
unlet g:result
|
||||||
delete('Xdir', 'rf')
|
delete('Xdir', 'rf')
|
||||||
@@ -2025,7 +2025,7 @@ def Test_autoload_name_wring()
|
|||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
writefile(lines, 'Xscriptname.vim')
|
writefile(lines, 'Xscriptname.vim')
|
||||||
CheckScriptFailure(lines, 'E1263:')
|
v9.CheckScriptFailure(lines, 'E1263:')
|
||||||
|
|
||||||
delete('Xscriptname.vim')
|
delete('Xscriptname.vim')
|
||||||
enddef
|
enddef
|
||||||
@@ -2056,9 +2056,9 @@ def Test_import_autoload_postponed()
|
|||||||
enddef
|
enddef
|
||||||
defcompile
|
defcompile
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
assert_false(exists('g:loaded_postponed'))
|
assert_false(exists('g:loaded_postponed'))
|
||||||
CheckScriptSuccess(lines + ['Tryit()'])
|
v9.CheckScriptSuccess(lines + ['Tryit()'])
|
||||||
assert_equal('true', g:loaded_postponed)
|
assert_equal('true', g:loaded_postponed)
|
||||||
|
|
||||||
unlet g:loaded_postponed
|
unlet g:loaded_postponed
|
||||||
@@ -2094,7 +2094,7 @@ def Test_import_autoload_override()
|
|||||||
enddef
|
enddef
|
||||||
defcompile
|
defcompile
|
||||||
END
|
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)
|
test_override('autoload', 0)
|
||||||
unlet g:loaded_override
|
unlet g:loaded_override
|
||||||
@@ -2130,7 +2130,7 @@ def Test_autoload_mapping()
|
|||||||
nnoremap <silent> xx <ScriptCmd>toggle.Doit()<CR>
|
nnoremap <silent> xx <ScriptCmd>toggle.Doit()<CR>
|
||||||
nnoremap <silent> yy <Cmd>toggle.Doit()<CR>
|
nnoremap <silent> yy <Cmd>toggle.Doit()<CR>
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
assert_false(exists("g:toggle_loaded"))
|
assert_false(exists("g:toggle_loaded"))
|
||||||
assert_false(exists("g:toggle_called"))
|
assert_false(exists("g:toggle_called"))
|
||||||
assert_match('\d A: \f*[/\\]toggle.vim', execute('scriptnames'))
|
assert_match('\d A: \f*[/\\]toggle.vim', execute('scriptnames'))
|
||||||
@@ -2159,13 +2159,13 @@ def Test_vim9script_autoload_fails()
|
|||||||
vim9script autoload
|
vim9script autoload
|
||||||
var n = 0
|
var n = 0
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E475: Invalid argument: autoload')
|
v9.CheckScriptFailure(lines, 'E475: Invalid argument: autoload')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script noclear noclear
|
vim9script noclear noclear
|
||||||
var n = 0
|
var n = 0
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E983: Duplicate argument: noclear')
|
v9.CheckScriptFailure(lines, 'E983: Duplicate argument: noclear')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_import_autoload_fails()
|
def Test_import_autoload_fails()
|
||||||
@@ -2173,25 +2173,25 @@ def Test_import_autoload_fails()
|
|||||||
vim9script
|
vim9script
|
||||||
import autoload autoload 'prefixed.vim'
|
import autoload autoload 'prefixed.vim'
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E121: Undefined variable: autoload')
|
v9.CheckScriptFailure(lines, 'E121: Undefined variable: autoload')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload './doesNotExist.vim'
|
import autoload './doesNotExist.vim'
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1264:')
|
v9.CheckScriptFailure(lines, 'E1264:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload '/dir/doesNotExist.vim'
|
import autoload '/dir/doesNotExist.vim'
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1264:')
|
v9.CheckScriptFailure(lines, 'E1264:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload 'doesNotExist.vim'
|
import autoload 'doesNotExist.vim'
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1053: Could not import "doesNotExist.vim"')
|
v9.CheckScriptFailure(lines, 'E1053: Could not import "doesNotExist.vim"')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" test disassembling an auto-loaded function starting with "debug"
|
" test disassembling an auto-loaded function starting with "debug"
|
||||||
@@ -2223,7 +2223,7 @@ def Test_vim9_autoload_disass()
|
|||||||
assert_equal('profile', profileit#test())
|
assert_equal('profile', profileit#test())
|
||||||
disass profileit#test
|
disass profileit#test
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
delete('Xdir', 'rf')
|
delete('Xdir', 'rf')
|
||||||
&rtp = save_rtp
|
&rtp = save_rtp
|
||||||
@@ -2274,7 +2274,7 @@ def Test_vim9_autoload_case_sensitive()
|
|||||||
import autoload 'CaseSensitive.vim'
|
import autoload 'CaseSensitive.vim'
|
||||||
assert_equal('done', CaseSensitive.CaseSensitive())
|
assert_equal('done', CaseSensitive.CaseSensitive())
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
if !has('fname_case')
|
if !has('fname_case')
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
@@ -2282,7 +2282,7 @@ def Test_vim9_autoload_case_sensitive()
|
|||||||
import autoload 'CaseSensitive.vim'
|
import autoload 'CaseSensitive.vim'
|
||||||
import autoload 'casesensitive.vim'
|
import autoload 'casesensitive.vim'
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1262:')
|
v9.CheckScriptFailure(lines, 'E1262:')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
delete('Xdir', 'rf')
|
delete('Xdir', 'rf')
|
||||||
@@ -2320,7 +2320,7 @@ def Test_vim9_autoload_error()
|
|||||||
qall!
|
qall!
|
||||||
END
|
END
|
||||||
writefile(lines, 'Xscript')
|
writefile(lines, 'Xscript')
|
||||||
RunVim([], [], '-S Xscript')
|
g:RunVim([], [], '-S Xscript')
|
||||||
assert_equal(['ok'], readfile('Xdidit'))
|
assert_equal(['ok'], readfile('Xdidit'))
|
||||||
|
|
||||||
delete('Xdidit')
|
delete('Xdidit')
|
||||||
@@ -2331,7 +2331,7 @@ def Test_vim9_autoload_error()
|
|||||||
vim9script
|
vim9script
|
||||||
var foo#bar = 'asdf'
|
var foo#bar = 'asdf'
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E461: Illegal variable name: foo#bar', 2)
|
v9.CheckScriptFailure(lines, 'E461: Illegal variable name: foo#bar', 2)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,12 @@
|
|||||||
" Utility functions for testing vim9 script
|
vim9script
|
||||||
|
|
||||||
" Use a different file name for each run.
|
# Utility functions for testing vim9 script
|
||||||
let s:sequence = 1
|
|
||||||
|
|
||||||
" Check that "lines" inside a ":def" function has no error when called.
|
# Use a different file name for each run.
|
||||||
func CheckDefSuccess(lines)
|
var sequence = 1
|
||||||
|
|
||||||
|
# Check that "lines" inside a ":def" function has no error when called.
|
||||||
|
export func CheckDefSuccess(lines)
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
let fname = 'XdefSuccess' .. s:sequence
|
let fname = 'XdefSuccess' .. s:sequence
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
@@ -19,8 +21,8 @@ func CheckDefSuccess(lines)
|
|||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Check that "lines" inside a ":def" function has no error when compiled.
|
# Check that "lines" inside a ":def" function has no error when compiled.
|
||||||
func CheckDefCompileSuccess(lines)
|
export func CheckDefCompileSuccess(lines)
|
||||||
let fname = 'XdefSuccess' .. s:sequence
|
let fname = 'XdefSuccess' .. s:sequence
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname)
|
call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname)
|
||||||
@@ -32,11 +34,11 @@ func CheckDefCompileSuccess(lines)
|
|||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Check that "lines" inside ":def" results in an "error" message.
|
# Check that "lines" inside ":def" results in an "error" message.
|
||||||
" If "lnum" is given check that the error is reported for this line.
|
# 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
|
# Add a line before and after to make it less likely that the line number is
|
||||||
" accidentally correct.
|
# accidentally correct.
|
||||||
func CheckDefFailure(lines, error, lnum = -3)
|
export func CheckDefFailure(lines, error, lnum = -3)
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
let fname = 'XdefFailure' .. s:sequence
|
let fname = 'XdefFailure' .. s:sequence
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
@@ -50,11 +52,11 @@ func CheckDefFailure(lines, error, lnum = -3)
|
|||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Check that "lines" inside ":def" results in an "error" message when executed.
|
# 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.
|
# 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
|
# Add a line before and after to make it less likely that the line number is
|
||||||
" accidentally correct.
|
# accidentally correct.
|
||||||
func CheckDefExecFailure(lines, error, lnum = -3)
|
export func CheckDefExecFailure(lines, error, lnum = -3)
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
let fname = 'XdefExecFailure' .. s:sequence
|
let fname = 'XdefExecFailure' .. s:sequence
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
@@ -69,7 +71,7 @@ func CheckDefExecFailure(lines, error, lnum = -3)
|
|||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
|
export def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
|
||||||
var cwd = getcwd()
|
var cwd = getcwd()
|
||||||
var fname = 'XScriptFailure' .. s:sequence
|
var fname = 'XScriptFailure' .. s:sequence
|
||||||
s:sequence += 1
|
s:sequence += 1
|
||||||
@@ -82,7 +84,7 @@ def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
|
|||||||
endtry
|
endtry
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def CheckScriptFailureList(lines: list<string>, errors: list<string>, lnum = -3)
|
export def CheckScriptFailureList(lines: list<string>, errors: list<string>, lnum = -3)
|
||||||
var cwd = getcwd()
|
var cwd = getcwd()
|
||||||
var fname = 'XScriptFailure' .. s:sequence
|
var fname = 'XScriptFailure' .. s:sequence
|
||||||
s:sequence += 1
|
s:sequence += 1
|
||||||
@@ -95,7 +97,7 @@ def CheckScriptFailureList(lines: list<string>, errors: list<string>, lnum = -3)
|
|||||||
endtry
|
endtry
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def CheckScriptSuccess(lines: list<string>)
|
export def CheckScriptSuccess(lines: list<string>)
|
||||||
var cwd = getcwd()
|
var cwd = getcwd()
|
||||||
var fname = 'XScriptSuccess' .. s:sequence
|
var fname = 'XScriptSuccess' .. s:sequence
|
||||||
s:sequence += 1
|
s:sequence += 1
|
||||||
@@ -108,17 +110,17 @@ def CheckScriptSuccess(lines: list<string>)
|
|||||||
endtry
|
endtry
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def CheckDefAndScriptSuccess(lines: list<string>)
|
export def CheckDefAndScriptSuccess(lines: list<string>)
|
||||||
CheckDefSuccess(lines)
|
CheckDefSuccess(lines)
|
||||||
CheckScriptSuccess(['vim9script'] + lines)
|
CheckScriptSuccess(['vim9script'] + lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Check that a command fails when used in a :def function and when used in
|
# Check that a command fails when used in a :def function and when used in
|
||||||
" Vim9 script.
|
# Vim9 script.
|
||||||
" When "error" is a string, both with the same error.
|
# When "error" is a string, both with the same error.
|
||||||
" When "error" is a list, the :def function fails with "error[0]" , the script
|
# When "error" is a list, the :def function fails with "error[0]" , the script
|
||||||
" fails with "error[1]".
|
# fails with "error[1]".
|
||||||
def CheckDefAndScriptFailure(lines: list<string>, error: any, lnum = -3)
|
export def CheckDefAndScriptFailure(lines: list<string>, error: any, lnum = -3)
|
||||||
var errorDef: string
|
var errorDef: string
|
||||||
var errorScript: string
|
var errorScript: string
|
||||||
if type(error) == v:t_string
|
if type(error) == v:t_string
|
||||||
@@ -135,12 +137,12 @@ def CheckDefAndScriptFailure(lines: list<string>, error: any, lnum = -3)
|
|||||||
CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1)
|
CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Check that a command fails when executed in a :def function and when used in
|
# Check that a command fails when executed in a :def function and when used in
|
||||||
" Vim9 script.
|
# Vim9 script.
|
||||||
" When "error" is a string, both with the same error.
|
# When "error" is a string, both with the same error.
|
||||||
" When "error" is a list, the :def function fails with "error[0]" , the script
|
# When "error" is a list, the :def function fails with "error[0]" , the script
|
||||||
" fails with "error[1]".
|
# fails with "error[1]".
|
||||||
def CheckDefExecAndScriptFailure(lines: list<string>, error: any, lnum = -3)
|
export def CheckDefExecAndScriptFailure(lines: list<string>, error: any, lnum = -3)
|
||||||
var errorDef: string
|
var errorDef: string
|
||||||
var errorScript: string
|
var errorScript: string
|
||||||
if type(error) == v:t_string
|
if type(error) == v:t_string
|
||||||
@@ -158,8 +160,8 @@ def CheckDefExecAndScriptFailure(lines: list<string>, error: any, lnum = -3)
|
|||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
|
||||||
" Check that "lines" inside a legacy function has no error.
|
# Check that "lines" inside a legacy function has no error.
|
||||||
func CheckLegacySuccess(lines)
|
export func CheckLegacySuccess(lines)
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
let fname = 'XlegacySuccess' .. s:sequence
|
let fname = 'XlegacySuccess' .. s:sequence
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
@@ -174,8 +176,8 @@ func CheckLegacySuccess(lines)
|
|||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Check that "lines" inside a legacy function results in the expected error
|
# Check that "lines" inside a legacy function results in the expected error
|
||||||
func CheckLegacyFailure(lines, error)
|
export func CheckLegacyFailure(lines, error)
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
let fname = 'XlegacyFails' .. s:sequence
|
let fname = 'XlegacyFails' .. s:sequence
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
@@ -189,9 +191,9 @@ func CheckLegacyFailure(lines, error)
|
|||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Execute "lines" in a legacy function, translated as in
|
# Execute "lines" in a legacy function, translated as in
|
||||||
" CheckLegacyAndVim9Success()
|
# CheckLegacyAndVim9Success()
|
||||||
def CheckTransLegacySuccess(lines: list<string>)
|
export def CheckTransLegacySuccess(lines: list<string>)
|
||||||
var legacylines = lines->mapnew((_, v) =>
|
var legacylines = lines->mapnew((_, v) =>
|
||||||
v->substitute('\<VAR\>', 'let', 'g')
|
v->substitute('\<VAR\>', 'let', 'g')
|
||||||
->substitute('\<LET\>', 'let', 'g')
|
->substitute('\<LET\>', 'let', 'g')
|
||||||
@@ -204,7 +206,7 @@ def CheckTransLegacySuccess(lines: list<string>)
|
|||||||
CheckLegacySuccess(legacylines)
|
CheckLegacySuccess(legacylines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Vim9Trans(lines: list<string>): list<string>
|
export def Vim9Trans(lines: list<string>): list<string>
|
||||||
return lines->mapnew((_, v) =>
|
return lines->mapnew((_, v) =>
|
||||||
v->substitute('\<VAR\>', 'var', 'g')
|
v->substitute('\<VAR\>', 'var', 'g')
|
||||||
->substitute('\<LET ', '', 'g')
|
->substitute('\<LET ', '', 'g')
|
||||||
@@ -215,36 +217,36 @@ def Vim9Trans(lines: list<string>): list<string>
|
|||||||
->substitute('\<FALSE\>', 'false', 'g'))
|
->substitute('\<FALSE\>', 'false', 'g'))
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Execute "lines" in a :def function, translated as in
|
# Execute "lines" in a :def function, translated as in
|
||||||
" CheckLegacyAndVim9Success()
|
# CheckLegacyAndVim9Success()
|
||||||
def CheckTransDefSuccess(lines: list<string>)
|
export def CheckTransDefSuccess(lines: list<string>)
|
||||||
CheckDefSuccess(Vim9Trans(lines))
|
CheckDefSuccess(Vim9Trans(lines))
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Execute "lines" in a Vim9 script, translated as in
|
# Execute "lines" in a Vim9 script, translated as in
|
||||||
" CheckLegacyAndVim9Success()
|
# CheckLegacyAndVim9Success()
|
||||||
def CheckTransVim9Success(lines: list<string>)
|
export def CheckTransVim9Success(lines: list<string>)
|
||||||
CheckScriptSuccess(['vim9script'] + Vim9Trans(lines))
|
CheckScriptSuccess(['vim9script'] + Vim9Trans(lines))
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Execute "lines" in a legacy function, :def function and Vim9 script.
|
# Execute "lines" in a legacy function, :def function and Vim9 script.
|
||||||
" Use 'VAR' for a declaration.
|
# Use 'VAR' for a declaration.
|
||||||
" Use 'LET' for an assignment
|
# Use 'LET' for an assignment
|
||||||
" Use ' #"' for a comment
|
# Use ' #"' for a comment
|
||||||
" Use LSTART arg LMIDDLE expr LEND for lambda
|
# Use LSTART arg LMIDDLE expr LEND for lambda
|
||||||
" Use 'TRUE' for 1 in legacy, true in Vim9
|
# Use 'TRUE' for 1 in legacy, true in Vim9
|
||||||
" Use 'FALSE' for 0 in legacy, false in Vim9
|
# Use 'FALSE' for 0 in legacy, false in Vim9
|
||||||
def CheckLegacyAndVim9Success(lines: list<string>)
|
export def CheckLegacyAndVim9Success(lines: list<string>)
|
||||||
CheckTransLegacySuccess(lines)
|
CheckTransLegacySuccess(lines)
|
||||||
CheckTransDefSuccess(lines)
|
CheckTransDefSuccess(lines)
|
||||||
CheckTransVim9Success(lines)
|
CheckTransVim9Success(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Execute "lines" in a legacy function, :def function and Vim9 script.
|
# Execute "lines" in a legacy function, :def function and Vim9 script.
|
||||||
" Use 'VAR' for a declaration.
|
# Use 'VAR' for a declaration.
|
||||||
" Use 'LET' for an assignment
|
# Use 'LET' for an assignment
|
||||||
" Use ' #"' for a comment
|
# Use ' #"' for a comment
|
||||||
def CheckLegacyAndVim9Failure(lines: list<string>, error: any)
|
export def CheckLegacyAndVim9Failure(lines: list<string>, error: any)
|
||||||
var legacyError: string
|
var legacyError: string
|
||||||
var defError: string
|
var defError: string
|
||||||
var scriptError: string
|
var scriptError: string
|
||||||
|
|||||||
@@ -3789,7 +3789,7 @@ trans_function_name(
|
|||||||
sid_buf[1] = KS_EXTRA;
|
sid_buf[1] = KS_EXTRA;
|
||||||
sid_buf[2] = (int)KE_SNR;
|
sid_buf[2] = (int)KE_SNR;
|
||||||
vim_snprintf((char *)sid_buf + 3, sizeof(sid_buf) - 3,
|
vim_snprintf((char *)sid_buf + 3, sizeof(sid_buf) - 3,
|
||||||
"%ld_", (long)current_sctx.sc_sid);
|
"%ld_", (long)lv.ll_sid);
|
||||||
name = concat_str(sid_buf, lv.ll_name);
|
name = concat_str(sid_buf, lv.ll_name);
|
||||||
}
|
}
|
||||||
*lv.ll_name_end = cc;
|
*lv.ll_name_end = cc;
|
||||||
|
|||||||
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4257,
|
||||||
/**/
|
/**/
|
||||||
4256,
|
4256,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
@@ -254,12 +254,6 @@ compile_load_scriptvar(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
si = SCRIPT_ITEM(current_sctx.sc_sid);
|
si = SCRIPT_ITEM(current_sctx.sc_sid);
|
||||||
idx = get_script_item_idx(current_sctx.sc_sid, name, 0, cctx);
|
idx = get_script_item_idx(current_sctx.sc_sid, name, 0, cctx);
|
||||||
if (idx == -1 || si->sn_version != SCRIPT_VERSION_VIM9)
|
|
||||||
{
|
|
||||||
// variable is not in sn_var_vals: old style script.
|
|
||||||
return generate_OLDSCRIPT(cctx, ISN_LOADS, name, current_sctx.sc_sid,
|
|
||||||
&t_any);
|
|
||||||
}
|
|
||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
{
|
{
|
||||||
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;
|
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;
|
||||||
@@ -344,6 +338,11 @@ compile_load_scriptvar(
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (idx == -1 || si->sn_version != SCRIPT_VERSION_VIM9)
|
||||||
|
// variable is not in sn_var_vals: old style script.
|
||||||
|
return generate_OLDSCRIPT(cctx, ISN_LOADS, name, current_sctx.sc_sid,
|
||||||
|
&t_any);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
semsg(_(e_item_not_found_str), name);
|
semsg(_(e_item_not_found_str), name);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -667,6 +666,7 @@ compile_call(
|
|||||||
ufunc_T *ufunc = NULL;
|
ufunc_T *ufunc = NULL;
|
||||||
int res = FAIL;
|
int res = FAIL;
|
||||||
int is_autoload;
|
int is_autoload;
|
||||||
|
int has_g_namespace;
|
||||||
int is_searchpair;
|
int is_searchpair;
|
||||||
imported_T *import;
|
imported_T *import;
|
||||||
|
|
||||||
@@ -783,6 +783,8 @@ compile_call(
|
|||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has_g_namespace = STRNCMP(namebuf, "g:", 2) == 0;
|
||||||
|
|
||||||
// An argument or local variable can be a function reference, this
|
// An argument or local variable can be a function reference, this
|
||||||
// overrules a function name.
|
// overrules a function name.
|
||||||
if (lookup_local(namebuf, varlen, NULL, cctx) == FAIL
|
if (lookup_local(namebuf, varlen, NULL, cctx) == FAIL
|
||||||
@@ -791,18 +793,28 @@ compile_call(
|
|||||||
// If we can find the function by name generate the right call.
|
// If we can find the function by name generate the right call.
|
||||||
// Skip global functions here, a local funcref takes precedence.
|
// Skip global functions here, a local funcref takes precedence.
|
||||||
ufunc = find_func(name, FALSE);
|
ufunc = find_func(name, FALSE);
|
||||||
if (ufunc != NULL && !func_is_global(ufunc))
|
if (ufunc != NULL)
|
||||||
|
{
|
||||||
|
if (!func_is_global(ufunc))
|
||||||
{
|
{
|
||||||
res = generate_CALL(cctx, ufunc, argcount);
|
res = generate_CALL(cctx, ufunc, argcount);
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
if (!has_g_namespace
|
||||||
|
&& vim_strchr(ufunc->uf_name, AUTOLOAD_CHAR) == NULL)
|
||||||
|
{
|
||||||
|
// A function name without g: prefix must be found locally.
|
||||||
|
semsg(_(e_unknown_function_str), namebuf);
|
||||||
|
goto theend;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the name is a variable, load it and use PCALL.
|
// If the name is a variable, load it and use PCALL.
|
||||||
// Not for g:Func(), we don't know if it is a variable or not.
|
// Not for g:Func(), we don't know if it is a variable or not.
|
||||||
// Not for eome#Func(), it will be loaded later.
|
// Not for eome#Func(), it will be loaded later.
|
||||||
p = namebuf;
|
p = namebuf;
|
||||||
if (STRNCMP(namebuf, "g:", 2) != 0 && !is_autoload
|
if (!has_g_namespace && !is_autoload
|
||||||
&& compile_load(&p, namebuf + varlen, cctx, FALSE, FALSE) == OK)
|
&& compile_load(&p, namebuf + varlen, cctx, FALSE, FALSE) == OK)
|
||||||
{
|
{
|
||||||
type_T *type = get_type_on_stack(cctx, 0);
|
type_T *type = get_type_on_stack(cctx, 0);
|
||||||
@@ -820,7 +832,7 @@ compile_call(
|
|||||||
|
|
||||||
// A global function may be defined only later. Need to figure out at
|
// A global function may be defined only later. Need to figure out at
|
||||||
// runtime. Also handles a FuncRef at runtime.
|
// runtime. Also handles a FuncRef at runtime.
|
||||||
if (STRNCMP(namebuf, "g:", 2) == 0 || is_autoload)
|
if (has_g_namespace || is_autoload)
|
||||||
res = generate_UCALL(cctx, name, argcount);
|
res = generate_UCALL(cctx, name, argcount);
|
||||||
else
|
else
|
||||||
semsg(_(e_unknown_function_str), namebuf);
|
semsg(_(e_unknown_function_str), namebuf);
|
||||||
|
|||||||
Reference in New Issue
Block a user