comparison 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
comparison
equal deleted inserted replaced
20537:cceaa5ec43aa 20538:9f921ba86d05
743 assert_fails('vim9script', 'E1038') 743 assert_fails('vim9script', 'E1038')
744 assert_fails('export something', 'E1043') 744 assert_fails('export something', 'E1043')
745 enddef 745 enddef
746 746
747 def Test_vim9script_reload_import() 747 def Test_vim9script_reload_import()
748 " TODO: make it work to compile when not in the script context anymore
749 return
750
751 let lines =<< trim END 748 let lines =<< trim END
752 vim9script 749 vim9script
753 const var = '' 750 const var = ''
754 let valone = 1234 751 let valone = 1234
755 def MyFunc(arg: string) 752 def MyFunc(arg: string)
795 delete('Xreload.vim') 792 delete('Xreload.vim')
796 delete('Ximport.vim') 793 delete('Ximport.vim')
797 enddef 794 enddef
798 795
799 def Test_vim9script_reload_delfunc() 796 def Test_vim9script_reload_delfunc()
800 " TODO: make it work to compile when not in the script context anymore
801 return
802
803 let first_lines =<< trim END 797 let first_lines =<< trim END
804 vim9script 798 vim9script
805 def FuncYes(): string 799 def FuncYes(): string
806 return 'yes' 800 return 'yes'
807 enddef 801 enddef
916 assert_equal(9876, g:imported_rtp) 910 assert_equal(9876, g:imported_rtp)
917 unlet g:imported_rtp 911 unlet g:imported_rtp
918 912
919 delete('Ximport_rtp.vim') 913 delete('Ximport_rtp.vim')
920 delete('import', 'rf') 914 delete('import', 'rf')
915 enddef
916
917 def Test_import_compile_error()
918 let export_lines = [
919 'vim9script',
920 'export def ExpFunc(): string',
921 ' return notDefined',
922 'enddef',
923 ]
924 writefile(export_lines, 'Xexported.vim')
925
926 let import_lines = [
927 'vim9script',
928 'import ExpFunc from "./Xexported.vim"',
929 'def ImpFunc()',
930 ' echo ExpFunc()',
931 'enddef',
932 'defcompile',
933 ]
934 writefile(import_lines, 'Ximport.vim')
935
936 try
937 source Ximport.vim
938 catch /E1001/
939 " Error should be fore the Xexported.vim file.
940 assert_match('E1001: variable not found: notDefined', v:exception)
941 assert_match('function <SNR>\d\+_ImpFunc\[1\]..<SNR>\d\+_ExpFunc, line 1', v:throwpoint)
942 endtry
943
944 delete('Xexported.vim')
945 delete('Ximport.vim')
921 enddef 946 enddef
922 947
923 def Test_fixed_size_list() 948 def Test_fixed_size_list()
924 " will be allocated as one piece of memory, check that changes work 949 " will be allocated as one piece of memory, check that changes work
925 let l = [1, 2, 3, 4] 950 let l = [1, 2, 3, 4]