Mercurial > vim
comparison src/testdir/test_vim9_disassemble.vim @ 19336:1cd6eab65ce0 v8.2.0226
patch 8.2.0226: compiling for loop not tested
Commit: https://github.com/vim/vim/commit/04d0522046e79d0e13c1317ad34bf228722ec728
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 6 22:06:54 2020 +0100
patch 8.2.0226: compiling for loop not tested
Problem: Compiling for loop not tested.
Solution: Add a test. Make variable initialization work for more types.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 06 Feb 2020 22:15:03 +0100 |
parents | 61646c189622 |
children | ef432264b88a |
comparison
equal
deleted
inserted
replaced
19335:fcd98c9a13e4 | 19336:1cd6eab65ce0 |
---|---|
323 \ .. '\d COMPAREANY ==.*' | 323 \ .. '\d COMPAREANY ==.*' |
324 \ .. '\d JUMP_IF_FALSE -> \d\+.*' | 324 \ .. '\d JUMP_IF_FALSE -> \d\+.*' |
325 \, instr) | 325 \, instr) |
326 enddef | 326 enddef |
327 | 327 |
328 def ForLoop(): list<number> | |
329 let res: list<number> | |
330 for i in range(3) | |
331 res->add(i) | |
332 endfor | |
333 return res | |
334 enddef | |
335 | |
336 def Test_compile_for_loop() | |
337 assert_equal([0, 1, 2], ForLoop()) | |
338 let instr = execute('disassemble ForLoop') | |
339 assert_match('ForLoop.*' | |
340 \ .. 'let res: list<number>.*' | |
341 \ .. ' NEWLIST size 0.*' | |
342 \ .. '\d STORE $0.*' | |
343 \ .. 'for i in range(3).*' | |
344 \ .. '\d STORE -1 in $1.*' | |
345 \ .. '\d PUSHNR 3.*' | |
346 \ .. '\d BCALL range(argc 1).*' | |
347 \ .. '\d FOR $1 -> \d\+.*' | |
348 \ .. '\d STORE $2.*' | |
349 \ .. 'res->add(i).*' | |
350 \ .. '\d LOAD $0.*' | |
351 \ .. '\d LOAD $2.*' | |
352 \ .. '\d BCALL add(argc 2).*' | |
353 \ .. '\d DROP.*' | |
354 \ .. 'endfor.*' | |
355 \ .. '\d JUMP -> \d\+.*' | |
356 \ .. '\d DROP.*' | |
357 \, instr) | |
358 enddef | |
359 | |
328 | 360 |
329 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 361 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |