annotate src/testdir/test_vim9_disassemble.vim @ 19862:846fbbacce3a v8.2.0487

patch 8.2.0487: Vim9: compiling not sufficiently tested Commit: https://github.com/vim/vim/commit/bd5da371aafe5a2207065643502f4d1ff6b286c7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 31 23:13:10 2020 +0200 patch 8.2.0487: Vim9: compiling not sufficiently tested Problem: Vim9: compiling not sufficiently tested. Solution: Add more tests. Fix bug with PCALL.
author Bram Moolenaar <Bram@vim.org>
date Tue, 31 Mar 2020 23:15:04 +0200
parents f03357f16ffc
children 50fa63ca3828
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Test the :disassemble command, and compilation as a side effect
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
3 source check.vim
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
4
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 func NotCompiled()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 echo "not"
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 let s:scriptvar = 4
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 let g:globalvar = 'g'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 def s:ScriptFuncLoad(arg: string)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let local = 1
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 buffers
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 echo arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 echo local
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 echo v:version
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 echo s:scriptvar
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 echo g:globalvar
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 echo &tabstop
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 echo $ENVVAR
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 echo @z
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
25 def Test_disassemble_load()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 assert_fails('disass NoFunc', 'E1061:')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 assert_fails('disass NotCompiled', 'E1062:')
19390
e4b326c9424a patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents: 19342
diff changeset
28 assert_fails('disass', 'E471:')
e4b326c9424a patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents: 19342
diff changeset
29 assert_fails('disass [', 'E475:')
e4b326c9424a patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents: 19342
diff changeset
30 assert_fails('disass 234', 'E475:')
e4b326c9424a patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents: 19342
diff changeset
31 assert_fails('disass <XX>foo', 'E475:')
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 let res = execute('disass s:ScriptFuncLoad')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 assert_match('<SNR>\d*_ScriptFuncLoad.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 \ .. 'buffers.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 \ .. ' EXEC \+buffers.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 \ .. ' LOAD arg\[-1\].*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 \ .. ' LOAD $0.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 \ .. ' LOADV v:version.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 \ .. ' LOADS s:scriptvar from .*test_vim9_disassemble.vim.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 \ .. ' LOADG g:globalvar.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 \ .. ' LOADENV $ENVVAR.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 \ .. ' LOADREG @z.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 \, res)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 def s:ScriptFuncPush()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 let localbool = true
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 let localspec = v:none
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 let localblob = 0z1234
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 if has('float')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 let localfloat = 1.234
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 endif
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
56 def Test_disassemble_push()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 let res = execute('disass s:ScriptFuncPush')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 assert_match('<SNR>\d*_ScriptFuncPush.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 \ .. 'localbool = true.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 \ .. ' PUSH v:true.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 \ .. 'localspec = v:none.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 \ .. ' PUSH v:none.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 \ .. 'localblob = 0z1234.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 \ .. ' PUSHBLOB 0z1234.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 \, res)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 if has('float')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 assert_match('<SNR>\d*_ScriptFuncPush.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 \ .. 'localfloat = 1.234.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 \ .. ' PUSHF 1.234.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 \, res)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 endif
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 def s:ScriptFuncStore()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 let localnr = 1
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 localnr = 2
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 let localstr = 'abc'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 localstr = 'xyz'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 v:char = 'abc'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 s:scriptvar = 'sv'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 g:globalvar = 'gv'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 &tabstop = 8
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 $ENVVAR = 'ev'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 @z = 'rv'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
87 def Test_disassemble_store()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 let res = execute('disass s:ScriptFuncStore')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 assert_match('<SNR>\d*_ScriptFuncStore.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 \ .. 'localnr = 2.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 \ .. ' STORE 2 in $0.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 \ .. 'localstr = ''xyz''.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 \ .. ' STORE $1.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 \ .. 'v:char = ''abc''.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 \ .. 'STOREV v:char.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 \ .. 's:scriptvar = ''sv''.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 \ .. ' STORES s:scriptvar in .*test_vim9_disassemble.vim.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 \ .. 'g:globalvar = ''gv''.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 \ .. ' STOREG g:globalvar.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 \ .. '&tabstop = 8.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 \ .. ' STOREOPT &tabstop.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 \ .. '$ENVVAR = ''ev''.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 \ .. ' STOREENV $ENVVAR.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 \ .. '@z = ''rv''.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 \ .. ' STOREREG @z.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 \, res)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 def s:ScriptFuncTry()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 try
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 echo 'yes'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 catch /fail/
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 echo 'no'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 finally
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
115 throw 'end'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 endtry
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
119 def Test_disassemble_try()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 let res = execute('disass s:ScriptFuncTry')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 assert_match('<SNR>\d*_ScriptFuncTry.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 \ .. 'try.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 \ .. 'TRY catch -> \d\+, finally -> \d\+.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 \ .. 'catch /fail/.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 \ .. ' JUMP -> \d\+.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 \ .. ' PUSH v:exception.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 \ .. ' PUSHS "fail".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 \ .. ' COMPARESTRING =\~.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 \ .. ' JUMP_IF_FALSE -> \d\+.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 \ .. ' CATCH.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 \ .. 'finally.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 \ .. ' PUSHS "end".*'
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
133 \ .. ' THROW.*'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 \ .. 'endtry.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 \ .. ' ENDTRY.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 \, res)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 def s:ScriptFuncNew()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 let ll = [1, "two", 333]
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 let dd = #{one: 1, two: "val"}
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
144 def Test_disassemble_new()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 let res = execute('disass s:ScriptFuncNew')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 assert_match('<SNR>\d*_ScriptFuncNew.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 \ .. 'let ll = \[1, "two", 333].*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 \ .. 'PUSHNR 1.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 \ .. 'PUSHS "two".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 \ .. 'PUSHNR 333.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 \ .. 'NEWLIST size 3.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 \ .. 'let dd = #{one: 1, two: "val"}.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 \ .. 'PUSHS "one".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 \ .. 'PUSHNR 1.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 \ .. 'PUSHS "two".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 \ .. 'PUSHS "val".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 \ .. 'NEWDICT size 2.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 \, res)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 def FuncWithArg(arg)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 echo arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 func UserFunc()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 echo 'nothing'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 func UserFuncWithArg(arg)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 echo a:arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 def s:ScriptFuncCall(): string
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 changenr()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 char2nr("abc")
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
176 Test_disassemble_new()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 FuncWithArg(343)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 ScriptFuncNew()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 s:ScriptFuncNew()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 UserFunc()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 UserFuncWithArg("foo")
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 let FuncRef = function("UserFunc")
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 FuncRef()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 let FuncRefWithArg = function("UserFuncWithArg")
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 FuncRefWithArg("bar")
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 return "yes"
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
189 def Test_disassemble_call()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 let res = execute('disass s:ScriptFuncCall')
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 assert_match('<SNR>\d\+_ScriptFuncCall.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 \ .. 'changenr().*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 \ .. ' BCALL changenr(argc 0).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 \ .. 'char2nr("abc").*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 \ .. ' PUSHS "abc".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 \ .. ' BCALL char2nr(argc 1).*'
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
197 \ .. 'Test_disassemble_new().*'
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
198 \ .. ' DCALL Test_disassemble_new(argc 0).*'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 \ .. 'FuncWithArg(343).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 \ .. ' PUSHNR 343.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 \ .. ' DCALL FuncWithArg(argc 1).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 \ .. 'ScriptFuncNew().*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 \ .. ' DCALL <SNR>\d\+_ScriptFuncNew(argc 0).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 \ .. 's:ScriptFuncNew().*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 \ .. ' DCALL <SNR>\d\+_ScriptFuncNew(argc 0).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 \ .. 'UserFunc().*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 \ .. ' UCALL UserFunc(argc 0).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 \ .. 'UserFuncWithArg("foo").*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 \ .. ' PUSHS "foo".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 \ .. ' UCALL UserFuncWithArg(argc 1).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 \ .. 'let FuncRef = function("UserFunc").*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 \ .. 'FuncRef().*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 \ .. ' LOAD $\d.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 \ .. ' PCALL (argc 0).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 \ .. 'let FuncRefWithArg = function("UserFuncWithArg").*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 \ .. 'FuncRefWithArg("bar").*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 \ .. ' PUSHS "bar".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 \ .. ' LOAD $\d.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 \ .. ' PCALL (argc 1).*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 \ .. 'return "yes".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 \ .. ' PUSHS "yes".*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 \ .. ' RETURN.*'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 \, res)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
226
19862
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
227 def EchoArg(arg: string): string
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
228 return arg
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
229 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
230 def RefThis(): func
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
231 return function('EchoArg')
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
232 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
233 def s:ScriptPCall()
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
234 RefThis()("text")
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
235 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
236
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
237 def Test_disassemble_pcall()
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
238 let res = execute('disass s:ScriptPCall')
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
239 assert_match('<SNR>\d\+_ScriptPCall.*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
240 \ .. 'RefThis()("text").*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
241 \ .. '\d DCALL RefThis(argc 0).*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
242 \ .. '\d PUSHS "text".*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
243 \ .. '\d PCALL top (argc 1).*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
244 \ .. '\d PCALL end.*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
245 \ .. '\d DROP.*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
246 \ .. '\d PUSHNR 0.*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
247 \ .. '\d RETURN.*'
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
248 \, res)
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
249 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
250
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
251
19532
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
252 def FuncWithForwardCall(): string
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
253 return DefinedLater("yes")
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
254 enddef
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
255
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
256 def DefinedLater(arg: string): string
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
257 return arg
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
258 enddef
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
259
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
260 def Test_disassemble_update_instr()
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
261 let res = execute('disass FuncWithForwardCall')
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
262 assert_match('FuncWithForwardCall.*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
263 \ .. 'return DefinedLater("yes").*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
264 \ .. '\d PUSHS "yes".*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
265 \ .. '\d UCALL DefinedLater(argc 1).*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
266 \ .. '\d CHECKTYPE string stack\[-1].*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
267 \ .. '\d RETURN.*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
268 \, res)
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
269
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
270 " Calling the function will change UCALL into the faster DCALL
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
271 assert_equal('yes', FuncWithForwardCall())
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
272
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
273 res = execute('disass FuncWithForwardCall')
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
274 assert_match('FuncWithForwardCall.*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
275 \ .. 'return DefinedLater("yes").*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
276 \ .. '\d PUSHS "yes".*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
277 \ .. '\d DCALL DefinedLater(argc 1).*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
278 \ .. '\d CHECKTYPE string stack\[-1].*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
279 \ .. '\d RETURN.*'
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
280 \, res)
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
281 enddef
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
282
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
283
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
284 def FuncWithDefault(arg: string = 'default'): string
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
285 return arg
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
286 enddef
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
287
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
288 def Test_disassemble_call_default()
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
289 let res = execute('disass FuncWithDefault')
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
290 assert_match('FuncWithDefault.*'
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
291 \ .. '\d PUSHS "default".*'
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
292 \ .. '\d STORE arg\[-1].*'
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
293 \ .. 'return arg.*'
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
294 \ .. '\d LOAD arg\[-1].*'
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
295 \ .. '\d RETURN.*'
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
296 \, res)
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
297 enddef
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
298
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
299
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
300 def HasEval()
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
301 if has("eval")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
302 echo "yes"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
303 else
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
304 echo "no"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
305 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
306 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
307
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
308 def HasNothing()
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
309 if has("nothing")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
310 echo "yes"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
311 else
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
312 echo "no"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
313 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
314 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
315
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
316 def HasSomething()
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
317 if has("nothing")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
318 echo "nothing"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
319 elseif has("something")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
320 echo "something"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
321 elseif has("eval")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
322 echo "eval"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
323 elseif has("less")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
324 echo "less"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
325 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
326 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
327
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
328 def Test_disassemble_const_expr()
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
329 assert_equal("\nyes", execute('call HasEval()'))
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
330 let instr = execute('disassemble HasEval')
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
331 assert_match('HasEval.*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
332 \ .. 'if has("eval").*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
333 \ .. ' PUSHS "yes".*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
334 \, instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
335 assert_notmatch('JUMP', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
336
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
337 assert_equal("\nno", execute('call HasNothing()'))
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
338 instr = execute('disassemble HasNothing')
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
339 assert_match('HasNothing.*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
340 \ .. 'if has("nothing").*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
341 \ .. 'else.*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
342 \ .. ' PUSHS "no".*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
343 \, instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
344 assert_notmatch('PUSHS "yes"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
345 assert_notmatch('JUMP', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
346
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
347 assert_equal("\neval", execute('call HasSomething()'))
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
348 instr = execute('disassemble HasSomething')
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
349 assert_match('HasSomething.*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
350 \ .. 'if has("nothing").*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
351 \ .. 'elseif has("something").*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
352 \ .. 'elseif has("eval").*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
353 \ .. ' PUSHS "eval".*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
354 \ .. 'elseif has("less").*'
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
355 \, instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
356 assert_notmatch('PUSHS "nothing"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
357 assert_notmatch('PUSHS "something"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
358 assert_notmatch('PUSHS "less"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
359 assert_notmatch('JUMP', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
360 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
361
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
362 def WithFunc()
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
363 let funky1: func
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
364 let funky2: func = function("len")
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
365 let party1: partial
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
366 let party2: partial = funcref("UserFunc")
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
367 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
368
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
369 def Test_disassemble_function()
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
370 let instr = execute('disassemble WithFunc')
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
371 assert_match('WithFunc.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
372 \ .. 'let funky1: func.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
373 \ .. '0 PUSHFUNC "\[none]".*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
374 \ .. '1 STORE $0.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
375 \ .. 'let funky2: func = function("len").*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
376 \ .. '2 PUSHS "len".*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
377 \ .. '3 BCALL function(argc 1).*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
378 \ .. '4 STORE $1.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
379 \ .. 'let party1: partial.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
380 \ .. '5 PUSHPARTIAL "\[none]".*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
381 \ .. '6 STORE $2.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
382 \ .. 'let party2: partial = funcref("UserFunc").*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
383 \ .. '7 PUSHS "UserFunc".*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
384 \ .. '8 BCALL funcref(argc 1).*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
385 \ .. '9 STORE $3.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
386 \ .. '10 PUSHNR 0.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
387 \ .. '11 RETURN.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
388 \, instr)
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
389 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
390
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
391 if has('channel')
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
392 def WithChannel()
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
393 let job1: job
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
394 let job2: job = job_start("donothing")
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
395 let chan1: channel
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
396 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
397 endif
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
398
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
399 def Test_disassemble_channel()
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
400 CheckFeature channel
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
401
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
402 let instr = execute('disassemble WithChannel')
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
403 assert_match('WithChannel.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
404 \ .. 'let job1: job.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
405 \ .. '\d PUSHJOB "no process".*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
406 \ .. '\d STORE $0.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
407 \ .. 'let job2: job = job_start("donothing").*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
408 \ .. '\d PUSHS "donothing".*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
409 \ .. '\d BCALL job_start(argc 1).*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
410 \ .. '\d STORE $1.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
411 \ .. 'let chan1: channel.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
412 \ .. '\d PUSHCHANNEL 0.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
413 \ .. '\d STORE $2.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
414 \ .. '\d PUSHNR 0.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
415 \ .. '\d RETURN.*'
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
416 \, instr)
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
417 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
418
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
419 def WithLambda(): string
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
420 let F = {a -> "X" .. a .. "X"}
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
421 return F("x")
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
422 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
423
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
424 def Test_disassemble_lambda()
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
425 assert_equal("XxX", WithLambda())
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
426 let instr = execute('disassemble WithLambda')
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
427 assert_match('WithLambda.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
428 \ .. 'let F = {a -> "X" .. a .. "X"}.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
429 \ .. ' FUNCREF <lambda>\d\+.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
430 \ .. 'PUSHS "x".*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
431 \ .. ' LOAD $0.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
432 \ .. ' PCALL (argc 1).*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
433 \ .. ' CHECKTYPE string stack\[-1].*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
434 \, instr)
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
435 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
436
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
437 def AndOr(arg): string
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
438 if arg == 1 && arg != 2 || arg == 4
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
439 return 'yes'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
440 endif
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
441 return 'no'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
442 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
443
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
444 def Test_disassemble_and_or()
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
445 assert_equal("yes", AndOr(1))
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
446 assert_equal("no", AndOr(2))
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
447 assert_equal("yes", AndOr(4))
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
448 let instr = execute('disassemble AndOr')
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
449 assert_match('AndOr.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
450 \ .. 'if arg == 1 && arg != 2 || arg == 4.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
451 \ .. '\d LOAD arg\[-1].*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
452 \ .. '\d PUSHNR 1.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
453 \ .. '\d COMPAREANY ==.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
454 \ .. '\d JUMP_AND_KEEP_IF_FALSE -> \d\+.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
455 \ .. '\d LOAD arg\[-1].*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
456 \ .. '\d PUSHNR 2.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
457 \ .. '\d COMPAREANY !=.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
458 \ .. '\d JUMP_AND_KEEP_IF_TRUE -> \d\+.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
459 \ .. '\d LOAD arg\[-1].*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
460 \ .. '\d PUSHNR 4.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
461 \ .. '\d COMPAREANY ==.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
462 \ .. '\d JUMP_IF_FALSE -> \d\+.*'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
463 \, instr)
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
464 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
465
19336
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
466 def ForLoop(): list<number>
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
467 let res: list<number>
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
468 for i in range(3)
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
469 res->add(i)
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
470 endfor
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
471 return res
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
472 enddef
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
473
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
474 def Test_disassemble_for_loop()
19336
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
475 assert_equal([0, 1, 2], ForLoop())
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
476 let instr = execute('disassemble ForLoop')
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
477 assert_match('ForLoop.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
478 \ .. 'let res: list<number>.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
479 \ .. ' NEWLIST size 0.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
480 \ .. '\d STORE $0.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
481 \ .. 'for i in range(3).*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
482 \ .. '\d STORE -1 in $1.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
483 \ .. '\d PUSHNR 3.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
484 \ .. '\d BCALL range(argc 1).*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
485 \ .. '\d FOR $1 -> \d\+.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
486 \ .. '\d STORE $2.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
487 \ .. 'res->add(i).*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
488 \ .. '\d LOAD $0.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
489 \ .. '\d LOAD $2.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
490 \ .. '\d BCALL add(argc 2).*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
491 \ .. '\d DROP.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
492 \ .. 'endfor.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
493 \ .. '\d JUMP -> \d\+.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
494 \ .. '\d DROP.*'
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
495 \, instr)
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
496 enddef
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
497
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
498 let g:number = 42
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
499
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
500 def Computing()
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
501 let nr = 3
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
502 let nrres = nr + 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
503 nrres = nr - 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
504 nrres = nr * 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
505 nrres = nr / 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
506 nrres = nr % 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
507
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
508 let anyres = g:number + 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
509 anyres = g:number - 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
510 anyres = g:number * 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
511 anyres = g:number / 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
512 anyres = g:number % 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
513
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
514 if has('float')
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
515 let fl = 3.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
516 let flres = fl + 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
517 flres = fl - 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
518 flres = fl * 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
519 flres = fl / 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
520 endif
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
521 enddef
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
522
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
523 def Test_disassemble_computing()
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
524 let instr = execute('disassemble Computing')
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
525 assert_match('Computing.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
526 \ .. 'let nr = 3.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
527 \ .. '\d STORE 3 in $0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
528 \ .. 'let nrres = nr + 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
529 \ .. '\d LOAD $0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
530 \ .. '\d PUSHNR 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
531 \ .. '\d OPNR +.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
532 \ .. '\d STORE $1.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
533 \ .. 'nrres = nr - 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
534 \ .. '\d OPNR -.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
535 \ .. 'nrres = nr \* 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
536 \ .. '\d OPNR \*.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
537 \ .. 'nrres = nr / 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
538 \ .. '\d OPNR /.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
539 \ .. 'nrres = nr % 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
540 \ .. '\d OPNR %.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
541 \ .. 'let anyres = g:number + 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
542 \ .. '\d LOADG g:number.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
543 \ .. '\d PUSHNR 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
544 \ .. '\d OPANY +.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
545 \ .. '\d STORE $2.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
546 \ .. 'anyres = g:number - 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
547 \ .. '\d OPANY -.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
548 \ .. 'anyres = g:number \* 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
549 \ .. '\d OPANY \*.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
550 \ .. 'anyres = g:number / 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
551 \ .. '\d OPANY /.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
552 \ .. 'anyres = g:number % 7.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
553 \ .. '\d OPANY %.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
554 \, instr)
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
555 if has('float')
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
556 assert_match('Computing.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
557 \ .. 'let fl = 3.0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
558 \ .. '\d PUSHF 3.0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
559 \ .. '\d STORE $3.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
560 \ .. 'let flres = fl + 7.0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
561 \ .. '\d LOAD $3.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
562 \ .. '\d PUSHF 7.0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
563 \ .. '\d OPFLOAT +.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
564 \ .. '\d STORE $4.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
565 \ .. 'flres = fl - 7.0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
566 \ .. '\d OPFLOAT -.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
567 \ .. 'flres = fl \* 7.0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
568 \ .. '\d OPFLOAT \*.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
569 \ .. 'flres = fl / 7.0.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
570 \ .. '\d OPFLOAT /.*'
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
571 \, instr)
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
572 endif
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
573 enddef
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
575 def AddListBlob()
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
576 let reslist = [1, 2] + [3, 4]
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
577 let resblob = 0z1122 + 0z3344
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
578 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
579
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
580 def Test_disassemble_add_list_blob()
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
581 let instr = execute('disassemble AddListBlob')
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
582 assert_match('AddListBlob.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
583 \ .. 'let reslist = \[1, 2] + \[3, 4].*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
584 \ .. '\d PUSHNR 1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
585 \ .. '\d PUSHNR 2.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
586 \ .. '\d NEWLIST size 2.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
587 \ .. '\d PUSHNR 3.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
588 \ .. '\d PUSHNR 4.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
589 \ .. '\d NEWLIST size 2.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
590 \ .. '\d ADDLIST.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
591 \ .. '\d STORE $.*.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
592 \ .. 'let resblob = 0z1122 + 0z3344.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
593 \ .. '\d PUSHBLOB 0z1122.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
594 \ .. '\d PUSHBLOB 0z3344.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
595 \ .. '\d ADDBLOB.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
596 \ .. '\d STORE $.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
597 \, instr)
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
598 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
599
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
600 let g:aa = 'aa'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
601 def ConcatString(): string
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
602 let res = g:aa .. "bb"
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
603 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
604 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
605
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
606 def Test_disassemble_concat()
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
607 let instr = execute('disassemble ConcatString')
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
608 assert_match('ConcatString.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
609 \ .. 'let res = g:aa .. "bb".*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
610 \ .. '\d LOADG g:aa.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
611 \ .. '\d PUSHS "bb".*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
612 \ .. '\d 2STRING stack\[-2].*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
613 \ .. '\d CONCAT.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
614 \ .. '\d STORE $.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
615 \, instr)
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
616 assert_equal('aabb', ConcatString())
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
617 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
618
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
619 def ListIndex(): number
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
620 let l = [1, 2, 3]
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
621 let res = l[1]
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
622 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
623 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
624
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
625 def Test_disassemble_list_index()
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
626 let instr = execute('disassemble ListIndex')
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
627 assert_match('ListIndex.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
628 \ .. 'let l = \[1, 2, 3].*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
629 \ .. '\d PUSHNR 1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
630 \ .. '\d PUSHNR 2.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
631 \ .. '\d PUSHNR 3.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
632 \ .. '\d NEWLIST size 3.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
633 \ .. '\d STORE $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
634 \ .. 'let res = l\[1].*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
635 \ .. '\d LOAD $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
636 \ .. '\d PUSHNR 1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
637 \ .. '\d INDEX.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
638 \ .. '\d STORE $1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
639 \, instr)
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
640 assert_equal(2, ListIndex())
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
641 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
642
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
643 def DictMember(): number
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
644 let d = #{item: 1}
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
645 let res = d.item
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
646 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
647 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
648
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
649 def Test_disassemble_dict_member()
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
650 let instr = execute('disassemble DictMember')
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
651 assert_match('DictMember.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
652 \ .. 'let d = #{item: 1}.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
653 \ .. '\d PUSHS "item".*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
654 \ .. '\d PUSHNR 1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
655 \ .. '\d NEWDICT size 1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
656 \ .. '\d STORE $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
657 \ .. 'let res = d.item.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
658 \ .. '\d LOAD $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
659 \ .. '\d MEMBER item.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
660 \ .. '\d STORE $1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
661 \, instr)
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
662 call assert_equal(1, DictMember())
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
663 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
664
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
665 def NegateNumber(): number
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
666 let nr = 9
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
667 let plus = +nr
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
668 let res = -nr
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
669 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
670 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
671
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
672 def Test_disassemble_negate_number()
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
673 let instr = execute('disassemble NegateNumber')
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
674 assert_match('NegateNumber.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
675 \ .. 'let nr = 9.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
676 \ .. '\d STORE 9 in $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
677 \ .. 'let plus = +nr.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
678 \ .. '\d LOAD $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
679 \ .. '\d CHECKNR.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
680 \ .. '\d STORE $1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
681 \ .. 'let res = -nr.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
682 \ .. '\d LOAD $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
683 \ .. '\d NEGATENR.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
684 \ .. '\d STORE $2.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
685 \, instr)
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
686 call assert_equal(-9, NegateNumber())
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
687 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
688
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
689 def InvertBool(): bool
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
690 let flag = true
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
691 let invert = !flag
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
692 let res = !!flag
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
693 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
694 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
695
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
696 def Test_disassemble_invert_bool()
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
697 let instr = execute('disassemble InvertBool')
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
698 assert_match('InvertBool.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
699 \ .. 'let flag = true.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
700 \ .. '\d PUSH v:true.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
701 \ .. '\d STORE $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
702 \ .. 'let invert = !flag.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
703 \ .. '\d LOAD $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
704 \ .. '\d INVERT (!val).*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
705 \ .. '\d STORE $1.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
706 \ .. 'let res = !!flag.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
707 \ .. '\d LOAD $0.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
708 \ .. '\d 2BOOL (!!val).*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
709 \ .. '\d STORE $2.*'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
710 \, instr)
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
711 call assert_equal(true, InvertBool())
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
712 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
713
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
714 def Test_disassemble_compare()
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
715 " TODO: COMPAREFUNC
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
716 let cases = [
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
717 \ ['true == false', 'COMPAREBOOL =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
718 \ ['true != false', 'COMPAREBOOL !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
719 \ ['v:none == v:null', 'COMPARESPECIAL =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
720 \ ['v:none != v:null', 'COMPARESPECIAL !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
721 \
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
722 \ ['111 == 222', 'COMPARENR =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
723 \ ['111 != 222', 'COMPARENR !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
724 \ ['111 > 222', 'COMPARENR >'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
725 \ ['111 < 222', 'COMPARENR <'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
726 \ ['111 >= 222', 'COMPARENR >='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
727 \ ['111 <= 222', 'COMPARENR <='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
728 \ ['111 =~ 222', 'COMPARENR =\~'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
729 \ ['111 !~ 222', 'COMPARENR !\~'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
730 \
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
731 \ ['"xx" == "yy"', 'COMPARESTRING =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
732 \ ['"xx" != "yy"', 'COMPARESTRING !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
733 \ ['"xx" > "yy"', 'COMPARESTRING >'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
734 \ ['"xx" < "yy"', 'COMPARESTRING <'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
735 \ ['"xx" >= "yy"', 'COMPARESTRING >='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
736 \ ['"xx" <= "yy"', 'COMPARESTRING <='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
737 \ ['"xx" =~ "yy"', 'COMPARESTRING =\~'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
738 \ ['"xx" !~ "yy"', 'COMPARESTRING !\~'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
739 \ ['"xx" is "yy"', 'COMPARESTRING is'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
740 \ ['"xx" isnot "yy"', 'COMPARESTRING isnot'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
741 \
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
742 \ ['0z11 == 0z22', 'COMPAREBLOB =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
743 \ ['0z11 != 0z22', 'COMPAREBLOB !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
744 \ ['0z11 is 0z22', 'COMPAREBLOB is'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
745 \ ['0z11 isnot 0z22', 'COMPAREBLOB isnot'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
746 \
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
747 \ ['[1,2] == [3,4]', 'COMPARELIST =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
748 \ ['[1,2] != [3,4]', 'COMPARELIST !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
749 \ ['[1,2] is [3,4]', 'COMPARELIST is'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
750 \ ['[1,2] isnot [3,4]', 'COMPARELIST isnot'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
751 \
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
752 \ ['#{a:1} == #{x:2}', 'COMPAREDICT =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
753 \ ['#{a:1} != #{x:2}', 'COMPAREDICT !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
754 \ ['#{a:1} is #{x:2}', 'COMPAREDICT is'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
755 \ ['#{a:1} isnot #{x:2}', 'COMPAREDICT isnot'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
756 \
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
757 \ ['{->33} == {->44}', 'COMPAREPARTIAL =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
758 \ ['{->33} != {->44}', 'COMPAREPARTIAL !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
759 \ ['{->33} is {->44}', 'COMPAREPARTIAL is'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
760 \ ['{->33} isnot {->44}', 'COMPAREPARTIAL isnot'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
761 \
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
762 \ ['77 == g:xx', 'COMPAREANY =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
763 \ ['77 != g:xx', 'COMPAREANY !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
764 \ ['77 > g:xx', 'COMPAREANY >'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
765 \ ['77 < g:xx', 'COMPAREANY <'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
766 \ ['77 >= g:xx', 'COMPAREANY >='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
767 \ ['77 <= g:xx', 'COMPAREANY <='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
768 \ ['77 =~ g:xx', 'COMPAREANY =\~'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
769 \ ['77 !~ g:xx', 'COMPAREANY !\~'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
770 \ ['77 is g:xx', 'COMPAREANY is'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
771 \ ['77 isnot g:xx', 'COMPAREANY isnot'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
772 \ ]
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
773 if has('float')
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
774 cases->extend([
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
775 \ ['1.1 == 2.2', 'COMPAREFLOAT =='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
776 \ ['1.1 != 2.2', 'COMPAREFLOAT !='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
777 \ ['1.1 > 2.2', 'COMPAREFLOAT >'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
778 \ ['1.1 < 2.2', 'COMPAREFLOAT <'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
779 \ ['1.1 >= 2.2', 'COMPAREFLOAT >='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
780 \ ['1.1 <= 2.2', 'COMPAREFLOAT <='],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
781 \ ['1.1 =~ 2.2', 'COMPAREFLOAT =\~'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
782 \ ['1.1 !~ 2.2', 'COMPAREFLOAT !\~'],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
783 \ ])
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
784 endif
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
785
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
786 let nr = 1
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
787 for case in cases
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
788 writefile(['def TestCase' .. nr .. '()',
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
789 \ ' if ' .. case[0],
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
790 \ ' echo 42'
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
791 \ ' endif',
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
792 \ 'enddef'], 'Xdisassemble')
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
793 source Xdisassemble
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
794 let instr = execute('disassemble TestCase' .. nr)
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
795 assert_match('TestCase' .. nr .. '.*'
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
796 \ .. 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '.*'
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
797 \ .. '\d \(PUSH\|FUNCREF\).*'
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
798 \ .. '\d \(PUSH\|FUNCREF\|LOADG\).*'
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
799 \ .. '\d ' .. case[1] .. '.*'
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
800 \ .. '\d JUMP_IF_FALSE -> \d\+.*'
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
801 \, instr)
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
802
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
803 nr += 1
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
804 endfor
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
805
19703
f03357f16ffc patch 8.2.0408: delete() commented out for testing
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
806 delete('Xdisassemble')
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
807 enddef
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
808
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
809 def s:Execute()
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
810 execute 'help vim9.txt'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
811 let cmd = 'help vim9.txt'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
812 execute cmd
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
813 let tag = 'vim9.txt'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
814 execute 'help ' .. tag
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
815 enddef
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
816
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
817 def Test_disassemble_execute()
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
818 let res = execute('disass s:Execute')
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
819 assert_match('\<SNR>\d*_Execute.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
820 \ .. "execute 'help vim9.txt'.*"
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
821 \ .. '\d PUSHS "help vim9.txt".*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
822 \ .. '\d EXECUTE 1.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
823 \ .. "let cmd = 'help vim9.txt'.*"
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
824 \ .. '\d PUSHS "help vim9.txt".*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
825 \ .. '\d STORE $0.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
826 \ .. 'execute cmd.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
827 \ .. '\d LOAD $0.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
828 \ .. '\d EXECUTE 1.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
829 \ .. "let tag = 'vim9.txt'.*"
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
830 \ .. '\d PUSHS "vim9.txt".*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
831 \ .. '\d STORE $1.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
832 \ .. "execute 'help ' .. tag.*"
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
833 \ .. '\d PUSHS "help ".*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
834 \ .. '\d LOAD $1.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
835 \ .. '\d CONCAT.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
836 \ .. '\d EXECUTE 1.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
837 \ .. '\d PUSHNR 0.*'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
838 \ .. '\d RETURN'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
839 \, res)
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
840 enddef
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
841
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
842 def SomeStringArg(arg: string)
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
843 echo arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
844 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
845
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
846 def SomeAnyArg(arg: any)
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
847 echo arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
848 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
849
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
850 def SomeStringArgAndReturn(arg: string): string
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
851 return arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
852 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
853
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
854 def Test_display_func()
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
855 let res1 = execute('function SomeStringArg')
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
856 assert_match('.* def SomeStringArg(arg: string).*'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
857 \ .. ' echo arg.*'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
858 \ .. ' enddef'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
859 \, res1)
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
860
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
861 let res2 = execute('function SomeAnyArg')
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
862 assert_match('.* def SomeAnyArg(arg: any).*'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
863 \ .. ' echo arg.*'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
864 \ .. ' enddef'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
865 \, res2)
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
866
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
867 let res3 = execute('function SomeStringArgAndReturn')
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
868 assert_match('.* def SomeStringArgAndReturn(arg: string): string.*'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
869 \ .. ' return arg.*'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
870 \ .. ' enddef'
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
871 \, res3)
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
872 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
873
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker