diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-07-18 18:21:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-18 18:21:38 +0200 |
commit | 4db572eeb2b42819268e934e76c67163316d873f (patch) | |
tree | 7c7b632b8808211dcaecb968090f31aac4e2b13a /src/testdir | |
parent | ad2d4969e1616d3a0354c181e3a09271d5433b3d (diff) |
patch 8.2.3178: Vim9: the file name of an :import cannot be an expressionv8.2.3178
Problem: Vim9: the file name of an :import cannot be an expression.
Solution: Accept an expression that results in a string. Do not support
:import in a function.
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_vim9_script.vim | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 592da6d0f9..9baa1ff5aa 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -1085,7 +1085,9 @@ def Test_vim9_import_export() enddef g:funcref_result = GetExported() - import {exp_name} from './Xexport.vim' + var dir = './' + var ext = ".vim" + import {exp_name} from dir .. 'Xexport' .. ext g:imported_name = exp_name exp_name ..= ' Doe' g:imported_name_appended = exp_name @@ -1148,26 +1150,6 @@ def Test_vim9_import_export() unlet g:imported_func delete('Ximport_lbr.vim') - # import inside :def function - var import_in_def_lines =<< trim END - vim9script - def ImportInDef() - import exported from './Xexport.vim' - g:imported = exported - exported += 7 - g:imported_added = exported - enddef - ImportInDef() - END - writefile(import_in_def_lines, 'Ximport2.vim') - source Ximport2.vim - # TODO: this should be 9879 - assert_equal(9876, g:imported) - assert_equal(9883, g:imported_added) - unlet g:imported - unlet g:imported_added - delete('Ximport2.vim') - var import_star_as_lines =<< trim END vim9script import * as Export from './Xexport.vim' @@ -1181,8 +1163,9 @@ def Test_vim9_import_export() END writefile(import_star_as_lines, 'Ximport.vim') source Ximport.vim - assert_equal(9883, g:imported_def) - assert_equal(9883, g:imported_script) + # FIXME: this should be 9881 + assert_equal(9876, g:imported_def) + assert_equal(9876, g:imported_script) var import_star_as_lines_no_dot =<< trim END vim9script @@ -1257,7 +1240,7 @@ def Test_vim9_import_export() END writefile(import_star_as_lbr_lines, 'Ximport.vim') source Ximport.vim - assert_equal(9883, g:imported) + assert_equal(9876, g:imported) var import_star_lines =<< trim END vim9script @@ -1345,7 +1328,7 @@ def Test_vim9_import_export() import name from Xexport.vim END writefile(import_invalid_string_lines, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1071:', '', 2, 'Ximport.vim') + assert_fails('source Ximport.vim', 'E121:', '', 2, 'Ximport.vim') var import_wrong_name_lines =<< trim END vim9script @@ -1659,22 +1642,6 @@ def Test_vim9script_reload_import() source Xreload.vim source Xreload.vim - var testlines =<< trim END - vim9script - def TheFunc() - import GetValtwo from './Xreload.vim' - assert_equal(222, GetValtwo()) - enddef - TheFunc() - END - writefile(testlines, 'Ximport.vim') - source Ximport.vim - - # Test that when not using "morelines" GetValtwo() and valtwo are still - # defined, because import doesn't reload a script. - writefile(lines, 'Xreload.vim') - source Ximport.vim - # cannot declare a var twice lines =<< trim END vim9script |