diff src/testdir/test_vim9_script.vim @ 20538:9f921ba86d05 v8.2.0823

patch 8.2.0823: Vim9: script reload test is disabled Commit: https://github.com/vim/vim/commit/25e0f5863e9010a75a1ff0d04e8f886403968755 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 25 22:36:50 2020 +0200 patch 8.2.0823: Vim9: script reload test is disabled Problem: Vim9: script reload test is disabled. Solution: Compile a function in the context of the script where it was defined. Set execution stack for compiled function. Add a test that an error is reported for the right file/function.
author Bram Moolenaar <Bram@vim.org>
date Mon, 25 May 2020 22:45:03 +0200
parents 489cb75c76b6
children 9faab49c880f
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -745,9 +745,6 @@ def Test_vim9script_fails()
 enddef
 
 def Test_vim9script_reload_import()
-  " TODO: make it work to compile when not in the script context anymore
-  return
-
   let lines =<< trim END
     vim9script
     const var = ''
@@ -797,9 +794,6 @@ def Test_vim9script_reload_import()
 enddef
 
 def Test_vim9script_reload_delfunc()
-  " TODO: make it work to compile when not in the script context anymore
-  return
-
   let first_lines =<< trim END
     vim9script
     def FuncYes(): string
@@ -920,6 +914,37 @@ def Test_import_rtp()
   delete('import', 'rf')
 enddef
 
+def Test_import_compile_error()
+  let export_lines = [
+        'vim9script',
+        'export def ExpFunc(): string',
+        '  return notDefined',
+        'enddef',
+        ]
+  writefile(export_lines, 'Xexported.vim')
+
+  let import_lines = [
+        'vim9script',
+        'import ExpFunc from "./Xexported.vim"',
+        'def ImpFunc()',
+        '  echo ExpFunc()',
+        'enddef',
+        'defcompile',
+        ]
+  writefile(import_lines, 'Ximport.vim')
+
+  try
+    source Ximport.vim
+  catch /E1001/
+    " Error should be fore the Xexported.vim file.
+    assert_match('E1001: variable not found: notDefined', v:exception)
+    assert_match('function <SNR>\d\+_ImpFunc\[1\]..<SNR>\d\+_ExpFunc, line 1', v:throwpoint)
+  endtry
+
+  delete('Xexported.vim')
+  delete('Ximport.vim')
+enddef
+
 def Test_fixed_size_list()
   " will be allocated as one piece of memory, check that changes work
   let l = [1, 2, 3, 4]