summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-13 20:51:56 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-13 20:51:56 +0000
commitc43e6235c7b3e64f81c6a4e294e4e47abf7a869a (patch)
treef19a22ab8f2ebf95d5593ebd7978ad81d91cecde /src
parent130f65d46bca94535d30cef518a6184613fb7ebf (diff)
downloadvim-git-c43e6235c7b3e64f81c6a4e294e4e47abf7a869a.tar.gz
patch 8.2.4085: Vim9: no test for using import in legacy scriptv8.2.4085
Problem: Vim9: no test for using import in legacy script. Solution: Add a test.
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_vim9_import.vim46
-rw-r--r--src/version.c2
2 files changed, 39 insertions, 9 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index 24aa28da2..553ef8fdc 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -1006,16 +1006,44 @@ def Test_source_vim9_from_legacy()
call assert_false(exists('s:exported'))
call assert_equal('global', global)
call assert_equal('global', g:global)
+ END
+ writefile(legacy_lines, 'Xlegacy_script.vim')
+
+ source Xlegacy_script.vim
+ assert_equal('global', g:global)
+ unlet g:global
+
+ delete('Xlegacy_script.vim')
+ delete('Xvim9_script.vim')
+enddef
+
+def Test_import_vim9_from_legacy()
+ var vim9_lines =<< trim END
+ vim9script
+ var local = 'local'
+ g:global = 'global'
+ export var exported = 'exported'
+ export def GetText(): string
+ return 'text'
+ enddef
+ END
+ writefile(vim9_lines, 'Xvim9_export.vim')
+
+ var legacy_lines =<< trim END
+ import './Xvim9_export.vim' as vim9
- "" imported variable becomes script-local
- "import exported from './Xvim9_script.vim'
- "call assert_equal('exported', s:exported)
- "call assert_false(exists('exported'))
+ call assert_false(exists('vim9'))
+ call assert_false(exists('local'))
+ call assert_false(exists('s:vim9.local'))
+ call assert_equal('global', global)
+ call assert_equal('global', g:global)
+ call assert_false(exists('exported'))
+ call assert_false(exists('s:exported'))
+ call assert_false(exists('*GetText'))
- "" imported function becomes script-local
- "import GetText from './Xvim9_script.vim'
- "call assert_equal('text', s:GetText())
- "call assert_false(exists('*GetText'))
+ " imported symbol is script-local
+ call assert_equal('exported', s:vim9.exported)
+ call assert_equal('text', s:vim9.GetText())
END
writefile(legacy_lines, 'Xlegacy_script.vim')
@@ -1024,7 +1052,7 @@ def Test_source_vim9_from_legacy()
unlet g:global
delete('Xlegacy_script.vim')
- delete('Xvim9_script.vim')
+ delete('Xvim9_export.vim')
enddef
def Test_cmdline_win()
diff --git a/src/version.c b/src/version.c
index 957ccee0c..557230313 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4085,
+/**/
4084,
/**/
4083,