comparison src/testdir/test_vim9_disassemble.vim @ 21188:d73b6ba20053 v8.2.1145

patch 8.2.1145: Vim9: "for" only accepts a list at compile time Commit: https://github.com/vim/vim/commit/0ad3e894d75236915e67dfbbcc821b6bb3c05d91 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 5 21:38:11 2020 +0200 patch 8.2.1145: Vim9: "for" only accepts a list at compile time Problem: Vim9: "for" only accepts a list at compile time. Solution: Also accept a list at runtime.
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Jul 2020 21:45:04 +0200
parents 0653b9b72091
children 3f14e0d4a4dd
comparison
equal deleted inserted replaced
21187:bfc9b0a72673 21188:d73b6ba20053
725 '\d\+ JUMP -> \d\+\_s*' .. 725 '\d\+ JUMP -> \d\+\_s*' ..
726 '\d\+ DROP', 726 '\d\+ DROP',
727 instr) 727 instr)
728 enddef 728 enddef
729 729
730 def ForLoopEval(): string
731 let res = ""
732 for str in eval('["one", "two"]')
733 res ..= str
734 endfor
735 return res
736 enddef
737
738 def Test_disassemble_for_loop_eval()
739 assert_equal('onetwo', ForLoopEval())
740 let instr = execute('disassemble ForLoopEval')
741 assert_match('ForLoopEval\_s*' ..
742 'let res = ""\_s*' ..
743 '\d PUSHS ""\_s*' ..
744 '\d STORE $0\_s*' ..
745 'for str in eval(''\["one", "two"\]'')\_s*' ..
746 '\d STORE -1 in $1\_s*' ..
747 '\d PUSHS "\["one", "two"\]"\_s*' ..
748 '\d BCALL eval(argc 1)\_s*' ..
749 '\d CHECKTYPE list stack\[-1\]\_s*' ..
750 '\d FOR $1 -> \d\+\_s*' ..
751 '\d STORE $2\_s*' ..
752 'res ..= str\_s*' ..
753 '\d\+ LOAD $0\_s*' ..
754 '\d\+ LOAD $2\_s*' ..
755 '\d\+ CHECKTYPE string stack\[-1\]\_s*' ..
756 '\d\+ CONCAT\_s*' ..
757 '\d\+ STORE $0\_s*' ..
758 'endfor\_s*' ..
759 '\d\+ JUMP -> 6\_s*' ..
760 '\d\+ DROP\_s*' ..
761 'return res\_s*' ..
762 '\d\+ LOAD $0\_s*' ..
763 '\d\+ RETURN',
764 instr)
765 enddef
766
730 let g:number = 42 767 let g:number = 42
731 768
732 def Computing() 769 def Computing()
733 let nr = 3 770 let nr = 3
734 let nrres = nr + 7 771 let nrres = nr + 7