diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-23 13:44:35 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-23 13:44:35 +0000 |
commit | 7ef4a2fe3736bbeb5bad182782a74576aa06b0db (patch) | |
tree | 082731e347d8841572fb8644dacd03506180984b /src/testdir/test_vim9_import.vim | |
parent | e15ebeffb35da4bb7d9054358671735ce6988c28 (diff) |
patch 8.2.4192: cannot use an import in 'printexpr'v8.2.4192
Problem: Cannot use an import in 'printexpr'.
Solution: Set the script context when evaluating 'printexpr'.
Diffstat (limited to 'src/testdir/test_vim9_import.vim')
-rw-r--r-- | src/testdir/test_vim9_import.vim | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 19379a01aa..482e759d11 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -874,6 +874,37 @@ def Test_import_in_indentexpr() delete('Xindenter') enddef +func Test_import_in_printexpr() + CheckFeature postscript + call Run_Test_import_in_printexpr() +endfunc + +def Run_Test_import_in_printexpr() + var lines =<< trim END + vim9script + export def PrintFile(): bool + g:printed = 'yes' + delete('v:fname_in') + return false + enddef + END + writefile(lines, 'Xprint.vim') + + lines =<< trim END + vim9script + import './Xprint.vim' + set printexpr=Xprint.PrintFile() + END + CheckScriptSuccess(lines) + + help + hardcopy dummy args + assert_equal('yes', g:printed) + + delete('Xprint.vim') + set printexpr= +enddef + def Test_export_fails() CheckScriptFailure(['export var some = 123'], 'E1042:') CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') |