diff options
Diffstat (limited to 'src/testdir/test_vim9_import.vim')
-rw-r--r-- | src/testdir/test_vim9_import.vim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index fa1aeb10e8..8d68f1e47e 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -2054,6 +2054,13 @@ def Test_import_vim9_from_legacy() export def GetText(): string return 'text' enddef + export var exported_nr: number = 22 + def AddNum(n: number) + exported_nr += n + enddef + export var exportedDict: dict<func> = {Fn: AddNum} + export const CONST = 10 + export final finalVar = 'abc' END writefile(vim9_lines, 'Xvim9_export.vim', 'D') @@ -2072,6 +2079,13 @@ def Test_import_vim9_from_legacy() " imported symbol is script-local call assert_equal('exported', s:vim9.exported) call assert_equal('text', s:vim9.GetText()) + call s:vim9.exportedDict.Fn(5) + call assert_equal(27, s:vim9.exported_nr) + call call(s:vim9.exportedDict.Fn, [3]) + call assert_equal(30, s:vim9.exported_nr) + call assert_fails('let s:vim9.CONST = 20', 'E46: Cannot change read-only variable "CONST"') + call assert_fails('let s:vim9.finalVar = ""', 'E46: Cannot change read-only variable "finalVar"') + call assert_fails('let s:vim9.non_existing_var = 20', 'E1048: Item not found in script: non_existing_var') END writefile(legacy_lines, 'Xlegacy_script.vim', 'D') |