Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 20347:0e1dfff4f294 v8.2.0729
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Commit: https://github.com/vim/vim/commit/89483d40438830fb9e74a5ec6c92d2470b05e4c2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 10 15:24:44 2020 +0200
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Problem: Vim9: When reloading a script variables are not cleared.
Solution: When sourcing a script again clear all script-local variables.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 10 May 2020 15:30:03 +0200 |
parents | ff4ae3f09307 |
children | e29b2ec8d4d2 |
comparison
equal
deleted
inserted
replaced
20346:cd52b48baba5 | 20347:0e1dfff4f294 |
---|---|
608 assert_fails('source Ximport.vim', 'E1048:') | 608 assert_fails('source Ximport.vim', 'E1048:') |
609 | 609 |
610 let import_star_lines =<< trim END | 610 let import_star_lines =<< trim END |
611 vim9script | 611 vim9script |
612 import * from './Xexport.vim' | 612 import * from './Xexport.vim' |
613 g:imported = exported | |
614 END | 613 END |
615 writefile(import_star_lines, 'Ximport.vim') | 614 writefile(import_star_lines, 'Ximport.vim') |
616 assert_fails('source Ximport.vim', 'E1045:') | 615 assert_fails('source Ximport.vim', 'E1045:') |
617 | 616 |
618 " try to import something that exists but is not exported | 617 " try to import something that exists but is not exported |
803 writefile(first_lines + withno_lines, 'Xreloaded.vim') | 802 writefile(first_lines + withno_lines, 'Xreloaded.vim') |
804 source Xreloaded.vim | 803 source Xreloaded.vim |
805 g:DoCheck() | 804 g:DoCheck() |
806 | 805 |
807 delete('Xreloaded.vim') | 806 delete('Xreloaded.vim') |
807 enddef | |
808 | |
809 def Test_vim9script_reload_delvar() | |
810 # write the script with a script-local variable | |
811 let lines =<< trim END | |
812 vim9script | |
813 let var = 'string' | |
814 END | |
815 writefile(lines, 'XreloadVar.vim') | |
816 source XreloadVar.vim | |
817 | |
818 # now write the script using the same variable locally - works | |
819 lines =<< trim END | |
820 vim9script | |
821 def Func() | |
822 let var = 'string' | |
823 enddef | |
824 END | |
825 writefile(lines, 'XreloadVar.vim') | |
826 source XreloadVar.vim | |
827 | |
828 delete('XreloadVar.vim') | |
808 enddef | 829 enddef |
809 | 830 |
810 def Test_import_absolute() | 831 def Test_import_absolute() |
811 let import_lines = [ | 832 let import_lines = [ |
812 'vim9script', | 833 'vim9script', |
860 | 881 |
861 assert_equal(9876, g:imported_rtp) | 882 assert_equal(9876, g:imported_rtp) |
862 unlet g:imported_rtp | 883 unlet g:imported_rtp |
863 | 884 |
864 delete('Ximport_rtp.vim') | 885 delete('Ximport_rtp.vim') |
865 delete('import/Xexport_rtp.vim') | 886 delete('import', 'rf') |
866 delete('import', 'd') | |
867 enddef | 887 enddef |
868 | 888 |
869 def Test_fixed_size_list() | 889 def Test_fixed_size_list() |
870 " will be allocated as one piece of memory, check that changes work | 890 " will be allocated as one piece of memory, check that changes work |
871 let l = [1, 2, 3, 4] | 891 let l = [1, 2, 3, 4] |