Patch 8.2.4085

5 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 13, 2022, 3:52:30 PM1/13/22
to vim...@googlegroups.com

Patch 8.2.4085
Problem: Vim9: no test for using import in legacy script.
Solution: Add a test.
Files: src/testdir/test_vim9_import.vim


*** ../vim-8.2.4084/src/testdir/test_vim9_import.vim 2022-01-13 20:18:52.704340964 +0000
--- src/testdir/test_vim9_import.vim 2022-01-13 20:47:41.402778425 +0000
***************
*** 1006,1021 ****
call assert_false(exists('s:exported'))
call assert_equal('global', global)
call assert_equal('global', g:global)
-
- "" imported variable becomes script-local
- "import exported from './Xvim9_script.vim'
- "call assert_equal('exported', s:exported)
- "call assert_false(exists('exported'))
-
- "" imported function becomes script-local
- "import GetText from './Xvim9_script.vim'
- "call assert_equal('text', s:GetText())
- "call assert_false(exists('*GetText'))
END
writefile(legacy_lines, 'Xlegacy_script.vim')

--- 1006,1011 ----
***************
*** 1027,1032 ****
--- 1017,1060 ----
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
+
+ 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 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')
+
+ source Xlegacy_script.vim
+ assert_equal('global', g:global)
+ unlet g:global
+
+ delete('Xlegacy_script.vim')
+ delete('Xvim9_export.vim')
+ enddef
+
def Test_cmdline_win()
# if the Vim syntax highlighting uses Vim9 constructs they can be used from
# the command line window.
*** ../vim-8.2.4084/src/version.c 2022-01-13 20:39:38.106029407 +0000
--- src/version.c 2022-01-13 20:49:07.654835651 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4085,
/**/

--
You were lucky. We lived for three months in a brown paper bag in a
septic tank. We used to have to get up at six o'clock in the morning,
clean the bag, eat a crust of stale bread, go to work down mill for
fourteen hours a day week in-week out. When we got home, our Dad
would thrash us to sleep with his belt!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages