summaryrefslogtreecommitdiff
path: root/src/testdir/test_vim9_disassemble.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-02-06 22:06:54 +0100
committerBram Moolenaar <Bram@vim.org>2020-02-06 22:06:54 +0100
commit04d0522046e79d0e13c1317ad34bf228722ec728 (patch)
treeae5bf89d1bccca4082b689eb5ec22181484ddf54 /src/testdir/test_vim9_disassemble.vim
parent777770fbb0f3c091cbfa22572b953c0723355710 (diff)
downloadvim-git-04d0522046e79d0e13c1317ad34bf228722ec728.tar.gz
patch 8.2.0226: compiling for loop not testedv8.2.0226
Problem: Compiling for loop not tested. Solution: Add a test. Make variable initialization work for more types.
Diffstat (limited to 'src/testdir/test_vim9_disassemble.vim')
-rw-r--r--src/testdir/test_vim9_disassemble.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim
index 20ad602f4..d9a2ad455 100644
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -325,5 +325,37 @@ def Test_compile_and_or()
\, instr)
enddef
+def ForLoop(): list<number>
+ let res: list<number>
+ for i in range(3)
+ res->add(i)
+ endfor
+ return res
+enddef
+
+def Test_compile_for_loop()
+ assert_equal([0, 1, 2], ForLoop())
+ let instr = execute('disassemble ForLoop')
+ assert_match('ForLoop.*'
+ \ .. 'let res: list<number>.*'
+ \ .. ' NEWLIST size 0.*'
+ \ .. '\d STORE $0.*'
+ \ .. 'for i in range(3).*'
+ \ .. '\d STORE -1 in $1.*'
+ \ .. '\d PUSHNR 3.*'
+ \ .. '\d BCALL range(argc 1).*'
+ \ .. '\d FOR $1 -> \d\+.*'
+ \ .. '\d STORE $2.*'
+ \ .. 'res->add(i).*'
+ \ .. '\d LOAD $0.*'
+ \ .. '\d LOAD $2.*'
+ \ .. '\d BCALL add(argc 2).*'
+ \ .. '\d DROP.*'
+ \ .. 'endfor.*'
+ \ .. '\d JUMP -> \d\+.*'
+ \ .. '\d DROP.*'
+ \, instr)
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker