Mercurial > vim
diff src/testdir/test_vim9_import.vim @ 27116:5b267700e6ab v8.2.4087
patch 8.2.4087: cannot test items from an autoload script easily
Commit: https://github.com/vim/vim/commit/3e4fa3d7d37162cd08fc0c6e83f52fd323f63eba
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 13 22:05:09 2022 +0000
patch 8.2.4087: cannot test items from an autoload script easily
Problem: Cannot test items from an autoload script easily.
Solution: Add the "autoload" value for test_override().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 13 Jan 2022 23:15:03 +0100 |
parents | 60df9f2679a6 |
children | a9eeb18e749c |
line wrap: on
line diff
--- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -1288,6 +1288,42 @@ def Test_import_autoload_postponed() &rtp = save_rtp enddef +def Test_import_autoload_override() + mkdir('Xdir/autoload', 'p') + var save_rtp = &rtp + exe 'set rtp^=' .. getcwd() .. '/Xdir' + test_override('autoload', 1) + + var lines =<< trim END + vim9script autoload + + g:loaded_override = 'true' + export var variable = 'bla' + export def Function(): string + return 'bla' + enddef + END + writefile(lines, 'Xdir/autoload/override.vim') + + lines =<< trim END + vim9script + + import autoload 'override.vim' + assert_equal('true', g:loaded_override) + + def Tryit() + echo override.doesNotExist + enddef + defcompile + END + CheckScriptFailure(lines, 'E1048: Item not found in script: doesNotExist', 1) + + test_override('autoload', 0) + unlet g:loaded_override + delete('Xdir', 'rf') + &rtp = save_rtp +enddef + def Test_autoload_mapping() mkdir('Xdir/autoload', 'p') var save_rtp = &rtp