Mercurial > vim
comparison src/testdir/test_vim9_import.vim @ 27086:1e2a6c6c7e42 v8.2.4072
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Commit: https://github.com/vim/vim/commit/d041f4208b0a2149e9d41f6443aa1c14c076a411
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 12 19:54:00 2022 +0000
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Problem: Vim9: compiling function fails when autoload script is not loaded
yet.
Solution: Depend on runtime loading.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 12 Jan 2022 21:00:05 +0100 |
parents | 9897dd3c6530 |
children | d7e6b85dd89d |
comparison
equal
deleted
inserted
replaced
27085:40b273e28f26 | 27086:1e2a6c6c7e42 |
---|---|
1216 unlet g:result | 1216 unlet g:result |
1217 delete('Xdir', 'rf') | 1217 delete('Xdir', 'rf') |
1218 &rtp = save_rtp | 1218 &rtp = save_rtp |
1219 enddef | 1219 enddef |
1220 | 1220 |
1221 def Test_import_autoload_postponed() | |
1222 mkdir('Xdir/autoload', 'p') | |
1223 var save_rtp = &rtp | |
1224 exe 'set rtp^=' .. getcwd() .. '/Xdir' | |
1225 | |
1226 var lines =<< trim END | |
1227 vim9script autoload | |
1228 | |
1229 g:loaded_postponed = 'true' | |
1230 export var variable = 'bla' | |
1231 export def Function(): string | |
1232 return 'bla' | |
1233 enddef | |
1234 END | |
1235 writefile(lines, 'Xdir/autoload/postponed.vim') | |
1236 | |
1237 lines =<< trim END | |
1238 vim9script | |
1239 | |
1240 import autoload 'postponed.vim' | |
1241 def Tryit() | |
1242 echo postponed.variable | |
1243 echo postponed.Function() | |
1244 enddef | |
1245 defcompile | |
1246 END | |
1247 CheckScriptSuccess(lines) | |
1248 assert_false(exists('g:loaded_postponed')) | |
1249 CheckScriptSuccess(lines + ['Tryit()']) | |
1250 assert_equal('true', g:loaded_postponed) | |
1251 | |
1252 unlet g:loaded_postponed | |
1253 delete('Xdir', 'rf') | |
1254 &rtp = save_rtp | |
1255 enddef | |
1256 | |
1221 def Test_autoload_mapping() | 1257 def Test_autoload_mapping() |
1222 mkdir('Xdir/autoload', 'p') | 1258 mkdir('Xdir/autoload', 'p') |
1223 var save_rtp = &rtp | 1259 var save_rtp = &rtp |
1224 exe 'set rtp^=' .. getcwd() .. '/Xdir' | 1260 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
1225 | 1261 |