Mercurial > vim
comparison src/testdir/test_vim9_disassemble.vim @ 19338:ef432264b88a v8.2.0227
patch 8.2.0227: compiling a few instructions not tested
Commit: https://github.com/vim/vim/commit/c2a4b35b86fa8b28a34a9aea8ad16c87dbc6d834
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 6 22:41:16 2020 +0100
patch 8.2.0227: compiling a few instructions not tested
Problem: Compiling a few instructions not tested.
Solution: Add more test cases.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 06 Feb 2020 22:45:04 +0100 |
parents | 1cd6eab65ce0 |
children | 8ff84bc1c89b |
comparison
equal
deleted
inserted
replaced
19337:3c9d338aaaeb | 19338:ef432264b88a |
---|---|
104 try | 104 try |
105 echo 'yes' | 105 echo 'yes' |
106 catch /fail/ | 106 catch /fail/ |
107 echo 'no' | 107 echo 'no' |
108 finally | 108 finally |
109 echo 'end' | 109 throw 'end' |
110 endtry | 110 endtry |
111 enddef | 111 enddef |
112 | 112 |
113 def Test_disassembleTry() | 113 def Test_disassembleTry() |
114 let res = execute('disass s:ScriptFuncTry') | 114 let res = execute('disass s:ScriptFuncTry') |
122 \ .. ' COMPARESTRING =\~.*' | 122 \ .. ' COMPARESTRING =\~.*' |
123 \ .. ' JUMP_IF_FALSE -> \d\+.*' | 123 \ .. ' JUMP_IF_FALSE -> \d\+.*' |
124 \ .. ' CATCH.*' | 124 \ .. ' CATCH.*' |
125 \ .. 'finally.*' | 125 \ .. 'finally.*' |
126 \ .. ' PUSHS "end".*' | 126 \ .. ' PUSHS "end".*' |
127 \ .. ' THROW.*' | |
127 \ .. 'endtry.*' | 128 \ .. 'endtry.*' |
128 \ .. ' ENDTRY.*' | 129 \ .. ' ENDTRY.*' |
129 \, res) | 130 \, res) |
130 enddef | 131 enddef |
131 | 132 |
355 \ .. '\d JUMP -> \d\+.*' | 356 \ .. '\d JUMP -> \d\+.*' |
356 \ .. '\d DROP.*' | 357 \ .. '\d DROP.*' |
357 \, instr) | 358 \, instr) |
358 enddef | 359 enddef |
359 | 360 |
361 let g:number = 42 | |
362 | |
363 def Computing() | |
364 let nr = 3 | |
365 let nrres = nr + 7 | |
366 nrres = nr - 7 | |
367 nrres = nr * 7 | |
368 nrres = nr / 7 | |
369 nrres = nr % 7 | |
370 | |
371 let anyres = g:number + 7 | |
372 anyres = g:number - 7 | |
373 anyres = g:number * 7 | |
374 anyres = g:number / 7 | |
375 anyres = g:number % 7 | |
376 | |
377 if has('float') | |
378 let fl = 3.0 | |
379 let flres = fl + 7.0 | |
380 flres = fl - 7.0 | |
381 flres = fl * 7.0 | |
382 flres = fl / 7.0 | |
383 endif | |
384 enddef | |
385 | |
386 def Test_computing() | |
387 let instr = execute('disassemble Computing') | |
388 assert_match('Computing.*' | |
389 \ .. 'let nr = 3.*' | |
390 \ .. '\d STORE 3 in $0.*' | |
391 \ .. 'let nrres = nr + 7.*' | |
392 \ .. '\d LOAD $0.*' | |
393 \ .. '\d PUSHNR 7.*' | |
394 \ .. '\d OPNR +.*' | |
395 \ .. '\d STORE $1.*' | |
396 \ .. 'nrres = nr - 7.*' | |
397 \ .. '\d OPNR -.*' | |
398 \ .. 'nrres = nr \* 7.*' | |
399 \ .. '\d OPNR \*.*' | |
400 \ .. 'nrres = nr / 7.*' | |
401 \ .. '\d OPNR /.*' | |
402 \ .. 'nrres = nr % 7.*' | |
403 \ .. '\d OPNR %.*' | |
404 \ .. 'let anyres = g:number + 7.*' | |
405 \ .. '\d LOADG g:number.*' | |
406 \ .. '\d PUSHNR 7.*' | |
407 \ .. '\d OPANY +.*' | |
408 \ .. '\d STORE $2.*' | |
409 \ .. 'anyres = g:number - 7.*' | |
410 \ .. '\d OPANY -.*' | |
411 \ .. 'anyres = g:number \* 7.*' | |
412 \ .. '\d OPANY \*.*' | |
413 \ .. 'anyres = g:number / 7.*' | |
414 \ .. '\d OPANY /.*' | |
415 \ .. 'anyres = g:number % 7.*' | |
416 \ .. '\d OPANY %.*' | |
417 \, instr) | |
418 if has('float') | |
419 assert_match('Computing.*' | |
420 \ .. 'let fl = 3.0.*' | |
421 \ .. '\d PUSHF 3.0.*' | |
422 \ .. '\d STORE $3.*' | |
423 \ .. 'let flres = fl + 7.0.*' | |
424 \ .. '\d LOAD $3.*' | |
425 \ .. '\d PUSHF 7.0.*' | |
426 \ .. '\d OPFLOAT +.*' | |
427 \ .. '\d STORE $4.*' | |
428 \ .. 'flres = fl - 7.0.*' | |
429 \ .. '\d OPFLOAT -.*' | |
430 \ .. 'flres = fl \* 7.0.*' | |
431 \ .. '\d OPFLOAT \*.*' | |
432 \ .. 'flres = fl / 7.0.*' | |
433 \ .. '\d OPFLOAT /.*' | |
434 \, instr) | |
435 endif | |
436 enddef | |
360 | 437 |
361 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 438 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |