diff src/testdir/test_vim9_import.vim @ 30819:d50d32026617 v9.0.0744

patch 9.0.0744: in script in autoload dir exported variable is not found Commit: https://github.com/vim/vim/commit/6c4d4a64449ea225b1a568f5517e309b2054b490 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 13 17:47:42 2022 +0100 patch 9.0.0744: in script in autoload dir exported variable is not found Problem: In script in autoload dir exported variable is not found. (Doug Kearns) Solution: Find the variable with the "script#" prefix. (closes #11361)
author Bram Moolenaar <Bram@vim.org>
date Thu, 13 Oct 2022 19:00:06 +0200
parents 12e6c7bae2a9
children b4b51e01dd36
line wrap: on
line diff
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -1218,6 +1218,26 @@ def Test_autoload_import_deleted()
   delete('Xa.vim')
 enddef
 
+def Test_autoload_import_using_const()
+  mkdir('Xdir/autoload', 'pR')
+  var lines =<< trim END
+      vim9script
+      export const FOO = 42
+      echomsg FOO
+  END
+  writefile(lines, 'Xdir/autoload/exp.vim')
+
+  var save_rtp = &rtp
+  exe 'set rtp^=' .. getcwd() .. '/Xdir'
+  lines =<< trim END
+      vim9script
+      import autoload 'exp.vim'
+      assert_equal(42, exp.FOO)
+  END
+  v9.CheckScriptSuccess(lines)
+  &rtp = save_rtp
+enddef
+
 func Test_import_in_diffexpr()
   CheckExecutable diff
 
@@ -2570,7 +2590,7 @@ def Test_vim9script_autoload_duplicate()
      enddef
   END
   writefile(lines, 'Xdupdir/autoload/dup4func.vim')
-  assert_fails('source Xdupdir/autoload/dup4func.vim', 'E707:')
+  assert_fails('source Xdupdir/autoload/dup4func.vim', 'E1041:')
 
   lines =<< trim END
      vim9script