comparison src/testdir/test_vim9_disassemble.vim @ 19572:6b6e97d0185e v8.2.0343

patch 8.2.0343: Vim9: using wrong instruction, limited test coverage Commit: https://github.com/vim/vim/commit/f51cb4e08ef904d137c27fe7cddb4702d8dcb2a2 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 1 17:55:14 2020 +0100 patch 8.2.0343: Vim9: using wrong instruction, limited test coverage Problem: Vim9: using wrong instruction, limited test coverage. Solution: Use ISN_PUSHJOB. Add a few more tests.
author Bram Moolenaar <Bram@vim.org>
date Sun, 01 Mar 2020 18:00:04 +0100
parents b8f778dda1a1
children aae19dd172c0
comparison
equal deleted inserted replaced
19571:a1ff82a1aa9f 19572:6b6e97d0185e
1 " Test the :disassemble command, and compilation as a side effect 1 " Test the :disassemble command, and compilation as a side effect
2
3 source check.vim
2 4
3 func NotCompiled() 5 func NotCompiled()
4 echo "not" 6 echo "not"
5 endfunc 7 endfunc
6 8
328 \, instr) 330 \, instr)
329 assert_notmatch('PUSHS "nothing"', instr) 331 assert_notmatch('PUSHS "nothing"', instr)
330 assert_notmatch('PUSHS "something"', instr) 332 assert_notmatch('PUSHS "something"', instr)
331 assert_notmatch('PUSHS "less"', instr) 333 assert_notmatch('PUSHS "less"', instr)
332 assert_notmatch('JUMP', instr) 334 assert_notmatch('JUMP', instr)
335 enddef
336
337 def WithFunc()
338 let funky1: func
339 let funky2: func = function("len")
340 let party1: partial
341 let party2: partial = funcref("UserFunc")
342 enddef
343
344 def Test_disassemble_function()
345 let instr = execute('disassemble WithFunc')
346 assert_match('WithFunc.*'
347 \ .. 'let funky1: func.*'
348 \ .. '0 PUSHFUNC "\[none]".*'
349 \ .. '1 STORE $0.*'
350 \ .. 'let funky2: func = function("len").*'
351 \ .. '2 PUSHS "len".*'
352 \ .. '3 BCALL function(argc 1).*'
353 \ .. '4 STORE $1.*'
354 \ .. 'let party1: partial.*'
355 \ .. '5 PUSHPARTIAL "\[none]".*'
356 \ .. '6 STORE $2.*'
357 \ .. 'let party2: partial = funcref("UserFunc").*'
358 \ .. '7 PUSHS "UserFunc".*'
359 \ .. '8 BCALL funcref(argc 1).*'
360 \ .. '9 STORE $3.*'
361 \ .. '10 PUSHNR 0.*'
362 \ .. '11 RETURN.*'
363 \, instr)
364 enddef
365
366 if has('channel')
367 def WithChannel()
368 let job1: job
369 let job2: job = job_start("donothing")
370 let chan1: channel
371 enddef
372 endif
373
374 def Test_disassemble_channel()
375 CheckFeature channel
376
377 let instr = execute('disassemble WithChannel')
378 assert_match('WithChannel.*'
379 \ .. 'let job1: job.*'
380 \ .. '\d PUSHJOB "no process".*'
381 \ .. '\d STORE $0.*'
382 \ .. 'let job2: job = job_start("donothing").*'
383 \ .. '\d PUSHS "donothing".*'
384 \ .. '\d BCALL job_start(argc 1).*'
385 \ .. '\d STORE $1.*'
386 \ .. 'let chan1: channel.*'
387 \ .. '\d PUSHCHANNEL 0.*'
388 \ .. '\d STORE $2.*'
389 \ .. '\d PUSHNR 0.*'
390 \ .. '\d RETURN.*'
391 \, instr)
333 enddef 392 enddef
334 393
335 def WithLambda(): string 394 def WithLambda(): string
336 let F = {a -> "X" .. a .. "X"} 395 let F = {a -> "X" .. a .. "X"}
337 return F("x") 396 return F("x")