annotate src/testdir/test_vim9_disassemble.vim @ 30065:6cf788ab844c v9.0.0370

patch 9.0.0370: cleaning up afterwards can make a function messy Commit: https://github.com/vim/vim/commit/1d84f7608f1e41dad03b8cc7925895437775f7c0 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 3 21:35:53 2022 +0100 patch 9.0.0370: cleaning up afterwards can make a function messy Problem: Cleaning up afterwards can make a function messy. Solution: Add the :defer command.
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Sep 2022 22:45:03 +0200
parents d269dd3cd31d
children 42a6345b91fd
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
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
4 import './vim9.vim' as v9
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
5
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
6 func s:NotCompiled()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 echo "not"
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 let s:scriptvar = 4
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 let g:globalvar = 'g'
20089
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
12 let b:buffervar = 'b'
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
13 let w:windowvar = 'w'
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
14 let t:tabpagevar = 't'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 def s:ScriptFuncLoad(arg: string)
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
17 var local = 1
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 buffers
23183
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
19 echo
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 echo arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 echo local
20301
e1a8d2040bd7 patch 8.2.0706: Vim9: using assert_fails() causes function to finish
Bram Moolenaar <Bram@vim.org>
parents: 20295
diff changeset
22 echo &lines
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 echo v:version
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 echo s:scriptvar
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 echo g:globalvar
21399
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
26 echo get(g:, "global")
23233
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
27 echo g:auto#var
20089
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
28 echo b:buffervar
21399
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
29 echo get(b:, "buffer")
20089
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
30 echo w:windowvar
21399
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
31 echo get(w:, "window")
20089
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
32 echo t:tabpagevar
21399
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
33 echo get(t:, "tab")
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 echo &tabstop
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 echo $ENVVAR
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 echo @z
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
39 def Test_disassemble_load()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 assert_fails('disass NoFunc', 'E1061:')
21821
0deb6f96a5a3 patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 21771
diff changeset
41 assert_fails('disass NotCompiled', 'E1091:')
19390
e4b326c9424a patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents: 19342
diff changeset
42 assert_fails('disass', 'E471:')
e4b326c9424a patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents: 19342
diff changeset
43 assert_fails('disass [', 'E475:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 21232
diff changeset
44 assert_fails('disass 234', 'E129:')
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 21232
diff changeset
45 assert_fails('disass <XX>foo', 'E129:')
28934
a712ea475390 patch 8.2.4989: cannot specify a function name for :defcompile
Bram Moolenaar <Bram@vim.org>
parents: 28901
diff changeset
46 assert_fails('disass Test_disassemble_load burp', 'E488:')
a712ea475390 patch 8.2.4989: cannot specify a function name for :defcompile
Bram Moolenaar <Bram@vim.org>
parents: 28901
diff changeset
47 assert_fails('disass debug debug Test_disassemble_load', 'E488:')
a712ea475390 patch 8.2.4989: cannot specify a function name for :defcompile
Bram Moolenaar <Bram@vim.org>
parents: 28901
diff changeset
48 assert_fails('disass profile profile Test_disassemble_load', 'E488:')
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
50 var res = execute('disass s:ScriptFuncLoad')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
51 assert_match('<SNR>\d*_ScriptFuncLoad.*' ..
23183
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
52 'buffers\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
53 '\d\+ EXEC \+buffers\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
54 'echo\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
55 'echo arg\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
56 '\d\+ LOAD arg\[-1\]\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
57 '\d\+ ECHO 1\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
58 'echo local\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
59 '\d\+ LOAD $0\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
60 '\d\+ ECHO 1\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
61 'echo &lines\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
62 '\d\+ LOADOPT &lines\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
63 '\d\+ ECHO 1\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
64 'echo v:version\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
65 '\d\+ LOADV v:version\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
66 '\d\+ ECHO 1\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
67 'echo s:scriptvar\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
68 '\d\+ LOADS s:scriptvar from .*test_vim9_disassemble.vim\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
69 '\d\+ ECHO 1\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
70 'echo g:globalvar\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
71 '\d\+ LOADG g:globalvar\_s*' ..
4d5d12138b36 patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents: 23156
diff changeset
72 '\d\+ ECHO 1\_s*' ..
21399
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
73 'echo get(g:, "global")\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
74 '\d\+ LOAD g:\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
75 '\d\+ PUSHS "global"\_s*' ..
23233
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
76 '\d\+ BCALL get(argc 2)\_s*' ..
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
77 '\d\+ ECHO 1\_s*' ..
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
78 'echo g:auto#var\_s*' ..
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
79 '\d\+ LOADAUTO g:auto#var\_s*' ..
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
80 '\d\+ ECHO 1\_s*' ..
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
81 'echo b:buffervar\_s*' ..
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
82 '\d\+ LOADB b:buffervar\_s*' ..
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
83 '\d\+ ECHO 1\_s*' ..
21399
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
84 'echo get(b:, "buffer")\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
85 '\d\+ LOAD b:\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
86 '\d\+ PUSHS "buffer"\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
87 '\d\+ BCALL get(argc 2).*' ..
20089
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
88 ' LOADW w:windowvar.*' ..
21399
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
89 'echo get(w:, "window")\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
90 '\d\+ LOAD w:\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
91 '\d\+ PUSHS "window"\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
92 '\d\+ BCALL get(argc 2).*' ..
20089
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
93 ' LOADT t:tabpagevar.*' ..
21399
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
94 'echo get(t:, "tab")\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
95 '\d\+ LOAD t:\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
96 '\d\+ PUSHS "tab"\_s*' ..
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21397
diff changeset
97 '\d\+ BCALL get(argc 2).*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
98 ' LOADENV $ENVVAR.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
99 ' LOADREG @z.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
100 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
103 def s:EditExpand()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
104 var filename = "file"
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
105 var filenr = 123
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
106 edit the`=filename``=filenr`.txt
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
107 enddef
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
108
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
109 def Test_disassemble_exec_expr()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
110 var res = execute('disass s:EditExpand')
21755
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
111 assert_match('<SNR>\d*_EditExpand\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
112 ' var filename = "file"\_s*' ..
21755
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
113 '\d PUSHS "file"\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
114 '\d STORE $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
115 ' var filenr = 123\_s*' ..
21755
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
116 '\d STORE 123 in $1\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
117 ' edit the`=filename``=filenr`.txt\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
118 '\d PUSHS "edit the"\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
119 '\d LOAD $0\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
120 '\d LOAD $1\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
121 '\d 2STRING stack\[-1\]\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
122 '\d\+ PUSHS ".txt"\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
123 '\d\+ EXECCONCAT 4\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
124 '\d\+ RETURN void',
21755
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
125 res)
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
126 enddef
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
127
24826
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
128 if has('python3')
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
129 def s:PyHeredoc()
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
130 python3 << EOF
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
131 print('hello')
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
132 EOF
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
133 enddef
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
134
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
135 def Test_disassemble_python_heredoc()
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
136 var res = execute('disass s:PyHeredoc')
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
137 assert_match('<SNR>\d*_PyHeredoc.*' ..
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
138 " python3 << EOF^@ print('hello')^@EOF\\_s*" ..
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
139 '\d EXEC_SPLIT python3 << EOF^@ print(''hello'')^@EOF\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
140 '\d RETURN void',
24826
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
141 res)
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
142 enddef
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
143 endif
a8d64f1a223b patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents: 24796
diff changeset
144
24488
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
145 def s:Substitute()
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
146 var expr = "abc"
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
147 :%s/a/\=expr/&g#c
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
148 enddef
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
149
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
150 def Test_disassemble_substitute()
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
151 var res = execute('disass s:Substitute')
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
152 assert_match('<SNR>\d*_Substitute.*' ..
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
153 ' var expr = "abc"\_s*' ..
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
154 '\d PUSHS "abc"\_s*' ..
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
155 '\d STORE $0\_s*' ..
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
156 ' :%s/a/\\=expr/&g#c\_s*' ..
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
157 '\d SUBSTITUTE :%s/a/\\=expr/&g#c\_s*' ..
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
158 ' 0 LOAD $0\_s*' ..
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
159 ' -------------\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
160 '\d RETURN void',
24488
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
161 res)
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
162 enddef
f293bb501b30 patch 8.2.2784: Vim9: cannot use =expr in :substitute
Bram Moolenaar <Bram@vim.org>
parents: 24475
diff changeset
163
24606
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
164
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
165 def s:SearchPair()
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
166 var col = 8
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
167 searchpair("{", "", "}", "", "col('.') > col")
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
168 enddef
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
169
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
170 def Test_disassemble_seachpair()
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
171 var res = execute('disass s:SearchPair')
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
172 assert_match('<SNR>\d*_SearchPair.*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
173 ' var col = 8\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
174 '\d STORE 8 in $0\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
175 ' searchpair("{", "", "}", "", "col(''.'') > col")\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
176 '\d PUSHS "{"\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
177 '\d PUSHS ""\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
178 '\d PUSHS "}"\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
179 '\d PUSHS ""\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
180 '\d INSTR\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
181 ' 0 PUSHS "."\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
182 ' 1 BCALL col(argc 1)\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
183 ' 2 LOAD $0\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
184 ' 3 COMPARENR >\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
185 ' -------------\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
186 '\d BCALL searchpair(argc 5)\_s*' ..
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
187 '\d DROP\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
188 '\d RETURN void',
24606
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
189 res)
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
190 enddef
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
191
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24590
diff changeset
192
28692
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
193 def s:SubstituteExpr()
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
194 substitute('a', 'b', '\=123', 'g')
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
195 enddef
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
196
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
197 def Test_disassemble_substitute_expr()
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
198 var res = execute('disass s:SubstituteExpr')
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
199 assert_match('<SNR>\d*_SubstituteExpr.*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
200 'substitute(''a'', ''b'', ''\\=123'', ''g'')\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
201 '\d PUSHS "a"\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
202 '\d PUSHS "b"\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
203 '\d INSTR\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
204 ' 0 PUSHNR 123\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
205 ' -------------\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
206 '\d PUSHS "g"\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
207 '\d BCALL substitute(argc 4)\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
208 '\d DROP\_s*' ..
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
209 '\d RETURN void',
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
210 res)
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
211 enddef
bfd8e25fa207 patch 8.2.4870: Vim9: expression in :substitute is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 28625
diff changeset
212
24490
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
213 def s:RedirVar()
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
214 var result: string
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
215 redir =>> result
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
216 echo "text"
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
217 redir END
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
218 enddef
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
219
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
220 def Test_disassemble_redir_var()
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
221 var res = execute('disass s:RedirVar')
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
222 assert_match('<SNR>\d*_RedirVar.*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
223 ' var result: string\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
224 '\d PUSHS "\[NULL\]"\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
225 '\d STORE $0\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
226 ' redir =>> result\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
227 '\d REDIR\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
228 ' echo "text"\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
229 '\d PUSHS "text"\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
230 '\d ECHO 1\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
231 ' redir END\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
232 '\d LOAD $0\_s*' ..
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
233 '\d REDIR END\_s*' ..
28598
d550054e1328 patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
234 '\d CONCAT size 2\_s*' ..
24490
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
235 '\d STORE $0\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
236 '\d RETURN void',
24490
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
237 res)
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
238 enddef
08050e45bd06 patch 8.2.2785: Vim9: cannot redirect to local variable
Bram Moolenaar <Bram@vim.org>
parents: 24488
diff changeset
239
24590
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
240 def s:Cexpr()
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
241 var errors = "list of errors"
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
242 cexpr errors
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
243 enddef
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
244
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
245 def Test_disassemble_cexpr()
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
246 var res = execute('disass s:Cexpr')
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
247 assert_match('<SNR>\d*_Cexpr.*' ..
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
248 ' var errors = "list of errors"\_s*' ..
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
249 '\d PUSHS "list of errors"\_s*' ..
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
250 '\d STORE $0\_s*' ..
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
251 ' cexpr errors\_s*' ..
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
252 '\d CEXPR pre cexpr\_s*' ..
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
253 '\d LOAD $0\_s*' ..
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
254 '\d CEXPR core cexpr "cexpr errors"\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
255 '\d RETURN void',
24590
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
256 res)
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
257 enddef
2818f846f099 patch 8.2.2834: Vim9: :cexpr does not work with local variables
Bram Moolenaar <Bram@vim.org>
parents: 24504
diff changeset
258
21755
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
259 def s:YankRange()
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
260 norm! m[jjm]
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
261 :'[,']yank
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
262 enddef
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
263
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
264 def Test_disassemble_yank_range()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
265 var res = execute('disass s:YankRange')
21755
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
266 assert_match('<SNR>\d*_YankRange.*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
267 ' norm! m\[jjm\]\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
268 '\d EXEC norm! m\[jjm\]\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
269 ' :''\[,''\]yank\_s*' ..
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
270 '\d EXEC :''\[,''\]yank\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
271 '\d RETURN void',
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
272 res)
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
273 enddef
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
274
22176
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
275 def s:PutExpr()
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
276 :3put ="text"
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
277 enddef
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
278
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
279 def Test_disassemble_put_expr()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
280 var res = execute('disass s:PutExpr')
22176
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
281 assert_match('<SNR>\d*_PutExpr.*' ..
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
282 ' :3put ="text"\_s*' ..
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
283 '\d PUSHS "text"\_s*' ..
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
284 '\d PUT = 3\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
285 '\d RETURN void',
22176
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
286 res)
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
287 enddef
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
288
23156
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
289 def s:PutRange()
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
290 :$-2put a
28625
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
291 :$-3put! b
23156
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
292 enddef
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
293
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
294 def Test_disassemble_put_range()
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
295 var res = execute('disass s:PutRange')
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
296 assert_match('<SNR>\d*_PutRange.*' ..
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
297 ' :$-2put a\_s*' ..
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
298 '\d RANGE $-2\_s*' ..
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
299 '\d PUT a range\_s*' ..
28625
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
300
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
301 ' :$-3put! b\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
302 '\d RANGE $-3\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
303 '\d PUT b above range\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
304 '\d RETURN void',
23156
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
305 res)
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
306 enddef
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
307
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 def s:ScriptFuncPush()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
309 var localbool = true
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
310 var localspec = v:none
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
311 var localblob = 0z1234
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 if has('float')
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
313 var localfloat = 1.234
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 endif
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
317 def Test_disassemble_push()
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29782
diff changeset
318 mkdir('Xdisdir/autoload', 'p')
27376
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
319 var save_rtp = &rtp
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29782
diff changeset
320 exe 'set rtp^=' .. getcwd() .. '/Xdisdir'
27376
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
321
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
322 var lines =<< trim END
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
323 vim9script
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
324 END
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29782
diff changeset
325 writefile(lines, 'Xdisdir/autoload/autoscript.vim')
27376
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
326
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
327 lines =<< trim END
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
328 vim9script
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
329 import autoload 'autoscript.vim'
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
330
27669
5c4ab8d4472c patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents: 27541
diff changeset
331 def AutoloadFunc()
27376
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
332 &operatorfunc = autoscript.Opfunc
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
333 enddef
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
334
27669
5c4ab8d4472c patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents: 27541
diff changeset
335 var res = execute('disass AutoloadFunc')
27376
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
336 assert_match('<SNR>\d*_AutoloadFunc.*' ..
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
337 '&operatorfunc = autoscript.Opfunc\_s*' ..
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
338 '0 AUTOLOAD autoscript#Opfunc\_s*' ..
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
339 '1 STOREFUNCOPT &operatorfunc\_s*' ..
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
340 '2 RETURN void',
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
341 res)
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
342 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
343 v9.CheckScriptSuccess(lines)
27376
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
344
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29782
diff changeset
345 delete('Xdisdir', 'rf')
27376
1a6421c5be20 patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Bram Moolenaar <Bram@vim.org>
parents: 26937
diff changeset
346 &rtp = save_rtp
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348
28249
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
349 def Test_disassemble_import_autoload()
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
350 writefile(['vim9script'], 'XimportAL.vim')
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
351
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
352 var lines =<< trim END
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
353 vim9script
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
354 import autoload './XimportAL.vim'
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
355
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
356 def AutoloadFunc()
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
357 echo XimportAL.SomeFunc()
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
358 echo XimportAL.someVar
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
359 XimportAL.someVar = "yes"
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
360 enddef
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
361
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
362 var res = execute('disass AutoloadFunc')
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
363 assert_match('<SNR>\d*_AutoloadFunc.*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
364 'echo XimportAL.SomeFunc()\_s*' ..
28251
9d90eef65a46 patch 8.2.4651: test fails because path differs
Bram Moolenaar <Bram@vim.org>
parents: 28249
diff changeset
365 '\d SOURCE .*/testdir/XimportAL.vim\_s*' ..
28249
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
366 '\d PUSHFUNC "<80><fd>R\d\+_SomeFunc"\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
367 '\d PCALL top (argc 0)\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
368 '\d PCALL end\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
369 '\d ECHO 1\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
370
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
371 'echo XimportAL.someVar\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
372 '\d SOURCE .*/testdir/XimportAL.vim\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
373 '\d LOADEXPORT s:someVar from .*/testdir/XimportAL.vim\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
374 '\d ECHO 1\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
375
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
376 'XimportAL.someVar = "yes"\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
377 '\d\+ PUSHS "yes"\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
378 '\d\+ SOURCE .*/testdir/XimportAL.vim\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
379 '\d\+ STOREEXPORT someVar in .*/testdir/XimportAL.vim\_s*' ..
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
380
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
381 '\d\+ RETURN void',
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
382 res)
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
383 END
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
384 v9.CheckScriptSuccess(lines)
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
385
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
386 delete('XimportAL.vim')
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
387 enddef
4b322951ebac patch 8.2.4650: "import autoload" only works with using 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 28217
diff changeset
388
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 def s:ScriptFuncStore()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
390 var localnr = 1
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 localnr = 2
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
392 var localstr = 'abc'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 localstr = 'xyz'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 v:char = 'abc'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 s:scriptvar = 'sv'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 g:globalvar = 'gv'
23233
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
397 g:auto#var = 'av'
20089
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
398 b:buffervar = 'bv'
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
399 w:windowvar = 'wv'
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
400 t:tabpagevar = 'tv'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 &tabstop = 8
26470
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
402 &opfunc = (t) => len(t)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 $ENVVAR = 'ev'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 @z = 'rv'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
407 def Test_disassemble_store()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
408 var res = execute('disass s:ScriptFuncStore')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
409 assert_match('<SNR>\d*_ScriptFuncStore.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
410 'var localnr = 1.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
411 'localnr = 2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
412 ' STORE 2 in $0.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
413 'var localstr = ''abc''.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
414 'localstr = ''xyz''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
415 ' STORE $1.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
416 'v:char = ''abc''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
417 'STOREV v:char.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
418 's:scriptvar = ''sv''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
419 ' STORES s:scriptvar in .*test_vim9_disassemble.vim.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
420 'g:globalvar = ''gv''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
421 ' STOREG g:globalvar.*' ..
23233
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
422 'g:auto#var = ''av''.*' ..
657216220293 patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents: 23183
diff changeset
423 ' STOREAUTO g:auto#var.*' ..
20089
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
424 'b:buffervar = ''bv''.*' ..
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
425 ' STOREB b:buffervar.*' ..
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
426 'w:windowvar = ''wv''.*' ..
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
427 ' STOREW w:windowvar.*' ..
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
428 't:tabpagevar = ''tv''.*' ..
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
429 ' STORET t:tabpagevar.*' ..
26470
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
430 '&tabstop = 8\_s*' ..
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
431 '\d\+ PUSHNR 8\_s*' ..
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
432 '\d\+ STOREOPT &tabstop\_s*' ..
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
433 '&opfunc = (t) => len(t)\_s*' ..
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
434 '\d\+ FUNCREF <lambda>\d\+\_s*' ..
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
435 '\d\+ STOREFUNCOPT &opfunc\_s*' ..
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
436 '$ENVVAR = ''ev''\_s*' ..
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
437 '\d\+ PUSHS "ev"\_s*' ..
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
438 '\d\+ STOREENV $ENVVAR\_s*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
439 '@z = ''rv''.*' ..
26470
ff0310e6f889 patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents: 26372
diff changeset
440 '\d\+ STOREREG @z.*',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
441 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
444 def s:ScriptFuncStoreMember()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
445 var locallist: list<number> = []
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
446 locallist[0] = 123
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
447 var localdict: dict<number> = {}
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
448 localdict["a"] = 456
24475
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
449 var localblob: blob = 0z1122
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
450 localblob[1] = 33
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
451 enddef
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
452
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
453 def Test_disassemble_store_member()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
454 var res = execute('disass s:ScriptFuncStoreMember')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
455 assert_match('<SNR>\d*_ScriptFuncStoreMember\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
456 'var locallist: list<number> = []\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
457 '\d NEWLIST size 0\_s*' ..
23458
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23438
diff changeset
458 '\d SETTYPE list<number>\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
459 '\d STORE $0\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
460 'locallist\[0\] = 123\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
461 '\d PUSHNR 123\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
462 '\d PUSHNR 0\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
463 '\d LOAD $0\_s*' ..
24475
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
464 '\d STOREINDEX list\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
465 'var localdict: dict<number> = {}\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
466 '\d NEWDICT size 0\_s*' ..
23458
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23438
diff changeset
467 '\d SETTYPE dict<number>\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
468 '\d STORE $1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
469 'localdict\["a"\] = 456\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
470 '\d\+ PUSHNR 456\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
471 '\d\+ PUSHS "a"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
472 '\d\+ LOAD $1\_s*' ..
24475
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
473 '\d\+ STOREINDEX dict\_s*' ..
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
474 'var localblob: blob = 0z1122\_s*' ..
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
475 '\d\+ PUSHBLOB 0z1122\_s*' ..
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
476 '\d\+ STORE $2\_s*' ..
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
477 'localblob\[1\] = 33\_s*' ..
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
478 '\d\+ PUSHNR 33\_s*' ..
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
479 '\d\+ PUSHNR 1\_s*' ..
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
480 '\d\+ LOAD $2\_s*' ..
96905804bf5a patch 8.2.2777: Vim9: blob operations not tested in all ways
Bram Moolenaar <Bram@vim.org>
parents: 24444
diff changeset
481 '\d\+ STOREINDEX blob\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
482 '\d\+ RETURN void',
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
483 res)
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
484 enddef
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
485
28002
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
486 if has('job')
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
487 def s:StoreNull()
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
488 var ss = null_string
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
489 var bb = null_blob
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
490 var dd = null_dict
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
491 var ll = null_list
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
492 var Ff = null_function
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
493 var Pp = null_partial
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
494 var jj = null_job
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
495 var cc = null_channel
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
496 enddef
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
497
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
498 def Test_disassemble_assign_null()
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
499 var res = execute('disass s:StoreNull')
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
500 assert_match('<SNR>\d*_StoreNull\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
501 'var ss = null_string\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
502 '\d\+ PUSHS "\[NULL\]"\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
503 '\d\+ STORE $\d\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
504
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
505 'var bb = null_blob\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
506 '\d\+ PUSHBLOB 0z\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
507 '\d\+ STORE $\d\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
508
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
509 'var dd = null_dict\_s*' ..
28217
662d2d5db9a6 patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
510 '\d\+ NEWDICT size -1\_s*' ..
28002
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
511 '\d\+ STORE $\d\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
512
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
513 'var ll = null_list\_s*' ..
28217
662d2d5db9a6 patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
514 '\d\+ NEWLIST size -1\_s*' ..
28002
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
515 '\d\+ STORE $\d\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
516
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
517 'var Ff = null_function\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
518 '\d\+ PUSHFUNC "\[none\]"\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
519 '\d\+ STORE $\d\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
520
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
521 'var Pp = null_partial\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
522 '\d\+ NEWPARTIAL\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
523 '\d\+ STORE $\d\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
524
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
525 'var jj = null_job\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
526 '\d\+ PUSHJOB "no process"\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
527 '\d\+ STORE $\d\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
528
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
529 'var cc = null_channel\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
530 '\d\+ PUSHCHANNEL 0\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
531 '\d\+ STORE $\d\_s*' ..
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
532
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
533 '\d\+ RETURN void',
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
534 res)
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
535 enddef
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
536 endif
1012048eed26 patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents: 27924
diff changeset
537
23266
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
538 def s:ScriptFuncStoreIndex()
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
539 var d = {dd: {}}
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
540 d.dd[0] = 0
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
541 enddef
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
542
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
543 def Test_disassemble_store_index()
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
544 var res = execute('disass s:ScriptFuncStoreIndex')
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
545 assert_match('<SNR>\d*_ScriptFuncStoreIndex\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
546 'var d = {dd: {}}\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
547 '\d PUSHS "dd"\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
548 '\d NEWDICT size 0\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
549 '\d NEWDICT size 1\_s*' ..
27728
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
550 '\d SETTYPE dict<dict<unknown>>\_s*' ..
23266
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
551 '\d STORE $0\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
552 'd.dd\[0\] = 0\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
553 '\d PUSHNR 0\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
554 '\d PUSHNR 0\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
555 '\d LOAD $0\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
556 '\d MEMBER dd\_s*' ..
25800
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
557 '\d\+ USEDICT\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
558 '\d\+ STOREINDEX any\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
559 '\d\+ RETURN void',
23266
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
560 res)
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
561 enddef
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
562
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
563 def s:ListAssign()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
564 var x: string
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
565 var y: string
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
566 var l: list<any>
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
567 [x, y; l] = g:stringlist
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
568 enddef
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
569
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
570 def Test_disassemble_list_assign()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
571 var res = execute('disass s:ListAssign')
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
572 assert_match('<SNR>\d*_ListAssign\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
573 'var x: string\_s*' ..
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
574 '\d PUSHS "\[NULL\]"\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
575 '\d STORE $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
576 'var y: string\_s*' ..
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
577 '\d PUSHS "\[NULL\]"\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
578 '\d STORE $1\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
579 'var l: list<any>\_s*' ..
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
580 '\d NEWLIST size 0\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
581 '\d STORE $2\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
582 '\[x, y; l\] = g:stringlist\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
583 '\d LOADG g:stringlist\_s*' ..
22284
6b385c2b9ff5 patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents: 22196
diff changeset
584 '\d CHECKTYPE list<any> stack\[-1\]\_s*' ..
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
585 '\d CHECKLEN >= 2\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
586 '\d\+ ITEM 0\_s*' ..
28901
11609f025219 patch 8.2.4973: Vim9: type error for list unpack mentions argument
Bram Moolenaar <Bram@vim.org>
parents: 28718
diff changeset
587 '\d\+ CHECKTYPE string stack\[-1\] var 1\_s*' ..
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
588 '\d\+ STORE $0\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
589 '\d\+ ITEM 1\_s*' ..
28901
11609f025219 patch 8.2.4973: Vim9: type error for list unpack mentions argument
Bram Moolenaar <Bram@vim.org>
parents: 28718
diff changeset
590 '\d\+ CHECKTYPE string stack\[-1\] var 2\_s*' ..
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
591 '\d\+ STORE $1\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
592 '\d\+ SLICE 2\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
593 '\d\+ STORE $2\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
594 '\d\+ RETURN void',
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
595 res)
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
596 enddef
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
597
24984
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
598 def s:ListAssignWithOp()
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
599 var a = 2
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
600 var b = 3
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
601 [a, b] += [4, 5]
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
602 enddef
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
603
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
604 def Test_disassemble_list_assign_with_op()
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
605 var res = execute('disass s:ListAssignWithOp')
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
606 assert_match('<SNR>\d*_ListAssignWithOp\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
607 'var a = 2\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
608 '\d STORE 2 in $0\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
609 'var b = 3\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
610 '\d STORE 3 in $1\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
611 '\[a, b\] += \[4, 5\]\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
612 '\d\+ PUSHNR 4\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
613 '\d\+ PUSHNR 5\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
614 '\d\+ NEWLIST size 2\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
615 '\d\+ LOAD $0\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
616 '\d\+ ITEM 0 with op\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
617 '\d\+ OPNR +\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
618 '\d\+ STORE $0\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
619 '\d\+ LOAD $1\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
620 '\d\+ ITEM 1 with op\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
621 '\d\+ OPNR +\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
622 '\d\+ STORE $1\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
623 '\d\+ DROP\_s*' ..
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
624 '\d\+ RETURN void',
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
625 res)
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
626 enddef
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24936
diff changeset
627
22633
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
628 def s:ListAdd()
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
629 var l: list<number> = []
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
630 add(l, 123)
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
631 add(l, g:aNumber)
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
632 enddef
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
633
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
634 def Test_disassemble_list_add()
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
635 var res = execute('disass s:ListAdd')
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
636 assert_match('<SNR>\d*_ListAdd\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
637 'var l: list<number> = []\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
638 '\d NEWLIST size 0\_s*' ..
23458
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23438
diff changeset
639 '\d SETTYPE list<number>\_s*' ..
22633
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
640 '\d STORE $0\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
641 'add(l, 123)\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
642 '\d LOAD $0\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
643 '\d PUSHNR 123\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
644 '\d LISTAPPEND\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
645 '\d DROP\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
646 'add(l, g:aNumber)\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
647 '\d LOAD $0\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
648 '\d\+ LOADG g:aNumber\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
649 '\d\+ CHECKTYPE number stack\[-1\]\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
650 '\d\+ LISTAPPEND\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
651 '\d\+ DROP\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
652 '\d\+ RETURN void',
22633
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
653 res)
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
654 enddef
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
655
22637
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
656 def s:BlobAdd()
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
657 var b: blob = 0z
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
658 add(b, 123)
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
659 add(b, g:aNumber)
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
660 enddef
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
661
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
662 def Test_disassemble_blob_add()
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
663 var res = execute('disass s:BlobAdd')
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
664 assert_match('<SNR>\d*_BlobAdd\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
665 'var b: blob = 0z\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
666 '\d PUSHBLOB 0z\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
667 '\d STORE $0\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
668 'add(b, 123)\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
669 '\d LOAD $0\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
670 '\d PUSHNR 123\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
671 '\d BLOBAPPEND\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
672 '\d DROP\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
673 'add(b, g:aNumber)\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
674 '\d LOAD $0\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
675 '\d\+ LOADG g:aNumber\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
676 '\d\+ CHECKTYPE number stack\[-1\]\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
677 '\d\+ BLOBAPPEND\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
678 '\d\+ DROP\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
679 '\d\+ RETURN void',
22637
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
680 res)
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
681 enddef
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
682
24444
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
683 def s:BlobIndexSlice()
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
684 var b: blob = 0z112233
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
685 echo b[1]
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
686 echo b[1 : 2]
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
687 enddef
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
688
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
689 def Test_disassemble_blob_index_slice()
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
690 var res = execute('disass s:BlobIndexSlice')
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
691 assert_match('<SNR>\d*_BlobIndexSlice\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
692 'var b: blob = 0z112233\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
693 '\d PUSHBLOB 0z112233\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
694 '\d STORE $0\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
695 'echo b\[1\]\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
696 '\d LOAD $0\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
697 '\d PUSHNR 1\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
698 '\d BLOBINDEX\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
699 '\d ECHO 1\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
700 'echo b\[1 : 2\]\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
701 '\d LOAD $0\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
702 '\d PUSHNR 1\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
703 '\d\+ PUSHNR 2\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
704 '\d\+ BLOBSLICE\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
705 '\d\+ ECHO 1\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
706 '\d\+ RETURN void',
24444
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
707 res)
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
708 enddef
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
709
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
710 def s:ScriptFuncUnlet()
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
711 g:somevar = "value"
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
712 unlet g:somevar
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
713 unlet! g:somevar
20099
058b41f85bcb patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents: 20091
diff changeset
714 unlet $SOMEVAR
28625
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
715
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
716 var l = [1, 2, 3]
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
717 unlet l[2]
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
718 unlet l[0 : 1]
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
719 enddef
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
720
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
721 def Test_disassemble_unlet()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
722 var res = execute('disass s:ScriptFuncUnlet')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
723 assert_match('<SNR>\d*_ScriptFuncUnlet\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
724 'g:somevar = "value"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
725 '\d PUSHS "value"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
726 '\d STOREG g:somevar\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
727 'unlet g:somevar\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
728 '\d UNLET g:somevar\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
729 'unlet! g:somevar\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
730 '\d UNLET! g:somevar\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
731 'unlet $SOMEVAR\_s*' ..
28625
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
732 '\d UNLETENV $SOMEVAR\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
733
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
734 'var l = \[1, 2, 3]\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
735 '\d\+ PUSHNR 1\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
736 '\d\+ PUSHNR 2\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
737 '\d\+ PUSHNR 3\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
738 '\d\+ NEWLIST size 3\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
739 '\d\+ SETTYPE list<number>\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
740 '\d\+ STORE $0\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
741
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
742 'unlet l\[2]\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
743 '\d\+ PUSHNR 2\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
744 '\d\+ LOAD $0\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
745 '\d\+ UNLETINDEX\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
746
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
747 'unlet l\[0 : 1]\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
748 '\d\+ PUSHNR 0\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
749 '\d\+ PUSHNR 1\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
750 '\d\+ LOAD $0\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
751 '\d\+ UNLETRANGE\_s*',
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
752 res)
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
753 enddef
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
754
25605
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
755 def s:LockLocal()
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
756 var d = {a: 1}
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
757 lockvar d.a
28625
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
758 const nr = 22
25605
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
759 enddef
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
760
27728
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
761 def Test_disassemble_lock_local()
25605
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
762 var res = execute('disass s:LockLocal')
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
763 assert_match('<SNR>\d*_LockLocal\_s*' ..
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
764 'var d = {a: 1}\_s*' ..
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
765 '\d PUSHS "a"\_s*' ..
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
766 '\d PUSHNR 1\_s*' ..
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
767 '\d NEWDICT size 1\_s*' ..
27728
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
768 '\d SETTYPE dict<number>\_s*' ..
25605
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
769 '\d STORE $0\_s*' ..
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
770 'lockvar d.a\_s*' ..
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
771 '\d LOAD $0\_s*' ..
28625
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
772 '\d LOCKUNLOCK lockvar 2 d.a\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
773
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
774 'const nr = 22\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
775 '\d\+ PUSHNR 22\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
776 '\d\+ LOCKCONST\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
777 '\d\+ STORE $1',
25605
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
778 res)
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
779 enddef
6f13d9ea0d04 patch 8.2.3339: Vim9: cannot lock a member in a local dict
Bram Moolenaar <Bram@vim.org>
parents: 25579
diff changeset
780
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 def s:ScriptFuncTry()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 try
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
783 echo "yes"
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 catch /fail/
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
785 echo "no"
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 finally
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
787 throw "end"
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 endtry
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
791 def Test_disassemble_try()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
792 var res = execute('disass s:ScriptFuncTry')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
793 assert_match('<SNR>\d*_ScriptFuncTry\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
794 'try\_s*' ..
23994
3daeb2060f25 patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents: 23927
diff changeset
795 '\d TRY catch -> \d\+, finally -> \d\+, endtry -> \d\+\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
796 'echo "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
797 '\d PUSHS "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
798 '\d ECHO 1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
799 'catch /fail/\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
800 '\d JUMP -> \d\+\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
801 '\d PUSH v:exception\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
802 '\d PUSHS "fail"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
803 '\d COMPARESTRING =\~\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
804 '\d JUMP_IF_FALSE -> \d\+\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
805 '\d CATCH\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
806 'echo "no"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
807 '\d\+ PUSHS "no"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
808 '\d\+ ECHO 1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
809 'finally\_s*' ..
23994
3daeb2060f25 patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents: 23927
diff changeset
810 '\d\+ FINALLY\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
811 'throw "end"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
812 '\d\+ PUSHS "end"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
813 '\d\+ THROW\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
814 'endtry\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
815 '\d\+ ENDTRY',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
816 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 def s:ScriptFuncNew()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
820 var ll = [1, "two", 333]
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
821 var dd = {one: 1, two: "val"}
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
824 def Test_disassemble_new()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
825 var res = execute('disass s:ScriptFuncNew')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
826 assert_match('<SNR>\d*_ScriptFuncNew\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
827 'var ll = \[1, "two", 333\]\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
828 '\d PUSHNR 1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
829 '\d PUSHS "two"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
830 '\d PUSHNR 333\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
831 '\d NEWLIST size 3\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
832 '\d STORE $0\_s*' ..
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
833 'var dd = {one: 1, two: "val"}\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
834 '\d PUSHS "one"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
835 '\d PUSHNR 1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
836 '\d PUSHS "two"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
837 '\d PUSHS "val"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
838 '\d NEWDICT size 2\_s*',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
839 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
842 def s:FuncWithArg(arg: any)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 echo arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
846 func s:UserFunc()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 echo 'nothing'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
850 func s:UserFuncWithArg(arg)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 echo a:arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 def s:ScriptFuncCall(): string
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 changenr()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 char2nr("abc")
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
857 g:Test_disassemble_new()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 FuncWithArg(343)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 ScriptFuncNew()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 s:ScriptFuncNew()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861 UserFunc()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 UserFuncWithArg("foo")
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
863 var FuncRef = function("UserFunc")
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 FuncRef()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
865 var FuncRefWithArg = function("UserFuncWithArg")
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 FuncRefWithArg("bar")
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 return "yes"
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
870 def Test_disassemble_call()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
871 var res = execute('disass s:ScriptFuncCall')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
872 assert_match('<SNR>\d\+_ScriptFuncCall\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
873 'changenr()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
874 '\d BCALL changenr(argc 0)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
875 '\d DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
876 'char2nr("abc")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
877 '\d PUSHS "abc"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
878 '\d BCALL char2nr(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
879 '\d DROP\_s*' ..
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
880 'g:Test_disassemble_new()\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
881 '\d DCALL Test_disassemble_new(argc 0)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
882 '\d DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
883 'FuncWithArg(343)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
884 '\d\+ PUSHNR 343\_s*' ..
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
885 '\d\+ DCALL <SNR>\d\+_FuncWithArg(argc 1)\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
886 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
887 'ScriptFuncNew()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
888 '\d\+ DCALL <SNR>\d\+_ScriptFuncNew(argc 0)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
889 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
890 's:ScriptFuncNew()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
891 '\d\+ DCALL <SNR>\d\+_ScriptFuncNew(argc 0)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
892 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
893 'UserFunc()\_s*' ..
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
894 '\d\+ UCALL <80><fd>R\d\+_UserFunc(argc 0)\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
895 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
896 'UserFuncWithArg("foo")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
897 '\d\+ PUSHS "foo"\_s*' ..
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
898 '\d\+ UCALL <80><fd>R\d\+_UserFuncWithArg(argc 1)\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
899 '\d\+ DROP\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
900 'var FuncRef = function("UserFunc")\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
901 '\d\+ PUSHS "UserFunc"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
902 '\d\+ BCALL function(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
903 '\d\+ STORE $0\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
904 'FuncRef()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
905 '\d\+ LOAD $\d\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
906 '\d\+ PCALL (argc 0)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
907 '\d\+ DROP\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
908 'var FuncRefWithArg = function("UserFuncWithArg")\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
909 '\d\+ PUSHS "UserFuncWithArg"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
910 '\d\+ BCALL function(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
911 '\d\+ STORE $1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
912 'FuncRefWithArg("bar")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
913 '\d\+ PUSHS "bar"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
914 '\d\+ LOAD $\d\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
915 '\d\+ PCALL (argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
916 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
917 'return "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
918 '\d\+ PUSHS "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
919 '\d\+ RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
920 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922
22541
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
923
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
924 def s:CreateRefs()
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
925 var local = 'a'
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
926 def Append(arg: string)
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
927 local ..= arg
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
928 enddef
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
929 g:Append = Append
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
930 def Get(): string
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
931 return local
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
932 enddef
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
933 g:Get = Get
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
934 enddef
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
935
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
936 def Test_disassemble_closure()
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
937 CreateRefs()
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
938 var res = execute('disass g:Append')
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
939 assert_match('<lambda>\d\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
940 'local ..= arg\_s*' ..
23557
f50ee1ae4d9b patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents: 23543
diff changeset
941 '\d LOADOUTER level 1 $0\_s*' ..
22541
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
942 '\d LOAD arg\[-1\]\_s*' ..
28598
d550054e1328 patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
943 '\d CONCAT size 2\_s*' ..
23557
f50ee1ae4d9b patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents: 23543
diff changeset
944 '\d STOREOUTER level 1 $0\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
945 '\d RETURN void',
22541
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
946 res)
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
947
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
948 res = execute('disass g:Get')
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
949 assert_match('<lambda>\d\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
950 'return local\_s*' ..
23557
f50ee1ae4d9b patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents: 23543
diff changeset
951 '\d LOADOUTER level 1 $0\_s*' ..
22541
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
952 '\d RETURN',
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
953 res)
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
954
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
955 unlet g:Append
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
956 unlet g:Get
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
957 enddef
20295
bc2c9ea94ec1 patch 8.2.0703: Vim9: closure cannot store value in outer context
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
958
28623
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
959 def s:ClosureArg(arg: string)
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
960 var Ref = () => arg .. "x"
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
961 enddef
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
962
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
963 def Test_disassemble_closure_arg()
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
964 var res = execute('disass s:ClosureArg')
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
965 assert_match('<SNR>\d\+_ClosureArg\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
966 'var Ref = () => arg .. "x"\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
967 '\d FUNCREF <lambda>\d\+',
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
968 res)
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
969 var lres = execute('disass ' .. matchstr(res, '<lambda>\d\+'))
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
970 assert_match('<lambda>\d\+\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
971 'return arg .. "x"\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
972 '\d LOADOUTER level 1 arg\[-1]\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
973 '\d PUSHS "x"\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
974 '\d CONCAT size 2\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
975 '\d RETURN',
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
976 lres)
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
977 enddef
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
978
19862
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
979 def EchoArg(arg: string): string
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
980 return arg
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
981 enddef
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
982 def s:RefThis(): func
19862
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
983 return function('EchoArg')
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
984 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
985 def s:ScriptPCall()
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
986 RefThis()("text")
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
987 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
988
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
989 def Test_disassemble_pcall()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
990 var res = execute('disass s:ScriptPCall')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
991 assert_match('<SNR>\d\+_ScriptPCall\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
992 'RefThis()("text")\_s*' ..
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
993 '\d DCALL <SNR>\d\+_RefThis(argc 0)\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
994 '\d PUSHS "text"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
995 '\d PCALL top (argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
996 '\d PCALL end\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
997 '\d DROP\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
998 '\d RETURN void',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
999 res)
19862
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
1000 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
1001
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
1002
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20029
diff changeset
1003 def s:FuncWithForwardCall(): string
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20029
diff changeset
1004 return g:DefinedLater("yes")
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
1005 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
1006
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
1007 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
1008 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
1009 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
1010
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
1011 def Test_disassemble_update_instr()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1012 var res = execute('disass s:FuncWithForwardCall')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1013 assert_match('FuncWithForwardCall\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1014 'return g:DefinedLater("yes")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1015 '\d PUSHS "yes"\_s*' ..
20528
489cb75c76b6 patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents: 20407
diff changeset
1016 '\d DCALL DefinedLater(argc 1)\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1017 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1018 res)
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
1019
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21299
diff changeset
1020 # Calling the function will change UCALL into the faster DCALL
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
1021 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
1022
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20029
diff changeset
1023 res = execute('disass s:FuncWithForwardCall')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1024 assert_match('FuncWithForwardCall\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1025 'return g:DefinedLater("yes")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1026 '\d PUSHS "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1027 '\d DCALL DefinedLater(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1028 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1029 res)
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
1030 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
1031
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
1032
24504
e7577f79d6eb patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents: 24490
diff changeset
1033 def FuncWithDefault(l: number, arg: string = "default", nr = 77): string
24272
cabed216cc2f patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
1034 return arg .. nr
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
1035 enddef
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
1036
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
1037 def Test_disassemble_call_default()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1038 var res = execute('disass FuncWithDefault')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1039 assert_match('FuncWithDefault\_s*' ..
24504
e7577f79d6eb patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents: 24490
diff changeset
1040 ' arg = "default"\_s*' ..
24272
cabed216cc2f patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
1041 '\d JUMP_IF_ARG_SET arg\[-2\] -> 3\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1042 '\d PUSHS "default"\_s*' ..
24272
cabed216cc2f patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
1043 '\d STORE arg\[-2]\_s*' ..
24504
e7577f79d6eb patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents: 24490
diff changeset
1044 ' nr = 77\_s*' ..
24272
cabed216cc2f patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
1045 '3 JUMP_IF_ARG_SET arg\[-1\] -> 6\_s*' ..
cabed216cc2f patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
1046 '\d PUSHNR 77\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1047 '\d STORE arg\[-1]\_s*' ..
24504
e7577f79d6eb patch 8.2.2792: Vim9: :disas shows instructions for default args but no text
Bram Moolenaar <Bram@vim.org>
parents: 24490
diff changeset
1048 ' return arg .. nr\_s*' ..
24272
cabed216cc2f patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
1049 '6 LOAD arg\[-2]\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1050 '\d LOAD arg\[-1]\_s*' ..
24272
cabed216cc2f patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
1051 '\d 2STRING stack\[-1]\_s*' ..
28598
d550054e1328 patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
1052 '\d\+ CONCAT size 2\_s*' ..
24272
cabed216cc2f patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
1053 '\d\+ RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1054 res)
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
1055 enddef
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
1056
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
1057
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
1058 def s:HasEval()
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1059 if has("eval")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1060 echo "yes"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1061 else
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1062 echo "no"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1063 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1064 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1065
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
1066 def s:HasNothing()
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1067 if has("nothing")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1068 echo "yes"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1069 else
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1070 echo "no"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1071 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1072 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1073
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
1074 def s:HasSomething()
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1075 if has("nothing")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1076 echo "nothing"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1077 elseif has("something")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1078 echo "something"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1079 elseif has("eval")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1080 echo "eval"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1081 elseif has("less")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1082 echo "less"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1083 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1084 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1085
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
1086 def s:HasGuiRunning()
22842
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1087 if has("gui_running")
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1088 echo "yes"
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1089 else
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1090 echo "no"
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1091 endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1092 enddef
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1093
28287
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1094 def s:LenConstant(): number
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1095 return len("foo") + len("fighters")
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1096 enddef
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1097
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1098 def Test_disassemble_const_expr()
28287
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1099 var instr = execute('disassemble LenConstant')
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1100 assert_match('LenConstant\_s*' ..
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1101 'return len("foo") + len("fighters")\_s*' ..
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1102 '\d PUSHNR 11\_s*',
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1103 instr)
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1104 assert_notmatch('BCALL len', instr)
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1105
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1106 assert_equal("\nyes", execute('HasEval()'))
28287
dc68c111cf7a patch 8.2.4669: in compiled code len('string') is not inlined
Bram Moolenaar <Bram@vim.org>
parents: 28251
diff changeset
1107 instr = execute('disassemble HasEval')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1108 assert_match('HasEval\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1109 'if has("eval")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1110 'echo "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1111 '\d PUSHS "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1112 '\d ECHO 1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1113 'else\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1114 'echo "no"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1115 'endif\_s*',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1116 instr)
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1117 assert_notmatch('JUMP', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1118
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1119 assert_equal("\nno", execute('HasNothing()'))
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1120 instr = execute('disassemble HasNothing')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1121 assert_match('HasNothing\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1122 'if has("nothing")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1123 'echo "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1124 'else\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1125 'echo "no"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1126 '\d PUSHS "no"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1127 '\d ECHO 1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1128 'endif',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1129 instr)
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1130 assert_notmatch('PUSHS "yes"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1131 assert_notmatch('JUMP', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1132
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1133 assert_equal("\neval", execute('HasSomething()'))
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1134 instr = execute('disassemble HasSomething')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1135 assert_match('HasSomething.*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1136 'if has("nothing")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1137 'echo "nothing"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1138 'elseif has("something")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1139 'echo "something"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1140 'elseif has("eval")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1141 'echo "eval"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1142 '\d PUSHS "eval"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1143 '\d ECHO 1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1144 'elseif has("less").*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1145 'echo "less"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1146 'endif',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1147 instr)
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1148 assert_notmatch('PUSHS "nothing"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1149 assert_notmatch('PUSHS "something"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1150 assert_notmatch('PUSHS "less"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1151 assert_notmatch('JUMP', instr)
22842
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1152
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1153 var result: string
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1154 var instr_expected: string
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1155 if has('gui')
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1156 if has('gui_running')
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1157 # GUI already running, always returns "yes"
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1158 result = "\nyes"
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1159 instr_expected = 'HasGuiRunning.*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1160 'if has("gui_running")\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1161 ' echo "yes"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1162 '\d PUSHS "yes"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1163 '\d ECHO 1\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1164 'else\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1165 ' echo "no"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1166 'endif'
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1167 else
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1168 result = "\nno"
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1169 if has('unix')
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1170 # GUI not running but can start later, call has()
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1171 instr_expected = 'HasGuiRunning.*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1172 'if has("gui_running")\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1173 '\d PUSHS "gui_running"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1174 '\d BCALL has(argc 1)\_s*' ..
24430
fe71212fd202 patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents: 24272
diff changeset
1175 '\d COND2BOOL\_s*' ..
22842
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1176 '\d JUMP_IF_FALSE -> \d\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1177 ' echo "yes"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1178 '\d PUSHS "yes"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1179 '\d ECHO 1\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1180 'else\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1181 '\d JUMP -> \d\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1182 ' echo "no"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1183 '\d PUSHS "no"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1184 '\d ECHO 1\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1185 'endif'
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1186 else
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1187 # GUI not running, always return "no"
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1188 instr_expected = 'HasGuiRunning.*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1189 'if has("gui_running")\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1190 ' echo "yes"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1191 'else\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1192 ' echo "no"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1193 '\d PUSHS "no"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1194 '\d ECHO 1\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1195 'endif'
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1196 endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1197 endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1198 else
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1199 # GUI not supported, always return "no"
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1200 result = "\nno"
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1201 instr_expected = 'HasGuiRunning.*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1202 'if has("gui_running")\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1203 ' echo "yes"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1204 'else\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1205 ' echo "no"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1206 '\d PUSHS "no"\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1207 '\d ECHO 1\_s*' ..
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1208 'endif'
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1209 endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1210
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1211 assert_equal(result, execute('HasGuiRunning()'))
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1212 instr = execute('disassemble HasGuiRunning')
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
1213 assert_match(instr_expected, instr)
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1214 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
1215
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1216 def ReturnInIf(): string
22926
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1217 if 1 < 0
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1218 return "maybe"
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1219 endif
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1220 if g:cond
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1221 return "yes"
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1222 else
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1223 return "no"
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1224 endif
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1225 enddef
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1226
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1227 def Test_disassemble_return_in_if()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1228 var instr = execute('disassemble ReturnInIf')
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1229 assert_match('ReturnInIf\_s*' ..
22926
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1230 'if 1 < 0\_s*' ..
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1231 ' return "maybe"\_s*' ..
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1232 'endif\_s*' ..
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1233 'if g:cond\_s*' ..
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1234 '0 LOADG g:cond\_s*' ..
22860
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1235 '1 COND2BOOL\_s*' ..
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1236 '2 JUMP_IF_FALSE -> 5\_s*' ..
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1237 'return "yes"\_s*' ..
22860
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1238 '3 PUSHS "yes"\_s*' ..
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1239 '4 RETURN\_s*' ..
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1240 'else\_s*' ..
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1241 ' return "no"\_s*' ..
22860
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1242 '5 PUSHS "no"\_s*' ..
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1243 '6 RETURN$',
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1244 instr)
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1245 enddef
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
1246
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1247 def WithFunc()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1248 var Funky1: func
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1249 var Funky2: func = function("len")
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1250 var Party2: func = funcref("UserFunc")
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1251 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1252
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1253 def Test_disassemble_function()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1254 var instr = execute('disassemble WithFunc')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1255 assert_match('WithFunc\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1256 'var Funky1: func\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1257 '0 PUSHFUNC "\[none]"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1258 '1 STORE $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1259 'var Funky2: func = function("len")\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1260 '2 PUSHS "len"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1261 '3 BCALL function(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1262 '4 STORE $1\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1263 'var Party2: func = funcref("UserFunc")\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1264 '\d PUSHS "UserFunc"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1265 '\d BCALL funcref(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1266 '\d STORE $2\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
1267 '\d RETURN void',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1268 instr)
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1269 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1270
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1271 if has('channel')
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1272 def WithChannel()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1273 var job1: job
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1274 var job2: job = job_start("donothing")
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1275 var chan1: channel
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1276 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1277 endif
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1278
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1279 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
1280 CheckFeature channel
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1281
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1282 var instr = execute('disassemble WithChannel')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1283 assert_match('WithChannel\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1284 'var job1: job\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1285 '\d PUSHJOB "no process"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1286 '\d STORE $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1287 'var job2: job = job_start("donothing")\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1288 '\d PUSHS "donothing"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1289 '\d BCALL job_start(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1290 '\d STORE $1\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1291 'var chan1: channel\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1292 '\d PUSHCHANNEL 0\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1293 '\d STORE $2\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
1294 '\d RETURN void',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1295 instr)
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1296 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
1297
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1298 def s:WithLambda(): string
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
1299 var F = (a) => "X" .. a .. "X"
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1300 return F("x")
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1301 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1302
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1303 def Test_disassemble_lambda()
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1304 assert_equal("XxX", WithLambda())
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1305 var instr = execute('disassemble WithLambda')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1306 assert_match('WithLambda\_s*' ..
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
1307 'var F = (a) => "X" .. a .. "X"\_s*' ..
22371
15003353a464 patch 8.2.1734: Vim9: cannot use a funcref for a closure twice
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
1308 '\d FUNCREF <lambda>\d\+\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1309 '\d STORE $0\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1310 'return F("x")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1311 '\d PUSHS "x"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1312 '\d LOAD $0\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1313 '\d PCALL (argc 1)\_s*' ..
20528
489cb75c76b6 patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents: 20407
diff changeset
1314 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1315 instr)
21299
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1316
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1317 var name = substitute(instr, '.*\(<lambda>\d\+\).*', '\1', '')
21299
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1318 instr = execute('disassemble ' .. name)
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1319 assert_match('<lambda>\d\+\_s*' ..
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1320 'return "X" .. a .. "X"\_s*' ..
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1321 '\d PUSHS "X"\_s*' ..
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1322 '\d LOAD arg\[-1\]\_s*' ..
21771
fcf978444298 patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents: 21755
diff changeset
1323 '\d 2STRING_ANY stack\[-1\]\_s*' ..
28598
d550054e1328 patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
1324 '\d CONCAT size 2\_s*' ..
21299
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1325 '\d PUSHS "X"\_s*' ..
28598
d550054e1328 patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
1326 '\d CONCAT size 2\_s*' ..
21299
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1327 '\d RETURN',
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
1328 instr)
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1329 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1330
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1331 def s:LambdaWithType(): number
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
1332 var Ref = (a: number) => a + 10
22816
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1333 return Ref(g:value)
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1334 enddef
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1335
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1336 def Test_disassemble_lambda_with_type()
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1337 g:value = 5
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1338 assert_equal(15, LambdaWithType())
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1339 var instr = execute('disassemble LambdaWithType')
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1340 assert_match('LambdaWithType\_s*' ..
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
1341 'var Ref = (a: number) => a + 10\_s*' ..
22816
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1342 '\d FUNCREF <lambda>\d\+\_s*' ..
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1343 '\d STORE $0\_s*' ..
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1344 'return Ref(g:value)\_s*' ..
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1345 '\d LOADG g:value\_s*' ..
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1346 '\d LOAD $0\_s*' ..
23691
0d56d4f107d8 patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents: 23654
diff changeset
1347 '\d CHECKTYPE number stack\[-2\] arg 1\_s*' ..
22816
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1348 '\d PCALL (argc 1)\_s*' ..
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1349 '\d RETURN',
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1350 instr)
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1351 enddef
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
1352
21558
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1353 def NestedOuter()
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1354 def g:Inner()
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1355 echomsg "inner"
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1356 enddef
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1357 enddef
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1358
24152
c308076e225e patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents: 23994
diff changeset
1359 def Test_disassemble_nested_func()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1360 var instr = execute('disassemble NestedOuter')
21558
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1361 assert_match('NestedOuter\_s*' ..
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1362 'def g:Inner()\_s*' ..
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1363 'echomsg "inner"\_s*' ..
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1364 'enddef\_s*' ..
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1365 '\d NEWFUNC <lambda>\d\+ Inner\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
1366 '\d RETURN void',
21558
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1367 instr)
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1368 enddef
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1369
22973
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1370 def NestedDefList()
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1371 def
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1372 def Info
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1373 def /Info
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1374 def /Info/
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1375 enddef
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1376
24152
c308076e225e patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents: 23994
diff changeset
1377 def Test_disassemble_nested_def_list()
22973
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1378 var instr = execute('disassemble NestedDefList')
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1379 assert_match('NestedDefList\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1380 'def\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1381 '\d DEF \_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1382 'def Info\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1383 '\d DEF Info\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1384 'def /Info\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1385 '\d DEF /Info\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1386 'def /Info/\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1387 '\d DEF /Info/\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
1388 '\d RETURN void',
22973
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1389 instr)
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1390 enddef
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
1391
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1392 def s:AndOr(arg: any): string
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1393 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
1394 return 'yes'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1395 endif
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1396 return 'no'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1397 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1398
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1399 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
1400 assert_equal("yes", AndOr(1))
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1401 assert_equal("no", AndOr(2))
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1402 assert_equal("yes", AndOr(4))
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1403 var instr = execute('disassemble AndOr')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1404 assert_match('AndOr\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1405 'if arg == 1 && arg != 2 || arg == 4\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1406 '\d LOAD arg\[-1]\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1407 '\d PUSHNR 1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1408 '\d COMPAREANY ==\_s*' ..
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1409 '\d JUMP_IF_COND_FALSE -> \d\+\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1410 '\d LOAD arg\[-1]\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1411 '\d PUSHNR 2\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1412 '\d COMPAREANY !=\_s*' ..
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1413 '\d JUMP_IF_COND_TRUE -> \d\+\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1414 '\d LOAD arg\[-1]\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1415 '\d\+ PUSHNR 4\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1416 '\d\+ COMPAREANY ==\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1417 '\d\+ JUMP_IF_FALSE -> \d\+',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1418 instr)
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1419 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1420
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1421 def s:AndConstant(arg: any): string
25814
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1422 if true && arg
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1423 return "yes"
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1424 endif
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1425 if false && arg
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1426 return "never"
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1427 endif
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1428 return "no"
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1429 enddef
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1430
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1431 def Test_disassemble_and_constant()
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1432 assert_equal("yes", AndConstant(1))
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1433 assert_equal("no", AndConstant(false))
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1434 var instr = execute('disassemble AndConstant')
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1435 assert_match('AndConstant\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1436 'if true && arg\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1437 '0 LOAD arg\[-1\]\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1438 '1 COND2BOOL\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1439 '2 JUMP_IF_FALSE -> 5\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1440 'return "yes"\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1441 '3 PUSHS "yes"\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1442 '4 RETURN\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1443 'endif\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1444 'if false && arg\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1445 'return "never"\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1446 'endif\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1447 'return "no"\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1448 '5 PUSHS "no"\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1449 '6 RETURN',
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1450 instr)
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1451 enddef
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1452
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1453 def s:ForLoop(): list<number>
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1454 var res: list<number>
19336
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1455 for i in range(3)
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1456 res->add(i)
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1457 endfor
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1458 return res
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1459 enddef
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1460
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1461 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
1462 assert_equal([0, 1, 2], ForLoop())
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1463 var instr = execute('disassemble ForLoop')
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1464 assert_match('ForLoop\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1465 'var res: list<number>\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1466 '\d NEWLIST size 0\_s*' ..
23458
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23438
diff changeset
1467 '\d SETTYPE list<number>\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1468 '\d STORE $0\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1469 'for i in range(3)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1470 '\d STORE -1 in $1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1471 '\d PUSHNR 3\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1472 '\d BCALL range(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1473 '\d FOR $1 -> \d\+\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1474 '\d STORE $2\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1475 'res->add(i)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1476 '\d LOAD $0\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1477 '\d LOAD $2\_s*' ..
22633
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
1478 '\d\+ LISTAPPEND\_s*' ..
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1479 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1480 'endfor\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1481 '\d\+ JUMP -> \d\+\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1482 '\d\+ DROP',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1483 instr)
19336
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1484 enddef
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1485
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1486 def s:ForLoopEval(): string
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1487 var res = ""
21188
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1488 for str in eval('["one", "two"]')
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1489 res ..= str
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1490 endfor
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1491 return res
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1492 enddef
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1493
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1494 def Test_disassemble_for_loop_eval()
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1495 assert_equal('onetwo', ForLoopEval())
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1496 var instr = execute('disassemble ForLoopEval')
21188
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1497 assert_match('ForLoopEval\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1498 'var res = ""\_s*' ..
21188
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1499 '\d PUSHS ""\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1500 '\d STORE $0\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1501 'for str in eval(''\["one", "two"\]'')\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1502 '\d STORE -1 in $1\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1503 '\d PUSHS "\["one", "two"\]"\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1504 '\d BCALL eval(argc 1)\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1505 '\d FOR $1 -> \d\+\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1506 '\d STORE $2\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1507 'res ..= str\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1508 '\d\+ LOAD $0\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1509 '\d\+ LOAD $2\_s*' ..
25453
21b70bab366c patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents: 25004
diff changeset
1510 '\d 2STRING_ANY stack\[-1\]\_s*' ..
28598
d550054e1328 patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
1511 '\d\+ CONCAT size 2\_s*' ..
21188
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1512 '\d\+ STORE $0\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1513 'endfor\_s*' ..
24234
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
1514 '\d\+ JUMP -> 5\_s*' ..
21188
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1515 '\d\+ DROP\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1516 'return res\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1517 '\d\+ LOAD $0\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1518 '\d\+ RETURN',
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1519 instr)
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1520 enddef
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1521
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1522 def s:ForLoopUnpack()
22975
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1523 for [x1, x2] in [[1, 2], [3, 4]]
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1524 echo x1 x2
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1525 endfor
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1526 enddef
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1527
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1528 def Test_disassemble_for_loop_unpack()
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1529 var instr = execute('disassemble ForLoopUnpack')
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1530 assert_match('ForLoopUnpack\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1531 'for \[x1, x2\] in \[\[1, 2\], \[3, 4\]\]\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1532 '\d\+ STORE -1 in $0\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1533 '\d\+ PUSHNR 1\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1534 '\d\+ PUSHNR 2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1535 '\d\+ NEWLIST size 2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1536 '\d\+ PUSHNR 3\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1537 '\d\+ PUSHNR 4\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1538 '\d\+ NEWLIST size 2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1539 '\d\+ NEWLIST size 2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1540 '\d\+ FOR $0 -> 16\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1541 '\d\+ UNPACK 2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1542 '\d\+ STORE $1\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1543 '\d\+ STORE $2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1544 'echo x1 x2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1545 '\d\+ LOAD $1\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1546 '\d\+ LOAD $2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1547 '\d\+ ECHO 2\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1548 'endfor\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1549 '\d\+ JUMP -> 8\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1550 '\d\+ DROP\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
1551 '\d\+ RETURN void',
22975
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1552 instr)
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1553 enddef
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1554
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1555 def s:ForLoopContinue()
23927
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1556 for nr in [1, 2]
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1557 try
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1558 echo "ok"
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1559 try
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1560 echo "deeper"
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1561 catch
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1562 continue
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1563 endtry
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1564 catch
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1565 echo "not ok"
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1566 endtry
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1567 endfor
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1568 enddef
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1569
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1570 def Test_disassemble_for_loop_continue()
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1571 var instr = execute('disassemble ForLoopContinue')
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1572 assert_match('ForLoopContinue\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1573 'for nr in \[1, 2]\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1574 '0 STORE -1 in $0\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1575 '1 PUSHNR 1\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1576 '2 PUSHNR 2\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1577 '3 NEWLIST size 2\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1578 '4 FOR $0 -> 22\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1579 '5 STORE $1\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1580 'try\_s*' ..
23994
3daeb2060f25 patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents: 23927
diff changeset
1581 '6 TRY catch -> 17, endtry -> 20\_s*' ..
23927
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1582 'echo "ok"\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1583 '7 PUSHS "ok"\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1584 '8 ECHO 1\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1585 'try\_s*' ..
23994
3daeb2060f25 patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents: 23927
diff changeset
1586 '9 TRY catch -> 13, endtry -> 15\_s*' ..
23927
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1587 'echo "deeper"\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1588 '10 PUSHS "deeper"\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1589 '11 ECHO 1\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1590 'catch\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1591 '12 JUMP -> 15\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1592 '13 CATCH\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1593 'continue\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1594 '14 TRY-CONTINUE 2 levels -> 4\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1595 'endtry\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1596 '15 ENDTRY\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1597 'catch\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1598 '16 JUMP -> 20\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1599 '17 CATCH\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1600 'echo "not ok"\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1601 '18 PUSHS "not ok"\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1602 '19 ECHO 1\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1603 'endtry\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1604 '20 ENDTRY\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1605 'endfor\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1606 '21 JUMP -> 4\_s*' ..
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1607 '\d\+ DROP\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
1608 '\d\+ RETURN void',
23927
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1609 instr)
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1610 enddef
5e5780e3f75d patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents: 23723
diff changeset
1611
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1612 let g:number = 42
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1613
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1614 def s:TypeCast()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1615 var l: list<number> = [23, <number>g:number]
21717
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1616 enddef
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1617
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1618 def Test_disassemble_typecast()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1619 var instr = execute('disassemble TypeCast')
21717
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1620 assert_match('TypeCast.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1621 'var l: list<number> = \[23, <number>g:number\].*' ..
21717
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1622 '\d PUSHNR 23\_s*' ..
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1623 '\d LOADG g:number\_s*' ..
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1624 '\d CHECKTYPE number stack\[-1\]\_s*' ..
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1625 '\d NEWLIST size 2\_s*' ..
23458
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23438
diff changeset
1626 '\d SETTYPE list<number>\_s*' ..
21717
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1627 '\d STORE $0\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
1628 '\d RETURN void\_s*',
21717
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1629 instr)
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1630 enddef
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1631
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1632 def s:Computing()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1633 var nr = 3
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1634 var nrres = nr + 7
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1635 nrres = nr - 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1636 nrres = nr * 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1637 nrres = nr / 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1638 nrres = nr % 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1639
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1640 var anyres = g:number + 7
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1641 anyres = g:number - 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1642 anyres = g:number * 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1643 anyres = g:number / 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1644 anyres = g:number % 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1645
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1646 if has('float')
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1647 var fl = 3.0
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1648 var flres = fl + 7.0
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1649 flres = fl - 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1650 flres = fl * 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1651 flres = fl / 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1652 endif
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1653 enddef
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1654
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1655 def Test_disassemble_computing()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1656 var instr = execute('disassemble Computing')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1657 assert_match('Computing.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1658 'var nr = 3.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1659 '\d STORE 3 in $0.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1660 'var nrres = nr + 7.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1661 '\d LOAD $0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1662 '\d PUSHNR 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1663 '\d OPNR +.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1664 '\d STORE $1.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1665 'nrres = nr - 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1666 '\d OPNR -.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1667 'nrres = nr \* 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1668 '\d OPNR \*.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1669 'nrres = nr / 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1670 '\d OPNR /.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1671 'nrres = nr % 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1672 '\d OPNR %.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1673 'var anyres = g:number + 7.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1674 '\d LOADG g:number.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1675 '\d PUSHNR 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1676 '\d OPANY +.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1677 '\d STORE $2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1678 'anyres = g:number - 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1679 '\d OPANY -.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1680 'anyres = g:number \* 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1681 '\d OPANY \*.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1682 'anyres = g:number / 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1683 '\d OPANY /.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1684 'anyres = g:number % 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1685 '\d OPANY %.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1686 instr)
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1687 if has('float')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1688 assert_match('Computing.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1689 'var fl = 3.0.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1690 '\d PUSHF 3.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1691 '\d STORE $3.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1692 'var flres = fl + 7.0.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1693 '\d LOAD $3.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1694 '\d PUSHF 7.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1695 '\d OPFLOAT +.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1696 '\d STORE $4.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1697 'flres = fl - 7.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1698 '\d OPFLOAT -.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1699 'flres = fl \* 7.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1700 '\d OPFLOAT \*.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1701 'flres = fl / 7.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1702 '\d OPFLOAT /.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1703 instr)
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1704 endif
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1705 enddef
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1706
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1707 def s:AddListBlob()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1708 var reslist = [1, 2] + [3, 4]
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1709 var resblob = 0z1122 + 0z3344
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1710 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1711
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1712 def Test_disassemble_add_list_blob()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1713 var instr = execute('disassemble AddListBlob')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1714 assert_match('AddListBlob.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1715 'var reslist = \[1, 2] + \[3, 4].*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1716 '\d PUSHNR 1.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1717 '\d PUSHNR 2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1718 '\d NEWLIST size 2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1719 '\d PUSHNR 3.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1720 '\d PUSHNR 4.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1721 '\d NEWLIST size 2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1722 '\d ADDLIST.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1723 '\d STORE $.*.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1724 'var resblob = 0z1122 + 0z3344.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1725 '\d PUSHBLOB 0z1122.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1726 '\d PUSHBLOB 0z3344.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1727 '\d ADDBLOB.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1728 '\d STORE $.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1729 instr)
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1730 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1731
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1732 let g:aa = 'aa'
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1733 def s:ConcatString(): string
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1734 var res = g:aa .. "bb"
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1735 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1736 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1737
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1738 def Test_disassemble_concat()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1739 var instr = execute('disassemble ConcatString')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1740 assert_match('ConcatString.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1741 'var res = g:aa .. "bb".*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1742 '\d LOADG g:aa.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1743 '\d PUSHS "bb".*' ..
21771
fcf978444298 patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents: 21755
diff changeset
1744 '\d 2STRING_ANY stack\[-2].*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1745 '\d CONCAT.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1746 '\d STORE $.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1747 instr)
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1748 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
1749 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1750
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1751 def s:StringIndex(): string
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1752 var s = "abcd"
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1753 var res = s[1]
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1754 return res
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1755 enddef
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1756
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1757 def Test_disassemble_string_index()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1758 var instr = execute('disassemble StringIndex')
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1759 assert_match('StringIndex\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1760 'var s = "abcd"\_s*' ..
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1761 '\d PUSHS "abcd"\_s*' ..
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1762 '\d STORE $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1763 'var res = s\[1]\_s*' ..
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1764 '\d LOAD $0\_s*' ..
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1765 '\d PUSHNR 1\_s*' ..
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1766 '\d STRINDEX\_s*' ..
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1767 '\d STORE $1\_s*',
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1768 instr)
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1769 assert_equal('b', StringIndex())
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1770 enddef
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1771
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1772 def s:StringSlice(): string
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1773 var s = "abcd"
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1774 var res = s[1 : 8]
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1775 return res
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1776 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1777
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1778 def Test_disassemble_string_slice()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1779 var instr = execute('disassemble StringSlice')
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1780 assert_match('StringSlice\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1781 'var s = "abcd"\_s*' ..
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1782 '\d PUSHS "abcd"\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1783 '\d STORE $0\_s*' ..
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1784 'var res = s\[1 : 8]\_s*' ..
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1785 '\d LOAD $0\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1786 '\d PUSHNR 1\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1787 '\d PUSHNR 8\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1788 '\d STRSLICE\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1789 '\d STORE $1\_s*',
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1790 instr)
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1791 assert_equal('bcd', StringSlice())
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1792 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1793
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1794 def s:ListIndex(): number
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1795 var l = [1, 2, 3]
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1796 var res = l[1]
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1797 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1798 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1799
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1800 def Test_disassemble_list_index()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1801 var instr = execute('disassemble ListIndex')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1802 assert_match('ListIndex\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1803 'var l = \[1, 2, 3]\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1804 '\d PUSHNR 1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1805 '\d PUSHNR 2\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1806 '\d PUSHNR 3\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1807 '\d NEWLIST size 3\_s*' ..
27728
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
1808 '\d SETTYPE list<number>\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1809 '\d STORE $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1810 'var res = l\[1]\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1811 '\d LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1812 '\d PUSHNR 1\_s*' ..
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1813 '\d LISTINDEX\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1814 '\d STORE $1\_s*',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1815 instr)
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1816 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
1817 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1818
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1819 def s:ListSlice(): list<number>
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1820 var l = [1, 2, 3]
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1821 var res = l[1 : 8]
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1822 return res
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1823 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1824
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1825 def Test_disassemble_list_slice()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1826 var instr = execute('disassemble ListSlice')
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1827 assert_match('ListSlice\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1828 'var l = \[1, 2, 3]\_s*' ..
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1829 '\d PUSHNR 1\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1830 '\d PUSHNR 2\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1831 '\d PUSHNR 3\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1832 '\d NEWLIST size 3\_s*' ..
27728
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
1833 '\d SETTYPE list<number>\_s*' ..
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1834 '\d STORE $0\_s*' ..
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1835 'var res = l\[1 : 8]\_s*' ..
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1836 '\d LOAD $0\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1837 '\d PUSHNR 1\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1838 '\d PUSHNR 8\_s*' ..
27728
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
1839 '\d\+ LISTSLICE\_s*' ..
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
1840 '\d\+ SETTYPE list<number>\_s*' ..
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
1841 '\d\+ STORE $1\_s*',
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1842 instr)
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1843 assert_equal([2, 3], ListSlice())
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1844 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1845
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1846 def s:DictMember(): number
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
1847 var d = {item: 1}
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1848 var res = d.item
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1849 res = d["item"]
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1850 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1851 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1852
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1853 def Test_disassemble_dict_member()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1854 var instr = execute('disassemble DictMember')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1855 assert_match('DictMember\_s*' ..
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
1856 'var d = {item: 1}\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1857 '\d PUSHS "item"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1858 '\d PUSHNR 1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1859 '\d NEWDICT size 1\_s*' ..
27728
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
1860 '\d SETTYPE dict<number>\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1861 '\d STORE $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1862 'var res = d.item\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1863 '\d\+ LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1864 '\d\+ MEMBER item\_s*' ..
25800
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
1865 '\d\+ USEDICT\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1866 '\d\+ STORE $1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1867 'res = d\["item"\]\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1868 '\d\+ LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1869 '\d\+ PUSHS "item"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1870 '\d\+ MEMBER\_s*' ..
25800
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
1871 '\d\+ USEDICT\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1872 '\d\+ STORE $1\_s*',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1873 instr)
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1874 assert_equal(1, DictMember())
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1875 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1876
21833
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1877 let somelist = [1, 2, 3, 4, 5]
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1878 def s:AnyIndex(): number
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1879 var res = g:somelist[2]
21833
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1880 return res
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1881 enddef
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1882
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1883 def Test_disassemble_any_index()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1884 var instr = execute('disassemble AnyIndex')
21833
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1885 assert_match('AnyIndex\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1886 'var res = g:somelist\[2\]\_s*' ..
21833
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1887 '\d LOADG g:somelist\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1888 '\d PUSHNR 2\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1889 '\d ANYINDEX\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1890 '\d STORE $0\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1891 'return res\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1892 '\d LOAD $0\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1893 '\d CHECKTYPE number stack\[-1\]\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1894 '\d RETURN',
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1895 instr)
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1896 assert_equal(3, AnyIndex())
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1897 enddef
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1898
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1899 def s:AnySlice(): list<number>
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1900 var res = g:somelist[1 : 3]
21833
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1901 return res
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1902 enddef
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1903
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1904 def Test_disassemble_any_slice()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1905 var instr = execute('disassemble AnySlice')
21833
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1906 assert_match('AnySlice\_s*' ..
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1907 'var res = g:somelist\[1 : 3\]\_s*' ..
21833
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1908 '\d LOADG g:somelist\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1909 '\d PUSHNR 1\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1910 '\d PUSHNR 3\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1911 '\d ANYSLICE\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1912 '\d STORE $0\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1913 'return res\_s*' ..
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1914 '\d LOAD $0\_s*' ..
22284
6b385c2b9ff5 patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents: 22196
diff changeset
1915 '\d CHECKTYPE list<number> stack\[-1\]\_s*' ..
21833
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1916 '\d RETURN',
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1917 instr)
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1918 assert_equal([2, 3, 4], AnySlice())
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1919 enddef
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1920
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1921 def s:NegateNumber(): number
25634
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1922 g:nr = 9
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1923 var plus = +g:nr
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1924 var minus = -g:nr
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1925 return minus
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1926 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1927
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1928 def Test_disassemble_negate_number()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1929 var instr = execute('disassemble NegateNumber')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1930 assert_match('NegateNumber\_s*' ..
25634
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1931 'g:nr = 9\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1932 '\d PUSHNR 9\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1933 '\d STOREG g:nr\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1934 'var plus = +g:nr\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1935 '\d LOADG g:nr\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1936 '\d CHECKTYPE number stack\[-1\]\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1937 '\d STORE $0\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1938 'var minus = -g:nr\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1939 '\d LOADG g:nr\_s*' ..
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1940 '\d CHECKTYPE number stack\[-1\]\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1941 '\d NEGATENR\_s*' ..
25634
27cb2e79ccde patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25605
diff changeset
1942 '\d STORE $1\_s*',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1943 instr)
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1944 assert_equal(-9, NegateNumber())
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1945 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1946
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1947 def s:InvertBool(): bool
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1948 var flag = true
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1949 var invert = !flag
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1950 var res = !!flag
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1951 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1952 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1953
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1954 def Test_disassemble_invert_bool()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1955 var instr = execute('disassemble InvertBool')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1956 assert_match('InvertBool\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1957 'var flag = true\_s*' ..
23438
4c6ebf531284 patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
1958 '\d PUSH true\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1959 '\d STORE $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1960 'var invert = !flag\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1961 '\d LOAD $0\_s*' ..
24796
7c1375eb1636 patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents: 24606
diff changeset
1962 '\d INVERT -1 (!val)\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1963 '\d STORE $1\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1964 'var res = !!flag\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1965 '\d LOAD $0\_s*' ..
24796
7c1375eb1636 patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents: 24606
diff changeset
1966 '\d 2BOOL -1 (!!val)\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1967 '\d STORE $2\_s*',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1968 instr)
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1969 assert_equal(true, InvertBool())
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1970 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1971
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
1972 def s:ReturnBool(): bool
25814
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1973 var one = 1
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1974 var zero = 0
26729
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1975 var none: number
25814
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1976 var name: bool = one && zero || one
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1977 return name
22196
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
1978 enddef
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
1979
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
1980 def Test_disassemble_return_bool()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1981 var instr = execute('disassemble ReturnBool')
22196
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
1982 assert_match('ReturnBool\_s*' ..
25814
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1983 'var one = 1\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1984 '0 STORE 1 in $0\_s*' ..
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1985 'var zero = 0\_s*' ..
26729
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1986 'var none: number\_s*' ..
25814
dd4e86558836 patch 8.2.3442: Vim9: || and && are not handled at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25800
diff changeset
1987 'var name: bool = one && zero || one\_s*' ..
26729
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1988 '1 LOAD $0\_s*' ..
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1989 '2 COND2BOOL\_s*' ..
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1990 '3 JUMP_IF_COND_FALSE -> 6\_s*' ..
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1991 '4 LOAD $1\_s*' ..
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1992 '5 COND2BOOL\_s*' ..
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1993 '6 JUMP_IF_COND_TRUE -> 9\_s*' ..
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1994 '7 LOAD $0\_s*' ..
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1995 '8 COND2BOOL\_s*' ..
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1996 '9 STORE $3\_s*' ..
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1997 'return name\_s*' ..
26729
b969fdb8cd46 patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Bram Moolenaar <Bram@vim.org>
parents: 26678
diff changeset
1998 '\d\+ LOAD $3\_s*' ..
22860
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22842
diff changeset
1999 '\d\+ RETURN',
22196
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
2000 instr)
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
2001 assert_equal(true, InvertBool())
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
2002 enddef
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
2003
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27394
diff changeset
2004 def s:AutoInit()
26739
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2005 var t: number
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2006 t = 1
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2007 t = 0
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2008 enddef
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2009
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2010 def Test_disassemble_auto_init()
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2011 var instr = execute('disassemble AutoInit')
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2012 assert_match('AutoInit\_s*' ..
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2013 'var t: number\_s*' ..
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2014 't = 1\_s*' ..
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2015 '\d STORE 1 in $0\_s*' ..
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2016 't = 0\_s*' ..
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2017 '\d STORE 0 in $0\_s*' ..
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2018 '\d\+ RETURN void',
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2019 instr)
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2020 enddef
47ad45fb433a patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Bram Moolenaar <Bram@vim.org>
parents: 26729
diff changeset
2021
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2022 def Test_disassemble_compare()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2023 var cases = [
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2024 ['true == isFalse', 'COMPAREBOOL =='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2025 ['true != isFalse', 'COMPAREBOOL !='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2026 ['v:none == isNull', 'COMPARESPECIAL =='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2027 ['v:none != isNull', 'COMPARESPECIAL !='],
27924
e6e3abc28c7a patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents: 27728
diff changeset
2028 ['"text" == isNull', 'COMPARENULL =='],
e6e3abc28c7a patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents: 27728
diff changeset
2029 ['"text" != isNull', 'COMPARENULL !='],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2030
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2031 ['111 == aNumber', 'COMPARENR =='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2032 ['111 != aNumber', 'COMPARENR !='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2033 ['111 > aNumber', 'COMPARENR >'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2034 ['111 < aNumber', 'COMPARENR <'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2035 ['111 >= aNumber', 'COMPARENR >='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2036 ['111 <= aNumber', 'COMPARENR <='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2037 ['111 =~ aNumber', 'COMPARENR =\~'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2038 ['111 !~ aNumber', 'COMPARENR !\~'],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2039
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2040 ['"xx" != aString', 'COMPARESTRING !='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2041 ['"xx" > aString', 'COMPARESTRING >'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2042 ['"xx" < aString', 'COMPARESTRING <'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2043 ['"xx" >= aString', 'COMPARESTRING >='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2044 ['"xx" <= aString', 'COMPARESTRING <='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2045 ['"xx" =~ aString', 'COMPARESTRING =\~'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2046 ['"xx" !~ aString', 'COMPARESTRING !\~'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2047 ['"xx" is aString', 'COMPARESTRING is'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2048 ['"xx" isnot aString', 'COMPARESTRING isnot'],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2049
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2050 ['0z11 == aBlob', 'COMPAREBLOB =='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2051 ['0z11 != aBlob', 'COMPAREBLOB !='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2052 ['0z11 is aBlob', 'COMPAREBLOB is'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2053 ['0z11 isnot aBlob', 'COMPAREBLOB isnot'],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2054
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2055 ['[1, 2] == aList', 'COMPARELIST =='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2056 ['[1, 2] != aList', 'COMPARELIST !='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2057 ['[1, 2] is aList', 'COMPARELIST is'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2058 ['[1, 2] isnot aList', 'COMPARELIST isnot'],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2059
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
2060 ['{a: 1} == aDict', 'COMPAREDICT =='],
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
2061 ['{a: 1} != aDict', 'COMPAREDICT !='],
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
2062 ['{a: 1} is aDict', 'COMPAREDICT is'],
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
2063 ['{a: 1} isnot aDict', 'COMPAREDICT isnot'],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2064
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
2065 ['(() => 33) == (() => 44)', 'COMPAREFUNC =='],
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
2066 ['(() => 33) != (() => 44)', 'COMPAREFUNC !='],
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
2067 ['(() => 33) is (() => 44)', 'COMPAREFUNC is'],
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
2068 ['(() => 33) isnot (() => 44)', 'COMPAREFUNC isnot'],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2069
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2070 ['77 == g:xx', 'COMPAREANY =='],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2071 ['77 != g:xx', 'COMPAREANY !='],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2072 ['77 > g:xx', 'COMPAREANY >'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2073 ['77 < g:xx', 'COMPAREANY <'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2074 ['77 >= g:xx', 'COMPAREANY >='],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2075 ['77 <= g:xx', 'COMPAREANY <='],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2076 ['77 =~ g:xx', 'COMPAREANY =\~'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2077 ['77 !~ g:xx', 'COMPAREANY !\~'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2078 ['77 is g:xx', 'COMPAREANY is'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2079 ['77 isnot g:xx', 'COMPAREANY isnot'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2080 ]
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2081 var floatDecl = ''
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2082 if has('float')
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2083 cases->extend([
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2084 ['1.1 == aFloat', 'COMPAREFLOAT =='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2085 ['1.1 != aFloat', 'COMPAREFLOAT !='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2086 ['1.1 > aFloat', 'COMPAREFLOAT >'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2087 ['1.1 < aFloat', 'COMPAREFLOAT <'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2088 ['1.1 >= aFloat', 'COMPAREFLOAT >='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2089 ['1.1 <= aFloat', 'COMPAREFLOAT <='],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2090 ['1.1 =~ aFloat', 'COMPAREFLOAT =\~'],
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2091 ['1.1 !~ aFloat', 'COMPAREFLOAT !\~'],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2092 ])
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2093 floatDecl = 'var aFloat = 2.2'
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2094 endif
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2095
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2096 var nr = 1
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2097 for case in cases
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21299
diff changeset
2098 # declare local variables to get a non-constant with the right type
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2099 writefile(['def TestCase' .. nr .. '()',
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2100 ' var isFalse = false',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2101 ' var isNull = v:null',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2102 ' var aNumber = 222',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2103 ' var aString = "yy"',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2104 ' var aBlob = 0z22',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2105 ' var aList = [3, 4]',
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
2106 ' var aDict = {x: 2}',
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2107 floatDecl,
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2108 ' if ' .. case[0],
29782
35cbea786334 patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28962
diff changeset
2109 ' echo 42',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2110 ' endif',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2111 'enddef'], 'Xdisassemble')
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2112 source Xdisassemble
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2113 var instr = execute('disassemble TestCase' .. nr)
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2114 assert_match('TestCase' .. nr .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2115 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2116 '\d \(PUSH\|FUNCREF\).*' ..
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
2117 '\d \(PUSH\|FUNCREF\|LOAD\).*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2118 '\d ' .. case[1] .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2119 '\d JUMP_IF_FALSE -> \d\+.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2120 instr)
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2121
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2122 nr += 1
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2123 endfor
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2124
19703
f03357f16ffc patch 8.2.0408: delete() commented out for testing
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
2125 delete('Xdisassemble')
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2126 enddef
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
2127
22492
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2128 def s:FalsyOp()
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2129 echo g:flag ?? "yes"
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2130 echo [] ?? "empty list"
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2131 echo "" ?? "empty string"
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2132 enddef
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2133
28171
b4c111ea83b1 patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents: 28002
diff changeset
2134 def Test_disassemble_falsy_op()
22492
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2135 var res = execute('disass s:FalsyOp')
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2136 assert_match('\<SNR>\d*_FalsyOp\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2137 'echo g:flag ?? "yes"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2138 '0 LOADG g:flag\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2139 '1 JUMP_AND_KEEP_IF_TRUE -> 3\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2140 '2 PUSHS "yes"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2141 '3 ECHO 1\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2142 'echo \[\] ?? "empty list"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2143 '4 NEWLIST size 0\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2144 '5 JUMP_AND_KEEP_IF_TRUE -> 7\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2145 '6 PUSHS "empty list"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2146 '7 ECHO 1\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2147 'echo "" ?? "empty string"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2148 '\d\+ PUSHS "empty string"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2149 '\d\+ ECHO 1\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2150 '\d\+ RETURN void',
22492
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2151 res)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2152 enddef
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
2153
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2154 def Test_disassemble_compare_const()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2155 var cases = [
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2156 ['"xx" == "yy"', false],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2157 ['"aa" == "aa"', true],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2158 ['has("eval") ? true : false', true],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2159 ['has("asdf") ? true : false', false],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2160 ]
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2161
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2162 var nr = 1
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2163 for case in cases
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2164 writefile(['def TestCase' .. nr .. '()',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2165 ' if ' .. case[0],
29782
35cbea786334 patch 9.0.0230: no error for comma missing in list in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28962
diff changeset
2166 ' echo 42',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2167 ' endif',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2168 'enddef'], 'Xdisassemble')
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2169 source Xdisassemble
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2170 var instr = execute('disassemble TestCase' .. nr)
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2171 if case[1]
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21299
diff changeset
2172 # condition true, "echo 42" executed
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2173 assert_match('TestCase' .. nr .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2174 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2175 '\d PUSHNR 42.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2176 '\d ECHO 1.*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2177 '\d RETURN void',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2178 instr)
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2179 else
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21299
diff changeset
2180 # condition false, function just returns
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2181 assert_match('TestCase' .. nr .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2182 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '[ \n]*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2183 'echo 42[ \n]*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2184 'endif[ \n]*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2185 '\d RETURN void',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2186 instr)
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2187 endif
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2188
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2189 nr += 1
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2190 endfor
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2191
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2192 delete('Xdisassemble')
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2193 enddef
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
2194
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2195 def s:Execute()
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2196 execute 'help vim9.txt'
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2197 var cmd = 'help vim9.txt'
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2198 execute cmd
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2199 var tag = 'vim9.txt'
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2200 execute 'help ' .. tag
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2201 enddef
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2202
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2203 def Test_disassemble_execute()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2204 var res = execute('disass s:Execute')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2205 assert_match('\<SNR>\d*_Execute\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2206 "execute 'help vim9.txt'\\_s*" ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2207 '\d PUSHS "help vim9.txt"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2208 '\d EXECUTE 1\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2209 "var cmd = 'help vim9.txt'\\_s*" ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2210 '\d PUSHS "help vim9.txt"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2211 '\d STORE $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2212 'execute cmd\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2213 '\d LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2214 '\d EXECUTE 1\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2215 "var tag = 'vim9.txt'\\_s*" ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2216 '\d PUSHS "vim9.txt"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2217 '\d STORE $1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2218 "execute 'help ' .. tag\\_s*" ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2219 '\d\+ PUSHS "help "\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2220 '\d\+ LOAD $1\_s*' ..
28598
d550054e1328 patch 8.2.4823: concat more than 2 strings in :def function is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 28287
diff changeset
2221 '\d\+ CONCAT size 2\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2222 '\d\+ EXECUTE 1\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2223 '\d\+ RETURN void',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2224 res)
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2225 enddef
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
2226
26370
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2227 def s:OnlyRange()
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2228 :$
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2229 :123
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2230 :'m
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2231 enddef
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2232
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2233 def Test_disassemble_range_only()
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2234 var res = execute('disass s:OnlyRange')
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2235 assert_match('\<SNR>\d*_OnlyRange\_s*' ..
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2236 ':$\_s*' ..
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2237 '\d EXECRANGE $\_s*' ..
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2238 ':123\_s*' ..
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2239 '\d EXECRANGE 123\_s*' ..
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2240 ':''m\_s*' ..
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2241 '\d EXECRANGE ''m\_s*' ..
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2242 '\d\+ RETURN void',
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2243 res)
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2244 enddef
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26352
diff changeset
2245
28625
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2246 def s:StoreRange()
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2247 var l = [1, 2]
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2248 l[0 : 1] = [7, 8]
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2249 enddef
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2250
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2251 def Test_disassemble_store_range()
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2252 var res = execute('disass s:StoreRange')
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2253 assert_match('\<SNR>\d*_StoreRange\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2254 'var l = \[1, 2]\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2255 '\d PUSHNR 1\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2256 '\d PUSHNR 2\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2257 '\d NEWLIST size 2\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2258 '\d SETTYPE list<number>\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2259 '\d STORE $0\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2260
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2261 'l\[0 : 1] = \[7, 8]\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2262 '\d\+ PUSHNR 7\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2263 '\d\+ PUSHNR 8\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2264 '\d\+ NEWLIST size 2\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2265 '\d\+ PUSHNR 0\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2266 '\d\+ PUSHNR 1\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2267 '\d\+ LOAD $0\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2268 '\d\+ STORERANGE\_s*' ..
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2269 '\d\+ RETURN void',
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2270 res)
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2271 enddef
56860e29ce5d patch 8.2.4836: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28623
diff changeset
2272
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2273 def s:Echomsg()
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2274 echomsg 'some' 'message'
25541
2ae1d5a4ae5c patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents: 25461
diff changeset
2275 echoconsole 'nothing'
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2276 echoerr 'went' .. 'wrong'
30025
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2277 var local = 'window'
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2278 echowin 'in' local
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2279 enddef
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2280
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2281 def Test_disassemble_echomsg()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2282 var res = execute('disass s:Echomsg')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2283 assert_match('\<SNR>\d*_Echomsg\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2284 "echomsg 'some' 'message'\\_s*" ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2285 '\d PUSHS "some"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2286 '\d PUSHS "message"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2287 '\d ECHOMSG 2\_s*' ..
25541
2ae1d5a4ae5c patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents: 25461
diff changeset
2288 "echoconsole 'nothing'\\_s*" ..
2ae1d5a4ae5c patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents: 25461
diff changeset
2289 '\d PUSHS "nothing"\_s*' ..
2ae1d5a4ae5c patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents: 25461
diff changeset
2290 '\d ECHOCONSOLE 1\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2291 "echoerr 'went' .. 'wrong'\\_s*" ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2292 '\d PUSHS "wentwrong"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2293 '\d ECHOERR 1\_s*' ..
30025
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2294 "var local = 'window'\\_s*" ..
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2295 '\d\+ PUSHS "window"\_s*' ..
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2296 '\d\+ STORE $0\_s*' ..
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2297 "echowin 'in' local\\_s*" ..
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2298 '\d\+ PUSHS "in"\_s*' ..
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2299 '\d\+ LOAD $0\_s*' ..
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2300 '\d\+ ECHOWINDOW 2\_s*' ..
d269dd3cd31d patch 9.0.0350: :echowindow does not work in a compiled function
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
2301 '\d\+ RETURN void',
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2302 res)
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2303 enddef
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
2304
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2305 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
2306 echo arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2307 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2308
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2309 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
2310 echo arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2311 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2312
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2313 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
2314 return arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2315 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2316
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2317 def Test_display_func()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2318 var res1 = execute('function SomeStringArg')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2319 assert_match('.* def SomeStringArg(arg: string)\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2320 '\d *echo arg.*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2321 ' *enddef',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2322 res1)
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2323
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2324 var res2 = execute('function SomeAnyArg')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2325 assert_match('.* def SomeAnyArg(arg: any)\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2326 '\d *echo arg\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2327 ' *enddef',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2328 res2)
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2329
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2330 var res3 = execute('function SomeStringArgAndReturn')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2331 assert_match('.* def SomeStringArgAndReturn(arg: string): string\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2332 '\d *return arg\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2333 ' *enddef',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
2334 res3)
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2335 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
2336
20339
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2337 def Test_vim9script_forward_func()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2338 var lines =<< trim END
20339
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2339 vim9script
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2340 def FuncOne(): string
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2341 return FuncTwo()
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2342 enddef
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2343 def FuncTwo(): string
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2344 return 'two'
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2345 enddef
20945
0653b9b72091 patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents: 20913
diff changeset
2346 g:res_FuncOne = execute('disass FuncOne')
20339
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2347 END
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2348 writefile(lines, 'Xdisassemble')
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2349 source Xdisassemble
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2350
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21299
diff changeset
2351 # check that the first function calls the second with DCALL
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2352 assert_match('\<SNR>\d*_FuncOne\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2353 'return FuncTwo()\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2354 '\d DCALL <SNR>\d\+_FuncTwo(argc 0)\_s*' ..
20339
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2355 '\d RETURN',
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2356 g:res_FuncOne)
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2357
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2358 delete('Xdisassemble')
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2359 unlet g:res_FuncOne
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2360 enddef
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
2361
20305
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2362 def s:ConcatStrings(): string
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2363 return 'one' .. 'two' .. 'three'
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2364 enddef
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2365
20324
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
2366 def s:ComputeConst(): number
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
2367 return 2 + 3 * 4 / 6 + 7
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
2368 enddef
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
2369
20336
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
2370 def s:ComputeConstParen(): number
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
2371 return ((2 + 4) * (8 / 2)) / (3 + 4)
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
2372 enddef
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
2373
20305
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2374 def Test_simplify_const_expr()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2375 var res = execute('disass s:ConcatStrings')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2376 assert_match('<SNR>\d*_ConcatStrings\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2377 "return 'one' .. 'two' .. 'three'\\_s*" ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2378 '\d PUSHS "onetwothree"\_s*' ..
20305
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2379 '\d RETURN',
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2380 res)
20324
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
2381
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
2382 res = execute('disass s:ComputeConst')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2383 assert_match('<SNR>\d*_ComputeConst\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2384 'return 2 + 3 \* 4 / 6 + 7\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2385 '\d PUSHNR 11\_s*' ..
20324
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
2386 '\d RETURN',
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
2387 res)
20336
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
2388
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
2389 res = execute('disass s:ComputeConstParen')
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2390 assert_match('<SNR>\d*_ComputeConstParen\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2391 'return ((2 + 4) \* (8 / 2)) / (3 + 4)\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
2392 '\d PUSHNR 3\>\_s*' ..
20336
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
2393 '\d RETURN',
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
2394 res)
20305
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2395 enddef
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
2396
21232
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2397 def s:CallAppend()
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2398 eval "some text"->append(2)
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2399 enddef
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2400
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2401 def Test_shuffle()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
2402 var res = execute('disass s:CallAppend')
21232
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2403 assert_match('<SNR>\d*_CallAppend\_s*' ..
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2404 'eval "some text"->append(2)\_s*' ..
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2405 '\d PUSHS "some text"\_s*' ..
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2406 '\d PUSHNR 2\_s*' ..
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2407 '\d SHUFFLE 2 up 1\_s*' ..
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2408 '\d BCALL append(argc 2)\_s*' ..
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2409 '\d DROP\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2410 '\d RETURN void',
21232
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2411 res)
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2412 enddef
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
2413
22691
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2414
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2415 def s:SilentMessage()
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2416 silent echomsg "text"
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2417 silent! echoerr "error"
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2418 enddef
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2419
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2420 def Test_silent()
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2421 var res = execute('disass s:SilentMessage')
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2422 assert_match('<SNR>\d*_SilentMessage\_s*' ..
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2423 'silent echomsg "text"\_s*' ..
22703
f2bfee4ac356 patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents: 22691
diff changeset
2424 '\d CMDMOD silent\_s*' ..
22691
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2425 '\d PUSHS "text"\_s*' ..
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2426 '\d ECHOMSG 1\_s*' ..
22703
f2bfee4ac356 patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents: 22691
diff changeset
2427 '\d CMDMOD_REV\_s*' ..
22691
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2428 'silent! echoerr "error"\_s*' ..
22703
f2bfee4ac356 patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents: 22691
diff changeset
2429 '\d CMDMOD silent!\_s*' ..
22691
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2430 '\d PUSHS "error"\_s*' ..
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2431 '\d ECHOERR 1\_s*' ..
22703
f2bfee4ac356 patch 8.2.1900: Vim9: command modifiers do not work
Bram Moolenaar <Bram@vim.org>
parents: 22691
diff changeset
2432 '\d CMDMOD_REV\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2433 '\d\+ RETURN void',
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2434 res)
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2435 enddef
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2436
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2437 def s:SilentIf()
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2438 silent if 4 == g:five
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2439 silent elseif 4 == g:five
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24220
diff changeset
2440 endif
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2441 enddef
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2442
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2443 def Test_silent_if()
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2444 var res = execute('disass s:SilentIf')
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2445 assert_match('<SNR>\d*_SilentIf\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2446 'silent if 4 == g:five\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2447 '\d\+ CMDMOD silent\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2448 '\d\+ PUSHNR 4\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2449 '\d\+ LOADG g:five\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2450 '\d\+ COMPAREANY ==\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2451 '\d\+ CMDMOD_REV\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2452 '\d\+ JUMP_IF_FALSE -> \d\+\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2453 'silent elseif 4 == g:five\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2454 '\d\+ JUMP -> \d\+\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2455 '\d\+ CMDMOD silent\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2456 '\d\+ PUSHNR 4\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2457 '\d\+ LOADG g:five\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2458 '\d\+ COMPAREANY ==\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2459 '\d\+ CMDMOD_REV\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2460 '\d\+ JUMP_IF_FALSE -> \d\+\_s*' ..
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24220
diff changeset
2461 'endif\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2462 '\d\+ RETURN void',
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2463 res)
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2464 enddef
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2465
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2466 def s:SilentFor()
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2467 silent for i in [0]
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24220
diff changeset
2468 endfor
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2469 enddef
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2470
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2471 def Test_silent_for()
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2472 var res = execute('disass s:SilentFor')
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2473 assert_match('<SNR>\d*_SilentFor\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2474 'silent for i in \[0\]\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2475 '\d CMDMOD silent\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2476 '\d STORE -1 in $0\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2477 '\d PUSHNR 0\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2478 '\d NEWLIST size 1\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2479 '\d CMDMOD_REV\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2480 '5 FOR $0 -> 8\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2481 '\d STORE $1\_s*' ..
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24220
diff changeset
2482 'endfor\_s*' ..
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2483 '\d JUMP -> 5\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2484 '8 DROP\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2485 '\d RETURN void\_s*',
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2486 res)
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2487 enddef
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2488
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2489 def s:SilentWhile()
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2490 silent while g:not
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24220
diff changeset
2491 endwhile
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2492 enddef
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2493
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2494 def Test_silent_while()
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2495 var res = execute('disass s:SilentWhile')
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2496 assert_match('<SNR>\d*_SilentWhile\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2497 'silent while g:not\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2498 '0 CMDMOD silent\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2499 '\d LOADG g:not\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2500 '\d COND2BOOL\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2501 '\d CMDMOD_REV\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2502 '\d JUMP_IF_FALSE -> 6\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2503
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24220
diff changeset
2504 'endwhile\_s*' ..
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2505 '\d JUMP -> 0\_s*' ..
24936
345619f35112 patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents: 24920
diff changeset
2506 '6 RETURN void\_s*',
24220
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2507 res)
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2508 enddef
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2509
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2510 def s:SilentReturn(): string
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2511 silent return "done"
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2512 enddef
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2513
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2514 def Test_silent_return()
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2515 var res = execute('disass s:SilentReturn')
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2516 assert_match('<SNR>\d*_SilentReturn\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2517 'silent return "done"\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2518 '\d CMDMOD silent\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2519 '\d PUSHS "done"\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2520 '\d CMDMOD_REV\_s*' ..
a7a9176bb542 patch 8.2.2651: Vim9: restoring command modifiers happens after jump
Bram Moolenaar <Bram@vim.org>
parents: 24152
diff changeset
2521 '\d RETURN',
22691
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2522 res)
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2523 enddef
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
2524
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2525 def s:Profiled(): string
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2526 # comment
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2527 echo "profiled"
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2528 # comment
24920
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2529 var some = "some text"
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2530 return "done"
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2531 enddef
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2532
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2533 def Test_profiled()
23719
1a7c2685d780 patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
2534 if !has('profile')
1a7c2685d780 patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
2535 MissingFeature 'profile'
1a7c2685d780 patch 8.2.2401: build fails without +profiling feature
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
2536 endif
24895
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2537 var res = execute('disass profile s:Profiled')
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2538 assert_match('<SNR>\d*_Profiled\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2539 '# comment\_s*' ..
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2540 'echo "profiled"\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2541 '\d PROFILE START line 2\_s*' ..
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2542 '\d PUSHS "profiled"\_s*' ..
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2543 '\d ECHO 1\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2544 '# comment\_s*' ..
24920
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2545 'var some = "some text"\_s*' ..
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2546 '\d PROFILE END\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2547 '\d PROFILE START line 4\_s*' ..
24920
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2548 '\d PUSHS "some text"\_s*' ..
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2549 '\d STORE $0\_s*' ..
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2550 'return "done"\_s*' ..
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2551 '\d PROFILE END\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2552 '\d PROFILE START line 5\_s*' ..
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2553 '\d PUSHS "done"\_s*' ..
24920
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2554 '\d\+ RETURN\_s*' ..
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2555 '\d\+ PROFILE END',
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2556 res)
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2557 enddef
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
2558
24895
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2559 def Test_debugged()
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2560 var res = execute('disass debug s:Profiled')
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2561 assert_match('<SNR>\d*_Profiled\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2562 '# comment\_s*' ..
24895
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2563 'echo "profiled"\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2564 '\d DEBUG line 1-2 varcount 0\_s*' ..
24895
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2565 '\d PUSHS "profiled"\_s*' ..
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2566 '\d ECHO 1\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2567 '# comment\_s*' ..
24920
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2568 'var some = "some text"\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2569 '\d DEBUG line 3-4 varcount 0\_s*' ..
24920
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2570 '\d PUSHS "some text"\_s*' ..
6235e5d3523d patch 8.2.2997: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 24895
diff changeset
2571 '\d STORE $0\_s*' ..
24895
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2572 'return "done"\_s*' ..
25004
70f55a30f03c patch 8.2.3039: Vim9: breakpoint at a comment line does not work
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2573 '\d DEBUG line 5-5 varcount 1\_s*' ..
24895
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2574 '\d PUSHS "done"\_s*' ..
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2575 '\d RETURN\_s*',
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2576 res)
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2577 enddef
e61a2085c89b patch 8.2.2985: Vim9: a compiled function cannot be debugged
Bram Moolenaar <Bram@vim.org>
parents: 24826
diff changeset
2578
26352
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2579 def s:ElseifConstant()
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2580 if g:value
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2581 echo "one"
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2582 elseif true
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2583 echo "true"
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2584 elseif false
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2585 echo "false"
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2586 endif
26678
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2587 if 0
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2588 echo "yes"
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2589 elseif 0
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2590 echo "no"
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2591 endif
26352
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2592 enddef
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2593
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2594 def Test_debug_elseif_constant()
26678
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2595 var res = execute('disass debug s:ElseifConstant')
26352
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2596 assert_match('<SNR>\d*_ElseifConstant\_s*' ..
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2597 'if g:value\_s*' ..
26678
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2598 '0 DEBUG line 1-1 varcount 0\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2599 '1 LOADG g:value\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2600 '2 COND2BOOL\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2601 '3 JUMP_IF_FALSE -> 8\_s*' ..
26352
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2602 'echo "one"\_s*' ..
26678
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2603 '4 DEBUG line 2-2 varcount 0\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2604 '5 PUSHS "one"\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2605 '6 ECHO 1\_s*' ..
26352
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2606 'elseif true\_s*' ..
26678
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2607 '7 JUMP -> 12\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2608 '8 DEBUG line 3-3 varcount 0\_s*' ..
26352
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2609 'echo "true"\_s*' ..
26678
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2610 '9 DEBUG line 4-4 varcount 0\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2611 '10 PUSHS "true"\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2612 '11 ECHO 1\_s*' ..
26352
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2613 'elseif false\_s*' ..
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2614 'echo "false"\_s*' ..
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2615 'endif\_s*' ..
26678
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2616 'if 0\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2617 '12 DEBUG line 8-8 varcount 0\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2618 'echo "yes"\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2619 'elseif 0\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2620 '13 DEBUG line 11-10 varcount 0\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2621 'echo "no"\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2622 'endif\_s*' ..
e16806237a70 patch 8.2.3868: Vim9: function test fails
Bram Moolenaar <Bram@vim.org>
parents: 26594
diff changeset
2623 '14 RETURN void*',
26352
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2624 res)
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2625 enddef
f209f28ad898 patch 8.2.3707: Vim9: constant expression of elseif not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25814
diff changeset
2626
25660
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2627 def s:DebugElseif()
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2628 var b = false
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2629 if b
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2630 eval 1 + 0
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2631 silent elseif !b
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2632 eval 2 + 0
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2633 endif
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2634 enddef
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2635
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2636 def Test_debug_elseif()
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2637 var res = execute('disass debug s:DebugElseif')
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2638 assert_match('<SNR>\d*_DebugElseif\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2639 'var b = false\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2640 '0 DEBUG line 1-1 varcount 0\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2641 '1 PUSH false\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2642 '2 STORE $0\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2643
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2644 'if b\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2645 '3 DEBUG line 2-2 varcount 1\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2646 '4 LOAD $0\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2647 '5 JUMP_IF_FALSE -> 10\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2648
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2649 'eval 1 + 0\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2650 '6 DEBUG line 3-3 varcount 1\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2651 '7 PUSHNR 1\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2652 '8 DROP\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2653
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2654 'silent elseif !b\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2655 '9 JUMP -> 20\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2656 '10 CMDMOD silent\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2657 '11 DEBUG line 4-4 varcount 1\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2658 '12 LOAD $0\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2659 '13 INVERT -1 (!val)\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2660 '14 CMDMOD_REV\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2661 '15 JUMP_IF_FALSE -> 20\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2662
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2663 'eval 2 + 0\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2664 '16 DEBUG line 5-5 varcount 1\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2665 '17 PUSHNR 2\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2666 '18 DROP\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2667
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2668 'endif\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2669 '19 DEBUG line 6-6 varcount 1\_s*' ..
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2670 '20 RETURN void*',
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2671 res)
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2672 enddef
7b80b25a5c2b patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Bram Moolenaar <Bram@vim.org>
parents: 25634
diff changeset
2673
26905
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2674 def s:DebugFor()
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2675 echo "hello"
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2676 for a in [0]
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2677 echo a
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2678 endfor
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2679 enddef
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2680
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2681 def Test_debug_for()
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2682 var res = execute('disass debug s:DebugFor')
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2683 assert_match('<SNR>\d*_DebugFor\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2684 'echo "hello"\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2685 '0 DEBUG line 1-1 varcount 0\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2686 '1 PUSHS "hello"\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2687 '2 ECHO 1\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2688
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2689 'for a in \[0\]\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2690 '3 DEBUG line 2-2 varcount 0\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2691 '4 STORE -1 in $0\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2692 '5 PUSHNR 0\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2693 '6 NEWLIST size 1\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2694 '7 DEBUG line 2-2 varcount 2\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2695 '8 FOR $0 -> 15\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2696 '9 STORE $1\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2697
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2698 'echo a\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2699 '10 DEBUG line 3-3 varcount 2\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2700 '11 LOAD $1\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2701 '12 ECHO 1\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2702
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2703 'endfor\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2704 '13 DEBUG line 4-4 varcount 2\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2705 '14 JUMP -> 7\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2706 '15 DROP\_s*' ..
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2707 '16 RETURN void*',
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2708 res)
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2709 enddef
c2186e32ae42 patch 8.2.3981: Vim9: debugging a for loop doesn't stop before it starts
Bram Moolenaar <Bram@vim.org>
parents: 26739
diff changeset
2710
27541
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2711 def s:TryCatch()
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2712 try
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2713 echo "try"
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2714 catch /error/
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2715 echo "caught"
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2716 endtry
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2717 enddef
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2718
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2719 def Test_debug_try_catch()
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2720 var res = execute('disass debug s:TryCatch')
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2721 assert_match('<SNR>\d*_TryCatch\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2722 'try\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2723 '0 DEBUG line 1-1 varcount 0\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2724 '1 TRY catch -> 7, endtry -> 17\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2725 'echo "try"\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2726 '2 DEBUG line 2-2 varcount 0\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2727 '3 PUSHS "try"\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2728 '4 ECHO 1\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2729 'catch /error/\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2730 '5 DEBUG line 3-3 varcount 0\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2731 '6 JUMP -> 17\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2732 '7 DEBUG line 4-3 varcount 0\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2733 '8 PUSH v:exception\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2734 '9 PUSHS "error"\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2735 '10 COMPARESTRING =\~\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2736 '11 JUMP_IF_FALSE -> 17\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2737 '12 CATCH\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2738 'echo "caught"\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2739 '13 DEBUG line 4-4 varcount 0\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2740 '14 PUSHS "caught"\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2741 '15 ECHO 1\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2742 'endtry\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2743 '16 DEBUG line 5-5 varcount 0\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2744 '17 ENDTRY\_s*' ..
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2745 '\d\+ RETURN void',
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2746 res)
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2747 enddef
8af6e7761b0c patch 8.2.4297: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
2748
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
2749 func s:Legacy() dict
25800
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2750 echo 'legacy'
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2751 endfunc
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2752
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2753 def s:UseMember()
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2754 var d = {func: Legacy}
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2755 var v = d.func()
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2756 enddef
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2757
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2758 def Test_disassemble_dict_stack()
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2759 var res = execute('disass s:UseMember')
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2760 assert_match('<SNR>\d*_UseMember\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2761 'var d = {func: Legacy}\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2762 '\d PUSHS "func"\_s*' ..
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
2763 '\d PUSHFUNC "<80><fd>R\d\+_Legacy"\_s*' ..
25800
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2764 '\d NEWDICT size 1\_s*' ..
27728
fdc841530372 patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents: 27669
diff changeset
2765 '\d SETTYPE dict<func(...): any>\_s*' ..
25800
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2766 '\d STORE $0\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2767
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2768 'var v = d.func()\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2769 '\d LOAD $0\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2770 '\d MEMBER func\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2771 '\d PCALL top (argc 0)\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2772 '\d PCALL end\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2773 '\d CLEARDICT\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2774 '\d\+ STORE $1\_s*' ..
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2775 '\d\+ RETURN void*',
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2776 res)
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2777 enddef
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2778
28623
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2779 def s:RetLegacy(): string
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2780 legacy return "yes"
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2781 enddef
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2782
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2783 def Test_disassemble_return_legacy()
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2784 var res = execute('disass s:RetLegacy')
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2785 assert_match('<SNR>\d*_RetLegacy\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2786 'legacy return "yes"\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2787 '\d CMDMOD legacy\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2788 '\d EVAL legacy "yes"\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2789 '\d CHECKTYPE string stack\[-1]\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2790 '\d CMDMOD_REV\_s*' ..
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2791 '\d RETURN',
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2792 res)
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2793 enddef
1d92ba691dc4 patch 8.2.4835: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28598
diff changeset
2794
24444
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2795 def s:EchoMessages()
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2796 echohl ErrorMsg | echom v:exception | echohl NONE
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2797 enddef
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2798
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2799 def Test_disassemble_nextcmd()
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2800 # splitting commands and removing trailing blanks should not change the line
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2801 var res = execute('disass s:EchoMessages')
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2802 assert_match('<SNR>\d*_EchoMessages\_s*' ..
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2803 'echohl ErrorMsg | echom v:exception | echohl NONE',
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2804 res)
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2805 enddef
b5fbe8280853 patch 8.2.2762: Vim9: function line truncated when compiling
Bram Moolenaar <Bram@vim.org>
parents: 24430
diff changeset
2806
25461
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2807 def Test_disassemble_after_reload()
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2808 var lines =<< trim END
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2809 vim9script
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2810 if exists('g:ThisFunc')
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2811 finish
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2812 endif
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2813 var name: any
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2814 def g:ThisFunc(): number
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2815 g:name = name
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2816 return 0
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2817 enddef
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2818 def g:ThatFunc(): number
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2819 name = g:name
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2820 return 0
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2821 enddef
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2822 END
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2823 lines->writefile('Xreload.vim')
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2824
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2825 source Xreload.vim
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2826 g:ThisFunc()
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2827 g:ThatFunc()
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2828
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2829 source Xreload.vim
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2830 var res = execute('disass g:ThisFunc')
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2831 assert_match('ThisFunc\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2832 'g:name = name\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2833 '\d LOADSCRIPT \[deleted\] from .*/Xreload.vim\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2834 '\d STOREG g:name\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2835 'return 0\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2836 '\d PUSHNR 0\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2837 '\d RETURN\_s*',
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2838 res)
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2839
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2840 res = execute('disass g:ThatFunc')
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2841 assert_match('ThatFunc\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2842 'name = g:name\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2843 '\d LOADG g:name\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2844 '\d STORESCRIPT \[deleted\] in .*/Xreload.vim\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2845 'return 0\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2846 '\d PUSHNR 0\_s*' ..
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2847 '\d RETURN\_s*',
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2848 res)
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2849
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2850 delete('Xreload.vim')
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2851 delfunc g:ThisFunc
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2852 delfunc g:ThatFunc
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2853 enddef
891d08245543 patch 8.2.3267: Vim9: crash when disassembling using deleted script variable
Bram Moolenaar <Bram@vim.org>
parents: 25453
diff changeset
2854
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2855 def s:MakeString(x: number): string
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2856 return $"x={x} x^2={x * x}"
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2857 enddef
23586
8c5374ec8a3d patch 8.2.2335: Vim9: "silent return" does not restore command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 23557
diff changeset
2858
28718
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2859 def Test_disassemble_string_interp()
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2860 var instr = execute('disassemble s:MakeString')
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2861 assert_match('MakeString\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2862 'return $"x={x} x^2={x \* x}"\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2863 '0 PUSHS "x="\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2864 '1 LOAD arg\[-1\]\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2865 '2 2STRING stack\[-1\]\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2866 '3 PUSHS " x^2="\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2867 '4 LOAD arg\[-1\]\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2868 '5 LOAD arg\[-1\]\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2869 '6 OPNR \*\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2870 '7 2STRING stack\[-1\]\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2871 '8 CONCAT size 4\_s*' ..
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2872 '9 RETURN\_s*',
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2873 instr)
723c7d940cba patch 8.2.4883: string interpolation only works in heredoc
Bram Moolenaar <Bram@vim.org>
parents: 28692
diff changeset
2874 enddef
25800
fe8d153cb268 patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents: 25660
diff changeset
2875
28962
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2876 def BitShift()
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2877 var a = 1 << 2
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2878 var b = 8 >> 1
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2879 var c = a << b
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2880 var d = b << a
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2881 enddef
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2882
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2883 def Test_disassemble_bitshift()
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2884 var instr = execute('disassemble BitShift')
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2885 assert_match('BitShift\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2886 'var a = 1 << 2\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2887 '0 STORE 4 in $0\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2888 'var b = 8 >> 1\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2889 '1 STORE 4 in $1\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2890 'var c = a << b\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2891 '2 LOAD $0\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2892 '3 LOAD $1\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2893 '4 OPNR <<\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2894 '5 STORE $2\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2895 'var d = b << a\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2896 '6 LOAD $1\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2897 '7 LOAD $0\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2898 '8 OPNR <<\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2899 '9 STORE $3\_s*' ..
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2900 '10 RETURN void', instr)
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2901 enddef
abdea69d21b6 patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents: 28934
diff changeset
2902
30065
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2903 def s:OneDefer()
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2904 defer delete("file")
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2905 enddef
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2906
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2907 def Test_disassemble_defer()
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2908 var instr = execute('disassemble s:OneDefer')
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2909 assert_match('OneDefer\_s*' ..
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2910 'defer delete("file")\_s*' ..
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2911 '\d PUSHFUNC "delete"\_s*' ..
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2912 '\d PUSHS "file"\_s*' ..
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2913 '\d DEFER 1 args\_s*' ..
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2914 '\d RETURN\_s*',
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2915 instr)
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2916 enddef
6cf788ab844c patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents: 30025
diff changeset
2917
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2918 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker