Mercurial > vim
diff src/testdir/test_vim9_import.vim @ 27074:19fefc42a063 v8.2.4066
patch 8.2.4066: Vim9: imported autoload script loaded again
Commit: https://github.com/vim/vim/commit/17d36cbcd36d944c744ef68afa971718959b2111
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 12 11:46:40 2022 +0000
patch 8.2.4066: Vim9: imported autoload script loaded again
Problem: Vim9: imported autoload script loaded again.
Solution: Do not create a new imported_T every time.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 12 Jan 2022 13:00:06 +0100 |
parents | 6a4fc2e6e6eb |
children | ceff6a546748 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -1140,7 +1140,7 @@ def Test_vim9script_autoload() # when using "vim9script autoload" prefix is not needed var lines =<< trim END vim9script autoload - g:prefixed_loaded = 'yes' + g:prefixed_loaded += 1 export def Gettest(): string return 'test' @@ -1156,12 +1156,14 @@ def Test_vim9script_autoload() END writefile(lines, 'Xdir/autoload/prefixed.vim') + g:prefixed_loaded = 0 + g:expected_loaded = 0 lines =<< trim END vim9script import autoload 'prefixed.vim' - assert_false(exists('g:prefixed_loaded')) + assert_equal(g:expected_loaded, g:prefixed_loaded) assert_equal('test', prefixed.Gettest()) - assert_equal('yes', g:prefixed_loaded) + assert_equal(1, g:prefixed_loaded) assert_equal('testmore', prefixed.GetMore()) assert_equal('name', prefixed.name) @@ -1169,6 +1171,9 @@ def Test_vim9script_autoload() assert_equal('const', prefixed.cname) END CheckScriptSuccess(lines) + # can source it again, autoload script not loaded again + g:expected_loaded = 1 + CheckScriptSuccess(lines) # can also get the items by autoload name lines =<< trim END