mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.4678: Vim9: not all code is tested
Problem: Vim9: not all code is tested. Solution: Add a few more tests.
This commit is contained in:
@@ -1538,6 +1538,14 @@ def Test_lockvar()
|
|||||||
d.a = 7
|
d.a = 7
|
||||||
assert_equal({a: 7, b: 5}, d)
|
assert_equal({a: 7, b: 5}, d)
|
||||||
|
|
||||||
|
caught = false
|
||||||
|
try
|
||||||
|
lockvar d.c
|
||||||
|
catch /E716/
|
||||||
|
caught = true
|
||||||
|
endtry
|
||||||
|
assert_true(caught)
|
||||||
|
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
g:bl = 0z1122
|
g:bl = 0z1122
|
||||||
|
@@ -858,6 +858,8 @@ def Test_autoload_import_relative()
|
|||||||
writefile(lines, 'XimportRel.vim')
|
writefile(lines, 'XimportRel.vim')
|
||||||
writefile(lines, 'XimportRel2.vim')
|
writefile(lines, 'XimportRel2.vim')
|
||||||
writefile(lines, 'XimportRel3.vim')
|
writefile(lines, 'XimportRel3.vim')
|
||||||
|
writefile(lines, 'XimportRel4.vim')
|
||||||
|
writefile(lines, 'XimportRel5.vim')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -928,17 +930,18 @@ def Test_autoload_import_relative()
|
|||||||
END
|
END
|
||||||
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)
|
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)
|
||||||
|
|
||||||
|
# Same, script not imported before
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import autoload './XimportRel.vim'
|
import autoload './XimportRel4.vim'
|
||||||
def Func()
|
def Func()
|
||||||
XimportRel.notexp = 'bad'
|
echo XimportRel4.notexp
|
||||||
enddef
|
enddef
|
||||||
Func()
|
Func()
|
||||||
END
|
END
|
||||||
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)
|
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)
|
||||||
|
|
||||||
# does not fail if the script wasn't loaded yet
|
# does not fail if the script wasn't loaded yet and only compiling
|
||||||
g:loaded = 'no'
|
g:loaded = 'no'
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -951,6 +954,16 @@ def Test_autoload_import_relative()
|
|||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
assert_equal('no', g:loaded)
|
assert_equal('no', g:loaded)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
import autoload './XimportRel.vim'
|
||||||
|
def Func()
|
||||||
|
XimportRel.notexp = 'bad'
|
||||||
|
enddef
|
||||||
|
Func()
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E1049: Item not exported in script: notexp', 1)
|
||||||
|
|
||||||
# fails with a not loaded import
|
# fails with a not loaded import
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
@@ -964,9 +977,37 @@ def Test_autoload_import_relative()
|
|||||||
assert_equal('yes', g:loaded)
|
assert_equal('yes', g:loaded)
|
||||||
unlet g:loaded
|
unlet g:loaded
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
import autoload './XimportRel5.vim'
|
||||||
|
def Func()
|
||||||
|
XimportRel5.nosuchvar = 'bad'
|
||||||
|
enddef
|
||||||
|
Func()
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E121: Undefined variable: nosuchvar', 1)
|
||||||
|
unlet g:loaded
|
||||||
|
|
||||||
|
# nasty: delete script after compiling function
|
||||||
|
writefile(['vim9script'], 'XimportRelDel.vim')
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
import autoload './XimportRelDel.vim'
|
||||||
|
def DoIt()
|
||||||
|
echo XimportRelDel.var
|
||||||
|
enddef
|
||||||
|
defcompile
|
||||||
|
delete('XimportRelDel.vim')
|
||||||
|
DoIt()
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E456:')
|
||||||
|
|
||||||
delete('XimportRel.vim')
|
delete('XimportRel.vim')
|
||||||
delete('XimportRel2.vim')
|
delete('XimportRel2.vim')
|
||||||
delete('XimportRel3.vim')
|
delete('XimportRel3.vim')
|
||||||
|
delete('XimportRel4.vim')
|
||||||
|
delete('XimportRel5.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_autoload_import_relative_autoload_dir()
|
def Test_autoload_import_relative_autoload_dir()
|
||||||
@@ -1576,10 +1617,10 @@ def Test_script_reload_from_function()
|
|||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
|
||||||
if exists('g:loaded')
|
if exists('g:loadedThis')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
g:loaded = 1
|
g:loadedThis = 1
|
||||||
delcommand CallFunc
|
delcommand CallFunc
|
||||||
command CallFunc Func()
|
command CallFunc Func()
|
||||||
def Func()
|
def Func()
|
||||||
@@ -1594,7 +1635,7 @@ def Test_script_reload_from_function()
|
|||||||
|
|
||||||
delete('XreloadFunc.vim')
|
delete('XreloadFunc.vim')
|
||||||
delcommand CallFunc
|
delcommand CallFunc
|
||||||
unlet g:loaded
|
unlet g:loadedThis
|
||||||
unlet g:didTheFunc
|
unlet g:didTheFunc
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
@@ -2130,6 +2130,17 @@ def Test_for_loop()
|
|||||||
endfor
|
endfor
|
||||||
assert_equal('', res)
|
assert_equal('', res)
|
||||||
|
|
||||||
|
total = 0
|
||||||
|
for c in null_list
|
||||||
|
total += 1
|
||||||
|
endfor
|
||||||
|
assert_equal(0, total)
|
||||||
|
|
||||||
|
for c in null_blob
|
||||||
|
total += 1
|
||||||
|
endfor
|
||||||
|
assert_equal(0, total)
|
||||||
|
|
||||||
var foo: list<dict<any>> = [
|
var foo: list<dict<any>> = [
|
||||||
{a: 'Cat'}
|
{a: 'Cat'}
|
||||||
]
|
]
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
4678,
|
||||||
/**/
|
/**/
|
||||||
4677,
|
4677,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2636,9 +2636,12 @@ exec_instructions(ectx_T *ectx)
|
|||||||
SOURCING_LNUM = iptr->isn_lnum;
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
if (do_source(si->sn_name, FALSE, DOSO_NONE, NULL)
|
if (do_source(si->sn_name, FALSE, DOSO_NONE, NULL)
|
||||||
== FAIL)
|
== FAIL)
|
||||||
|
{
|
||||||
|
semsg(_(e_cant_open_file_str_2), si->sn_name);
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// execute :substitute with an expression
|
// execute :substitute with an expression
|
||||||
|
Reference in New Issue
Block a user