annotate src/testdir/test_vim9_disassemble.vim @ 23458:d2b1269c2c68 v8.2.2272

patch 8.2.2272: Vim9: extend() can violate the type of a variable Commit: https://github.com/vim/vim/commit/aa210a3aeccc33c6051978017959126b037f94af Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 2 15:41:03 2021 +0100 patch 8.2.2272: Vim9: extend() can violate the type of a variable Problem: Vim9: extend() can violate the type of a variable. Solution: Add the type to the dictionary or list and check items against it. (closes #7593)
author Bram Moolenaar <Bram@vim.org>
date Sat, 02 Jan 2021 15:45:04 +0100
parents 4c6ebf531284
children f90e429453fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Test the :disassemble command, and compilation as a side effect
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
3 source check.vim
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
4
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 func NotCompiled()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 echo "not"
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 let s:scriptvar = 4
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 let g:globalvar = 'g'
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
11 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
12 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
13 let t:tabpagevar = 't'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 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
16 var local = 1
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 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
18 echo
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 echo arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 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
21 echo &lines
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 echo v:version
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 echo s:scriptvar
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 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
25 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
26 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
27 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
28 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
29 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
30 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
31 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
32 echo get(t:, "tab")
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 echo &tabstop
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 echo $ENVVAR
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 echo @z
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
38 def Test_disassemble_load()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 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
40 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
41 assert_fails('disass', 'E471:')
e4b326c9424a patch 8.2.0253: crash when using :disassamble without argument
Bram Moolenaar <Bram@vim.org>
parents: 19342
diff changeset
42 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
43 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
44 assert_fails('disass <XX>foo', 'E129:')
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
46 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
47 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
48 '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
49 '\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
50 '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
51 '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
52 '\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
53 '\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
54 '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
55 '\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
56 '\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
57 '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
58 '\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
59 '\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
60 '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
61 '\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
62 '\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
63 '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
64 '\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
65 '\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
66 '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
67 '\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
68 '\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
69 '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
70 '\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
71 '\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
72 '\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
73 '\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
74 '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
75 '\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
76 '\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
77 '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
78 '\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
79 '\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
80 '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
81 '\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
82 '\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
83 '\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
84 ' 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
85 '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
86 '\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
87 '\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
88 '\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
89 ' 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
90 '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
91 '\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
92 '\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
93 '\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
94 ' LOADENV $ENVVAR.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
95 ' LOADREG @z.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
96 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
99 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
100 var filename = "file"
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
101 var filenr = 123
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
102 edit the`=filename``=filenr`.txt
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
103 enddef
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
104
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
105 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
106 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
107 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
108 ' 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
109 '\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
110 '\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
111 ' 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
112 '\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
113 ' 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
114 '\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
115 '\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
116 '\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
117 '\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
118 '\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
119 '\d\+ EXECCONCAT 4\_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\+ PUSHNR 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
121 '\d\+ RETURN',
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 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
123 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
124
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 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
126 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
127 :'[,']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
128 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
129
3b312e56e2b8 patch 8.2.1427: Vim9: cannot use a range with marks in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
130 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
131 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
132 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
133 ' 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
134 '\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
135 ' :''\[,''\]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
136 '\d EXEC :''\[,''\]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
137 '\d PUSHNR 0\_s*' ..
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
138 '\d RETURN',
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
139 res)
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
140 enddef
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
141
22176
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
142 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
143 :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
144 enddef
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
145
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
146 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
147 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
148 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
149 ' :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
150 '\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
151 '\d PUT = 3\_s*' ..
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
152 '\d PUSHNR 0\_s*' ..
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
153 '\d RETURN',
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
154 res)
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
155 enddef
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 22147
diff changeset
156
23156
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
157 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
158 :$-2put a
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
159 enddef
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
160
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
161 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
162 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
163 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
164 ' :$-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
165 '\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
166 '\d PUT a range\_s*' ..
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
167 '\d PUSHNR 0\_s*' ..
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
168 '\d RETURN',
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
169 res)
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
170 enddef
6aa8ddf7a3fa patch 8.2.2124: Vim9: a range cannot be computed at runtime
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
171
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 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
173 var localbool = true
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
174 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
175 var localblob = 0z1234
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 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
177 var localfloat = 1.234
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 endif
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
181 def Test_disassemble_push()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
182 var res = execute('disass s:ScriptFuncPush')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
183 assert_match('<SNR>\d*_ScriptFuncPush.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
184 'localbool = true.*' ..
23438
4c6ebf531284 patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
185 ' PUSH true.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
186 'localspec = v:none.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
187 ' PUSH v:none.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
188 'localblob = 0z1234.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
189 ' PUSHBLOB 0z1234.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
190 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 if has('float')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
192 assert_match('<SNR>\d*_ScriptFuncPush.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
193 'localfloat = 1.234.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
194 ' PUSHF 1.234.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
195 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 endif
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 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
200 var localnr = 1
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 localnr = 2
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
202 var localstr = 'abc'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 localstr = 'xyz'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 v:char = 'abc'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 s:scriptvar = 'sv'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 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
207 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
208 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
209 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
210 t:tabpagevar = 'tv'
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 &tabstop = 8
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 $ENVVAR = 'ev'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 @z = 'rv'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
216 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
217 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
218 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
219 'var localnr = 1.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
220 'localnr = 2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
221 ' 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
222 'var localstr = ''abc''.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
223 'localstr = ''xyz''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
224 ' STORE $1.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
225 'v:char = ''abc''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
226 'STOREV v:char.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
227 's:scriptvar = ''sv''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
228 ' 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
229 'g:globalvar = ''gv''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
230 ' 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
231 '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
232 ' 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
233 '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
234 ' 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
235 '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
236 ' 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
237 '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
238 ' STORET t:tabpagevar.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
239 '&tabstop = 8.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
240 ' STOREOPT &tabstop.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
241 '$ENVVAR = ''ev''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
242 ' STOREENV $ENVVAR.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
243 '@z = ''rv''.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
244 ' STOREREG @z.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
245 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
248 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
249 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
250 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
251 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
252 localdict["a"] = 456
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
253 enddef
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
254
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
255 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
256 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
257 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
258 '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
259 '\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
260 '\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
261 '\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
262 '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
263 '\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
264 '\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
265 '\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
266 '\d STORELIST\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
267 '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
268 '\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
269 '\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
270 '\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
271 '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
272 '\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
273 '\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
274 '\d\+ LOAD $1\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
275 '\d\+ STOREDICT\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
276 '\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
277 '\d\+ RETURN',
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
278 res)
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
279 enddef
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
280
23266
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
281 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
282 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
283 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
284 enddef
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
285
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
286 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
287 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
288 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
289 '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
290 '\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
291 '\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
292 '\d NEWDICT size 1\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
293 '\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
294 '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
295 '\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
296 '\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
297 '\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
298 '\d MEMBER 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
299 '\d STOREINDEX\_s*' ..
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
300 '\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
301 '\d\+ RETURN',
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
302 res)
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
303 enddef
00f7cd9b6033 patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents: 23233
diff changeset
304
20913
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
305 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
306 var x: string
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
307 var y: string
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
308 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
309 [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
310 enddef
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
311
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
312 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
313 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
314 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
315 '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
316 '\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
317 '\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
318 '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
319 '\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
320 '\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
321 '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
322 '\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
323 '\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
324 '\[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
325 '\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
326 '\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
327 '\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
328 '\d\+ ITEM 0\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
329 '\d\+ CHECKTYPE string stack\[-1\]\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
330 '\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
331 '\d\+ ITEM 1\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
332 '\d\+ CHECKTYPE string stack\[-1\]\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
333 '\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
334 '\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
335 '\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
336 '\d\+ PUSHNR 0\_s*' ..
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
337 '\d\+ RETURN',
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
338 res)
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
339 enddef
a127db33a075 patch 8.2.1008: Vim9: no test for disassambling newly added instructions
Bram Moolenaar <Bram@vim.org>
parents: 20909
diff changeset
340
22633
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
341 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
342 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
343 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
344 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
345 enddef
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
346
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
347 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
348 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
349 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
350 '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
351 '\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
352 '\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
353 '\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
354 '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
355 '\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
356 '\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
357 '\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
358 '\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
359 '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
360 '\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
361 '\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
362 '\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
363 '\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
364 '\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
365 '\d\+ PUSHNR 0\_s*' ..
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
366 '\d\+ RETURN',
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
367 res)
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
368 enddef
6589dae9696c patch 8.2.1865: Vim9: add() does not check type of argument
Bram Moolenaar <Bram@vim.org>
parents: 22541
diff changeset
369
22637
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
370 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
371 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
372 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
373 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
374 enddef
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
375
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
376 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
377 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
378 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
379 '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
380 '\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
381 '\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
382 '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
383 '\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
384 '\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
385 '\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
386 '\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
387 '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
388 '\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
389 '\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
390 '\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
391 '\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
392 '\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
393 '\d\+ PUSHNR 0\_s*' ..
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
394 '\d\+ RETURN',
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
395 res)
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
396 enddef
4d4042683371 patch 8.2.1867: Vim9: argument to add() not checked for blob
Bram Moolenaar <Bram@vim.org>
parents: 22633
diff changeset
397
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
398 def s:ScriptFuncUnlet()
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
399 g:somevar = "value"
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
400 unlet g:somevar
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
401 unlet! g:somevar
20099
058b41f85bcb patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents: 20091
diff changeset
402 unlet $SOMEVAR
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
403 enddef
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
404
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
405 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
406 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
407 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
408 '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
409 '\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
410 '\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
411 '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
412 '\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
413 '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
414 '\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
415 'unlet $SOMEVAR\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
416 '\d UNLETENV $SOMEVAR\_s*',
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
417 res)
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
418 enddef
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
419
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 def s:ScriptFuncTry()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 try
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
422 echo "yes"
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 catch /fail/
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
424 echo "no"
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 finally
20407
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
426 throw "end"
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 endtry
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
430 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
431 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
432 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
433 'try\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
434 '\d TRY catch -> \d\+, finally -> \d\+\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
435 'echo "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
436 '\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
437 '\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
438 'catch /fail/\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
439 '\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
440 '\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
441 '\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
442 '\d COMPARESTRING =\~\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
443 '\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
444 '\d CATCH\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
445 'echo "no"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
446 '\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
447 '\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
448 'finally\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
449 'throw "end"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
450 '\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
451 '\d\+ THROW\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
452 'endtry\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
453 '\d\+ ENDTRY',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
454 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 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
458 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
459 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
460 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
462 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
463 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
464 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
465 '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
466 '\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
467 '\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
468 '\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
469 '\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
470 '\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
471 '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
472 '\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
473 '\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
474 '\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
475 '\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
476 '\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
477 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479
20029
8fb1cf4c44d5 patch 8.2.0570: Vim9: no error when omitting type from argument
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
480 def FuncWithArg(arg: any)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 echo arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 func UserFunc()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 echo 'nothing'
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 func UserFuncWithArg(arg)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 echo a:arg
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 endfunc
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 def s:ScriptFuncCall(): string
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 changenr()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 char2nr("abc")
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
495 Test_disassemble_new()
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 FuncWithArg(343)
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 ScriptFuncNew()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 s:ScriptFuncNew()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 UserFunc()
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 UserFuncWithArg("foo")
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
501 var FuncRef = function("UserFunc")
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 FuncRef()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
503 var FuncRefWithArg = function("UserFuncWithArg")
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 FuncRefWithArg("bar")
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 return "yes"
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
508 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
509 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
510 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
511 'changenr()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
512 '\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
513 '\d DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
514 'char2nr("abc")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
515 '\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
516 '\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
517 '\d DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
518 'Test_disassemble_new()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
519 '\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
520 '\d DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
521 'FuncWithArg(343)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
522 '\d\+ PUSHNR 343\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
523 '\d\+ DCALL FuncWithArg(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
524 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
525 'ScriptFuncNew()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
526 '\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
527 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
528 's:ScriptFuncNew()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
529 '\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
530 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
531 'UserFunc()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
532 '\d\+ UCALL UserFunc(argc 0)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
533 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
534 'UserFuncWithArg("foo")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
535 '\d\+ PUSHS "foo"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
536 '\d\+ UCALL UserFuncWithArg(argc 1)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
537 '\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
538 '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
539 '\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
540 '\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
541 '\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
542 'FuncRef()\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
543 '\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
544 '\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
545 '\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
546 '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
547 '\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
548 '\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
549 '\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
550 'FuncRefWithArg("bar")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
551 '\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
552 '\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
553 '\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
554 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
555 'return "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
556 '\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
557 '\d\+ RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
558 res)
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 enddef
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560
22541
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
561
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
562 def s:CreateRefs()
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
563 var local = 'a'
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
564 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
565 local ..= arg
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
566 enddef
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
567 g:Append = Append
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
568 def Get(): string
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
569 return local
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
570 enddef
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
571 g:Get = Get
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
572 enddef
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
573
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
574 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
575 CreateRefs()
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
576 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
577 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
578 'local ..= arg\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
579 '\d LOADOUTER $0\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
580 '\d LOAD arg\[-1\]\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
581 '\d CONCAT\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
582 '\d STOREOUTER $0\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
583 '\d PUSHNR 0\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
584 '\d RETURN',
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
585 res)
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
586
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
587 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
588 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
589 'return local\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
590 '\d LOADOUTER $0\_s*' ..
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
591 '\d RETURN',
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
592 res)
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
593
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
594 unlet g:Append
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
595 unlet g:Get
7d6ba4204f66 patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents: 22533
diff changeset
596 enddef
20295
bc2c9ea94ec1 patch 8.2.0703: Vim9: closure cannot store value in outer context
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
597
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
598
19862
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
599 def EchoArg(arg: string): string
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
600 return arg
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
601 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
602 def RefThis(): func
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
603 return function('EchoArg')
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
604 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
605 def s:ScriptPCall()
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
606 RefThis()("text")
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
607 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
608
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
609 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
610 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
611 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
612 'RefThis()("text")\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
613 '\d DCALL RefThis(argc 0)\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
614 '\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
615 '\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
616 '\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
617 '\d DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
618 '\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
619 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
620 res)
19862
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
621 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
622
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19703
diff changeset
623
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20029
diff changeset
624 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
625 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
626 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
627
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
628 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
629 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
630 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
631
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
632 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
633 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
634 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
635 '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
636 '\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
637 '\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
638 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
639 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
640
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21299
diff changeset
641 # 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
642 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
643
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20029
diff changeset
644 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
645 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
646 '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
647 '\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
648 '\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
649 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
650 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
651 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
652
b8f778dda1a1 patch 8.2.0323: Vim9: calling a function that is defined later is slow
Bram Moolenaar <Bram@vim.org>
parents: 19528
diff changeset
653
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
654 def FuncWithDefault(arg: string = 'default'): string
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
655 return arg
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
656 enddef
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
657
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
658 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
659 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
660 assert_match('FuncWithDefault\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
661 '\d PUSHS "default"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
662 '\d STORE arg\[-1]\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
663 'return arg\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
664 '\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
665 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
666 res)
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
667 enddef
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
668
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19439
diff changeset
669
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
670 def HasEval()
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
671 if has("eval")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
672 echo "yes"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
673 else
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
674 echo "no"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
675 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
676 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
677
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
678 def HasNothing()
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
679 if has("nothing")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
680 echo "yes"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
681 else
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
682 echo "no"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
683 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
684 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
685
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
686 def HasSomething()
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
687 if has("nothing")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
688 echo "nothing"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
689 elseif has("something")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
690 echo "something"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
691 elseif has("eval")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
692 echo "eval"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
693 elseif has("less")
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
694 echo "less"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
695 endif
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
696 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
697
22842
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
698 def HasGuiRunning()
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
699 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
700 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
701 else
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
702 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
703 endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
704 enddef
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
705
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
706 def Test_disassemble_const_expr()
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
707 assert_equal("\nyes", execute('HasEval()'))
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
708 var 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
709 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
710 '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
711 'echo "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
712 '\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
713 '\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
714 'else\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
715 'echo "no"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
716 'endif\_s*',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
717 instr)
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
718 assert_notmatch('JUMP', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
719
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
720 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
721 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
722 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
723 '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
724 'echo "yes"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
725 'else\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
726 'echo "no"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
727 '\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
728 '\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
729 'endif',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
730 instr)
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
731 assert_notmatch('PUSHS "yes"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
732 assert_notmatch('JUMP', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
733
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
734 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
735 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
736 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
737 '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
738 'echo "nothing"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
739 '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
740 'echo "something"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
741 '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
742 'echo "eval"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
743 '\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
744 '\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
745 'elseif has("less").*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
746 'echo "less"\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
747 'endif',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
748 instr)
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
749 assert_notmatch('PUSHS "nothing"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
750 assert_notmatch('PUSHS "something"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
751 assert_notmatch('PUSHS "less"', instr)
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
752 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
753
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
754 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
755 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
756 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
757 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
758 # 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
759 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
760 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
761 '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
762 ' 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
763 '\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
764 '\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
765 '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
766 ' 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
767 'endif'
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
768 else
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
769 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
770 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
771 # 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
772 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
773 '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
774 '\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
775 '\d BCALL has(argc 1)\_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
776 '\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
777 '\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
778 ' 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
779 '\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
780 '\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
781 '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
782 '\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
783 ' 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
784 '\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
785 '\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
786 'endif'
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
787 else
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
788 # 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
789 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
790 '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
791 ' 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
792 '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
793 ' 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
794 '\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
795 '\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
796 'endif'
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
797 endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
798 endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
799 else
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
800 # 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
801 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
802 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
803 '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
804 ' 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
805 '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
806 ' 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
807 '\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
808 '\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
809 'endif'
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
810 endif
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
811
f2fbbb72ff28 patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically
Bram Moolenaar <Bram@vim.org>
parents: 22816
diff changeset
812 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
813 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
814 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
815 enddef
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
816
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
817 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
818 if 1 < 0
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
819 return "maybe"
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
820 endif
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
821 if g:cond
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
822 return "yes"
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
823 else
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
824 return "no"
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
825 endif
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
826 enddef
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
827
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
828 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
829 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
830 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
831 '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
832 ' return "maybe"\_s*' ..
edfbb06cd0ee patch 8.2.2010: Vim9: compiling fails for unreachable return statement
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
833 'endif\_s*' ..
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
834 'if g:cond\_s*' ..
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
835 '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
836 '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
837 '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
838 '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
839 '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
840 '4 RETURN\_s*' ..
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
841 'else\_s*' ..
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
842 ' 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
843 '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
844 '6 RETURN$',
20909
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
845 instr)
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
846 enddef
0d7465881b06 patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
847
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
848 def WithFunc()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
849 var Funky1: func
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
850 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
851 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
852 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
853
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
854 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
855 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
856 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
857 '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
858 '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
859 '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
860 '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
861 '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
862 '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
863 '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
864 '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
865 '\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
866 '\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
867 '\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
868 '\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
869 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
870 instr)
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
871 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
872
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
873 if has('channel')
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
874 def WithChannel()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
875 var job1: job
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
876 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
877 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
878 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
879 endif
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
880
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
881 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
882 CheckFeature channel
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
883
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
884 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
885 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
886 '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
887 '\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
888 '\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
889 '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
890 '\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
891 '\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
892 '\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
893 '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
894 '\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
895 '\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
896 '\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
897 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
898 instr)
19572
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
899 enddef
6b6e97d0185e patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
900
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
901 def WithLambda(): string
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
902 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
903 return F("x")
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
904 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
905
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
906 def Test_disassemble_lambda()
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
907 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
908 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
909 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
910 '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
911 '\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
912 '\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
913 '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
914 '\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
915 '\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
916 '\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
917 '\d RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
918 instr)
21299
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
919
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
920 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
921 instr = execute('disassemble ' .. name)
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
922 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
923 '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
924 '\d PUSHS "X"\_s*' ..
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
925 '\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
926 '\d 2STRING_ANY stack\[-1\]\_s*' ..
21299
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
927 '\d CONCAT\_s*' ..
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
928 '\d PUSHS "X"\_s*' ..
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
929 '\d CONCAT\_s*' ..
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
930 '\d RETURN',
883315e762b7 patch 8.2.1200: Vim9: cannot disassemble a lambda function
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
931 instr)
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
932 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
933
22816
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
934 def LambdaWithType(): number
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
935 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
936 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
937 enddef
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
938
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
939 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
940 g:value = 5
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
941 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
942 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
943 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
944 '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
945 '\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
946 '\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
947 '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
948 '\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
949 '\d LOAD $0\_s*' ..
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
950 '\d CHECKTYPE number stack\[-2\]\_s*' ..
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
951 '\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
952 '\d RETURN',
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
953 instr)
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
954 enddef
8a5369f5f2b4 patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents: 22703
diff changeset
955
21558
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
956 def NestedOuter()
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
957 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
958 echomsg "inner"
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
959 enddef
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
960 enddef
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
961
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
962 def Test_nested_func()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
963 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
964 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
965 '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
966 '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
967 'enddef\_s*' ..
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
968 '\d NEWFUNC <lambda>\d\+ Inner\_s*' ..
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
969 '\d PUSHNR 0\_s*' ..
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
970 '\d RETURN',
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
971 instr)
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
972 enddef
1c4d4aa22b37 patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
973
22973
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
974 def NestedDefList()
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
975 def
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
976 def Info
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
977 def /Info
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
978 def /Info/
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
979 enddef
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
980
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
981 def Test_nested_def_list()
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
982 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
983 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
984 'def\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
985 '\d DEF \_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
986 'def Info\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
987 '\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
988 'def /Info\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
989 '\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
990 'def /Info/\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
991 '\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
992 '\d PUSHNR 0\_s*' ..
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
993 '\d RETURN',
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
994 instr)
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
995 enddef
4c97c0747017 patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents: 22926
diff changeset
996
20029
8fb1cf4c44d5 patch 8.2.0570: Vim9: no error when omitting type from argument
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
997 def AndOr(arg: any): string
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
998 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
999 return 'yes'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1000 endif
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1001 return 'no'
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1002 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1003
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1004 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
1005 assert_equal("yes", AndOr(1))
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1006 assert_equal("no", AndOr(2))
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1007 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
1008 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
1009 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
1010 '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
1011 '\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
1012 '\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
1013 '\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
1014 '\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
1015 '\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
1016 '\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
1017 '\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
1018 '\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
1019 '\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
1020 '\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
1021 '\d\+ COMPAREANY ==\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1022 '\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
1023 instr)
19334
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1024 enddef
61646c189622 patch 8.2.0225: compiling lambda not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19332
diff changeset
1025
19336
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1026 def 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
1027 var res: list<number>
19336
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1028 for i in range(3)
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1029 res->add(i)
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1030 endfor
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1031 return res
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1032 enddef
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1033
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1034 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
1035 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
1036 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
1037 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
1038 '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
1039 '\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
1040 '\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
1041 '\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
1042 '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
1043 '\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
1044 '\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
1045 '\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
1046 '\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
1047 '\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
1048 '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
1049 '\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
1050 '\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
1051 '\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
1052 '\d\+ DROP\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1053 'endfor\_s*' ..
33166d945b54 patch 8.2.0758: Vim9: no test for STORELIST and STOREDICT
Bram Moolenaar <Bram@vim.org>
parents: 20405
diff changeset
1054 '\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
1055 '\d\+ DROP',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1056 instr)
19336
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1057 enddef
1cd6eab65ce0 patch 8.2.0226: compiling for loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19334
diff changeset
1058
21188
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1059 def ForLoopEval(): string
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1060 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
1061 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
1062 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
1063 endfor
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1064 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
1065 enddef
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1066
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1067 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
1068 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
1069 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
1070 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
1071 '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
1072 '\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
1073 '\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
1074 '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
1075 '\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
1076 '\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
1077 '\d BCALL eval(argc 1)\_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
1078 '\d CHECKTYPE list<any> stack\[-1\]\_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
1079 '\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
1080 '\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
1081 '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
1082 '\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
1083 '\d\+ LOAD $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
1084 '\d\+ CHECKTYPE string stack\[-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
1085 '\d\+ CONCAT\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1086 '\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
1087 'endfor\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1088 '\d\+ JUMP -> 6\_s*' ..
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1089 '\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
1090 '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
1091 '\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
1092 '\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
1093 instr)
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1094 enddef
d73b6ba20053 patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20945
diff changeset
1095
22975
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1096 def ForLoopUnpack()
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1097 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
1098 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
1099 endfor
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1100 enddef
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1101
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1102 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
1103 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
1104 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
1105 '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
1106 '\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
1107 '\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
1108 '\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
1109 '\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
1110 '\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
1111 '\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
1112 '\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
1113 '\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
1114 '\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
1115 '\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
1116 '\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
1117 '\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
1118 '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
1119 '\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
1120 '\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
1121 '\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
1122 '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
1123 '\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
1124 '\d\+ DROP\_s*' ..
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1125 '\d\+ PUSHNR 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
1126 '\d\+ RETURN',
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1127 instr)
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1128 enddef
a943b175586a patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1129
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1130 let g:number = 42
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1131
21717
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1132 def TypeCast()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1133 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
1134 enddef
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1135
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1136 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
1137 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
1138 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
1139 '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
1140 '\d PUSHNR 23\_s*' ..
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1141 '\d LOADG g:number\_s*' ..
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1142 '\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
1143 '\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
1144 '\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
1145 '\d STORE $0\_s*' ..
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1146 '\d PUSHNR 0\_s*' ..
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1147 '\d RETURN\_s*',
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1148 instr)
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1149 enddef
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21558
diff changeset
1150
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1151 def Computing()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1152 var nr = 3
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1153 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
1154 nrres = nr - 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1155 nrres = nr * 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1156 nrres = nr / 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1157 nrres = nr % 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1158
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1159 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
1160 anyres = g:number - 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1161 anyres = g:number * 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1162 anyres = g:number / 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1163 anyres = g:number % 7
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1164
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1165 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
1166 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
1167 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
1168 flres = fl - 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1169 flres = fl * 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1170 flres = fl / 7.0
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1171 endif
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1172 enddef
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1173
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1174 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
1175 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
1176 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
1177 'var nr = 3.*' ..
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1178 '\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
1179 '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
1180 '\d LOAD $0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1181 '\d PUSHNR 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1182 '\d OPNR +.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1183 '\d STORE $1.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1184 'nrres = nr - 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1185 '\d OPNR -.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1186 'nrres = nr \* 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1187 '\d OPNR \*.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1188 'nrres = nr / 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1189 '\d OPNR /.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1190 'nrres = nr % 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1191 '\d OPNR %.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1192 '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
1193 '\d LOADG g:number.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1194 '\d PUSHNR 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1195 '\d OPANY +.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1196 '\d STORE $2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1197 'anyres = g:number - 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1198 '\d OPANY -.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1199 'anyres = g:number \* 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1200 '\d OPANY \*.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1201 'anyres = g:number / 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1202 '\d OPANY /.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1203 'anyres = g:number % 7.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1204 '\d OPANY %.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1205 instr)
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1206 if has('float')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1207 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
1208 '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
1209 '\d PUSHF 3.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1210 '\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
1211 '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
1212 '\d LOAD $3.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1213 '\d PUSHF 7.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1214 '\d OPFLOAT +.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1215 '\d STORE $4.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1216 'flres = fl - 7.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1217 '\d OPFLOAT -.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1218 'flres = fl \* 7.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1219 '\d OPFLOAT \*.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1220 'flres = fl / 7.0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1221 '\d OPFLOAT /.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1222 instr)
19338
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1223 endif
ef432264b88a patch 8.2.0227: compiling a few instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19336
diff changeset
1224 enddef
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1226 def AddListBlob()
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1227 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
1228 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
1229 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1230
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1231 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
1232 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
1233 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
1234 '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
1235 '\d PUSHNR 1.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1236 '\d PUSHNR 2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1237 '\d NEWLIST size 2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1238 '\d PUSHNR 3.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1239 '\d PUSHNR 4.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1240 '\d NEWLIST size 2.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1241 '\d ADDLIST.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1242 '\d STORE $.*.*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1243 '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
1244 '\d PUSHBLOB 0z1122.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1245 '\d PUSHBLOB 0z3344.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1246 '\d ADDBLOB.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1247 '\d STORE $.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1248 instr)
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1249 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1250
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1251 let g:aa = 'aa'
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1252 def ConcatString(): string
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1253 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
1254 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1255 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1256
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1257 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
1258 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
1259 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
1260 '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
1261 '\d LOADG g:aa.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1262 '\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
1263 '\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
1264 '\d CONCAT.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1265 '\d STORE $.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1266 instr)
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1267 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
1268 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1269
21826
ccad66ac6c3e patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
1270 def StringIndex(): string
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1271 var s = "abcd"
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1272 var res = s[1]
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1273 return res
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1274 enddef
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1275
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1276 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
1277 var instr = execute('disassemble StringIndex')
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1278 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
1279 'var s = "abcd"\_s*' ..
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1280 '\d PUSHS "abcd"\_s*' ..
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1281 '\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
1282 'var res = s\[1]\_s*' ..
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1283 '\d LOAD $0\_s*' ..
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1284 '\d PUSHNR 1\_s*' ..
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1285 '\d STRINDEX\_s*' ..
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1286 '\d STORE $1\_s*',
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1287 instr)
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1288 assert_equal('b', StringIndex())
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1289 enddef
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1290
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1291 def StringSlice(): string
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1292 var s = "abcd"
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1293 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
1294 return res
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1295 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1296
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1297 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
1298 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
1299 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
1300 '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
1301 '\d PUSHS "abcd"\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1302 '\d STORE $0\_s*' ..
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1303 '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
1304 '\d LOAD $0\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1305 '\d PUSHNR 1\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1306 '\d PUSHNR 8\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1307 '\d STRSLICE\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1308 '\d STORE $1\_s*',
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1309 instr)
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1310 assert_equal('bcd', StringSlice())
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1311 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1312
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1313 def ListIndex(): number
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1314 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
1315 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
1316 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1317 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1318
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1319 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
1320 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
1321 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
1322 '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
1323 '\d PUSHNR 1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1324 '\d PUSHNR 2\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1325 '\d PUSHNR 3\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1326 '\d NEWLIST size 3\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1327 '\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
1328 '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
1329 '\d LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1330 '\d PUSHNR 1\_s*' ..
21397
62339482daab patch 8.2.1249: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1331 '\d LISTINDEX\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1332 '\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
1333 instr)
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1334 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
1335 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1336
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1337 def 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
1338 var l = [1, 2, 3]
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1339 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
1340 return res
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1341 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1342
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1343 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
1344 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
1345 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
1346 '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
1347 '\d PUSHNR 1\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1348 '\d PUSHNR 2\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1349 '\d PUSHNR 3\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1350 '\d NEWLIST size 3\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1351 '\d STORE $0\_s*' ..
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1352 '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
1353 '\d LOAD $0\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1354 '\d PUSHNR 1\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1355 '\d PUSHNR 8\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1356 '\d LISTSLICE\_s*' ..
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1357 '\d STORE $1\_s*',
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1358 instr)
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1359 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
1360 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
1361
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1362 def 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
1363 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
1364 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
1365 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
1366 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1367 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1368
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1369 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
1370 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
1371 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
1372 '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
1373 '\d PUSHS "item"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1374 '\d PUSHNR 1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1375 '\d NEWDICT size 1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1376 '\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
1377 '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
1378 '\d\+ LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1379 '\d\+ MEMBER item\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1380 '\d\+ STORE $1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1381 'res = d\["item"\]\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1382 '\d\+ LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1383 '\d\+ PUSHS "item"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1384 '\d\+ MEMBER\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1385 '\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
1386 instr)
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1387 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
1388 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1389
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
1390 let somelist = [1, 2, 3, 4, 5]
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1391 def AnyIndex(): number
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1392 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
1393 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
1394 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
1395
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1396 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
1397 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
1398 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
1399 '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
1400 '\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
1401 '\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
1402 '\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
1403 '\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
1404 '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
1405 '\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
1406 '\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
1407 '\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
1408 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
1409 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
1410 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
1411
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1412 def AnySlice(): list<number>
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1413 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
1414 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
1415 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
1416
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
1417 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
1418 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
1419 assert_match('AnySlice\_s*' ..
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1420 '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
1421 '\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
1422 '\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
1423 '\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
1424 '\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
1425 '\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
1426 '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
1427 '\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
1428 '\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
1429 '\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
1430 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
1431 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
1432 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
1433
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1434 def NegateNumber(): number
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1435 var nr = 9
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1436 var plus = +nr
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1437 var res = -nr
19439
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1438 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1439 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1440
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1441 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
1442 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
1443 assert_match('NegateNumber\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1444 'var nr = 9\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1445 '\d STORE 9 in $0\_s*' ..
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1446 'var plus = +nr\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1447 '\d LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1448 '\d CHECKNR\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1449 '\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
1450 'var res = -nr\_s*' ..
20405
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1451 '\d LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1452 '\d NEGATENR\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1453 '\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
1454 instr)
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1455 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
1456 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1457
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1458 def InvertBool(): bool
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1459 var flag = true
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1460 var invert = !flag
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1461 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
1462 return res
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1463 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1464
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1465 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
1466 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
1467 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
1468 '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
1469 '\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
1470 '\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
1471 '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
1472 '\d LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1473 '\d INVERT (!val)\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1474 '\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
1475 '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
1476 '\d LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1477 '\d 2BOOL (!!val)\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1478 '\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
1479 instr)
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
1480 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
1481 enddef
b347a6c61090 patch 8.2.0277: Vim9: not all instructions covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19390
diff changeset
1482
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
1483 def ReturnBool(): bool
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1484 var name: bool = 1 && 0 || 1
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1485 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
1486 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
1487
d835f2fdfcfc patch 8.2.1647: Vim9: result of expression with && and || is not a bool
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
1488 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
1489 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
1490 assert_match('ReturnBool\_s*' ..
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1491 'var name: bool = 1 && 0 || 1\_s*' ..
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1492 '0 PUSHNR 1\_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
1493 '1 2BOOL (!!val)\_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
1494 '2 JUMP_IF_COND_FALSE -> 5\_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
1495 '3 PUSHNR 0\_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
1496 '4 2BOOL (!!val)\_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
1497 '5 JUMP_IF_COND_TRUE -> 8\_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
1498 '6 PUSHNR 1\_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
1499 '7 2BOOL (!!val)\_s*' ..
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
1500 '\d STORE $0\_s*' ..
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
1501 'return name\_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
1502 '\d\+ LOAD $0\_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
1503 '\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
1504 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
1505 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
1506 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
1507
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1508 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
1509 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
1510 ['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
1511 ['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
1512 ['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
1513 ['v:none != isNull', 'COMPARESPECIAL !='],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1514
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
1515 ['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
1516 ['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
1517 ['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
1518 ['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
1519 ['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
1520 ['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
1521 ['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
1522 ['111 !~ aNumber', 'COMPARENR !\~'],
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1523
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
1524 ['"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
1525 ['"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
1526 ['"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
1527 ['"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
1528 ['"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
1529 ['"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
1530 ['"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
1531 ['"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
1532 ['"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
1533
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
1534 ['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
1535 ['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
1536 ['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
1537 ['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
1538
20328
445c2b2ea44b patch 8.2.0719: Vim9: more expressions can be evaluated at compile time
Bram Moolenaar <Bram@vim.org>
parents: 20324
diff changeset
1539 ['[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
1540 ['[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
1541 ['[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
1542 ['[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
1543
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22975
diff changeset
1544 ['{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
1545 ['{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
1546 ['{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
1547 ['{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
1548
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
1549 ['(() => 33) == (() => 44)', 'COMPAREFUNC =='],
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
1550 ['(() => 33) != (() => 44)', 'COMPAREFUNC !='],
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
1551 ['(() => 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
1552 ['(() => 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
1553
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1554 ['77 == g:xx', 'COMPAREANY =='],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1555 ['77 != g:xx', 'COMPAREANY !='],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1556 ['77 > g:xx', 'COMPAREANY >'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1557 ['77 < g:xx', 'COMPAREANY <'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1558 ['77 >= g:xx', 'COMPAREANY >='],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1559 ['77 <= g:xx', 'COMPAREANY <='],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1560 ['77 =~ g:xx', 'COMPAREANY =\~'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1561 ['77 !~ g:xx', 'COMPAREANY !\~'],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1562 ['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
1563 ['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
1564 ]
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1565 var floatDecl = ''
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1566 if has('float')
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1567 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
1568 ['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
1569 ['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
1570 ['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
1571 ['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
1572 ['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
1573 ['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
1574 ['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
1575 ['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
1576 ])
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1577 floatDecl = 'var aFloat = 2.2'
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1578 endif
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1579
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1580 var nr = 1
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1581 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
1582 # 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
1583 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
1584 ' var isFalse = false',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1585 ' 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
1586 ' var aNumber = 222',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1587 ' var aString = "yy"',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1588 ' var aBlob = 0z22',
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1589 ' 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
1590 ' 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
1591 floatDecl,
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1592 ' if ' .. case[0],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1593 ' echo 42'
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1594 ' endif',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1595 'enddef'], 'Xdisassemble')
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1596 source Xdisassemble
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1597 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
1598 assert_match('TestCase' .. nr .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1599 '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
1600 '\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
1601 '\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
1602 '\d ' .. case[1] .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1603 '\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
1604 instr)
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1605
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1606 nr += 1
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1607 endfor
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1608
19703
f03357f16ffc patch 8.2.0408: delete() commented out for testing
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
1609 delete('Xdisassemble')
19342
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1610 enddef
8ff84bc1c89b patch 8.2.0229: compare instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19338
diff changeset
1611
22492
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1612 def s:FalsyOp()
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1613 echo g:flag ?? "yes"
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1614 echo [] ?? "empty list"
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1615 echo "" ?? "empty string"
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1616 enddef
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1617
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1618 def Test_dsassemble_falsy_op()
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1619 var res = execute('disass s:FalsyOp')
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1620 assert_match('\<SNR>\d*_FalsyOp\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1621 'echo g:flag ?? "yes"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1622 '0 LOADG g:flag\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1623 '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
1624 '2 PUSHS "yes"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1625 '3 ECHO 1\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1626 'echo \[\] ?? "empty list"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1627 '4 NEWLIST size 0\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1628 '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
1629 '6 PUSHS "empty list"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1630 '7 ECHO 1\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1631 'echo "" ?? "empty string"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1632 '\d\+ PUSHS "empty string"\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1633 '\d\+ ECHO 1\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1634 '\d\+ PUSHNR 0\_s*' ..
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1635 '\d\+ RETURN',
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1636 res)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1637 enddef
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1638
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1639 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
1640 var cases = [
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1641 ['"xx" == "yy"', false],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1642 ['"aa" == "aa"', true],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1643 ['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
1644 ['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
1645 ]
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1646
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1647 var nr = 1
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1648 for case in cases
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1649 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
1650 ' if ' .. case[0],
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1651 ' echo 42'
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1652 ' endif',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1653 'enddef'], 'Xdisassemble')
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1654 source Xdisassemble
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1655 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
1656 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
1657 # 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
1658 assert_match('TestCase' .. nr .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1659 '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
1660 '\d PUSHNR 42.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1661 '\d ECHO 1.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1662 '\d PUSHNR 0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1663 '\d RETURN.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1664 instr)
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1665 else
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21299
diff changeset
1666 # 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
1667 assert_match('TestCase' .. nr .. '.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1668 '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
1669 'echo 42[ \n]*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1670 'endif[ \n]*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1671 '\s*\d PUSHNR 0.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1672 '\d RETURN.*',
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1673 instr)
19880
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1674 endif
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1675
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1676 nr += 1
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1677 endfor
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1678
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1679 delete('Xdisassemble')
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1680 enddef
50fa63ca3828 patch 8.2.0496: Vim9: disassemble test fails
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
1681
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1682 def s:Execute()
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1683 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
1684 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
1685 execute cmd
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1686 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
1687 execute 'help ' .. tag
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1688 enddef
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1689
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1690 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
1691 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
1692 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
1693 "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
1694 '\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
1695 '\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
1696 "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
1697 '\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
1698 '\d STORE $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1699 'execute cmd\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1700 '\d LOAD $0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1701 '\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
1702 "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
1703 '\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
1704 '\d STORE $1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1705 "execute 'help ' .. tag\\_s*" ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1706 '\d\+ PUSHS "help "\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1707 '\d\+ LOAD $1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1708 '\d\+ CONCAT\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1709 '\d\+ EXECUTE 1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1710 '\d\+ PUSHNR 0\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1711 '\d\+ RETURN',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1712 res)
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1713 enddef
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
1714
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1715 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
1716 echomsg 'some' 'message'
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1717 echoerr 'went' .. 'wrong'
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1718 enddef
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1719
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1720 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
1721 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
1722 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
1723 "echomsg 'some' 'message'\\_s*" ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1724 '\d PUSHS "some"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1725 '\d PUSHS "message"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1726 '\d ECHOMSG 2\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1727 "echoerr 'went' .. 'wrong'\\_s*" ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1728 '\d PUSHS "wentwrong"\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1729 '\d ECHOERR 1\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1730 '\d PUSHNR 0\_s*' ..
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1731 '\d RETURN',
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1732 res)
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1733 enddef
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1734
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1735 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
1736 echo arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1737 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1738
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1739 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
1740 echo arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1741 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1742
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1743 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
1744 return arg
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1745 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1746
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1747 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
1748 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
1749 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
1750 '\d *echo arg.*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1751 ' *enddef',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1752 res1)
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1753
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1754 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
1755 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
1756 '\d *echo arg\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1757 ' *enddef',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1758 res2)
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1759
22425
eabc059a6ac4 patch 8.2.1761: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22371
diff changeset
1760 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
1761 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
1762 '\d *return arg\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1763 ' *enddef',
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1764 res3)
19579
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1765 enddef
aae19dd172c0 patch 8.2.0346: Vim9: finding common list type not tested
Bram Moolenaar <Bram@vim.org>
parents: 19572
diff changeset
1766
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
1767 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
1768 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
1769 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
1770 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
1771 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
1772 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
1773 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
1774 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
1775 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
1776 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
1777 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
1778 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
1779 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
1780
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21299
diff changeset
1781 # 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
1782 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
1783 'return FuncTwo()\_s*' ..
83573e907c8b patch 8.2.0757: Vim9: no test for MEMBER instruction
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1784 '\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
1785 '\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
1786 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
1787
7587d892c00c patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20336
diff changeset
1788 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
1789 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
1790 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
1791
20305
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
1792 def s:ConcatStrings(): string
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
1793 return 'one' .. 'two' .. 'three'
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
1794 enddef
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
1795
20324
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
1796 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
1797 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
1798 enddef
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
1799
20336
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
1800 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
1801 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
1802 enddef
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
1803
20305
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
1804 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
1805 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
1806 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
1807 "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
1808 '\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
1809 '\d RETURN',
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
1810 res)
20324
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
1811
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
1812 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
1813 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
1814 '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
1815 '\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
1816 '\d RETURN',
23188ef99fc2 patch 8.2.0717: Vim9: postponed constant expressions does not scale
Bram Moolenaar <Bram@vim.org>
parents: 20305
diff changeset
1817 res)
20336
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
1818
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
1819 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
1820 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
1821 '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
1822 '\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
1823 '\d RETURN',
2fd980fb9ab3 patch 8.2.0723: Vim9: nested constant expression not evaluated compile time
Bram Moolenaar <Bram@vim.org>
parents: 20328
diff changeset
1824 res)
20305
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
1825 enddef
9a5e2370df0e patch 8.2.0708: Vim9: constant expressions are not simplified
Bram Moolenaar <Bram@vim.org>
parents: 20301
diff changeset
1826
21232
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
1827 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
1828 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
1829 enddef
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
1830
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
1831 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
1832 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
1833 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
1834 '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
1835 '\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
1836 '\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
1837 '\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
1838 '\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
1839 '\d DROP\_s*' ..
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
1840 '\d PUSHNR 0\_s*' ..
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
1841 '\d RETURN',
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
1842 res)
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
1843 enddef
3f14e0d4a4dd patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents: 21188
diff changeset
1844
22691
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1845
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1846 def s:SilentMessage()
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1847 silent echomsg "text"
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1848 silent! echoerr "error"
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1849 enddef
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1850
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1851 def Test_silent()
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1852 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
1853 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
1854 '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
1855 '\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
1856 '\d PUSHS "text"\_s*' ..
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1857 '\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
1858 '\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
1859 '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
1860 '\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
1861 '\d PUSHS "error"\_s*' ..
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1862 '\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
1863 '\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
1864 '\d PUSHNR 0\_s*' ..
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1865 '\d RETURN',
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1866 res)
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1867 enddef
dda110a14be4 patch 8.2.1894: Vim9: command modifiers are not supported
Bram Moolenaar <Bram@vim.org>
parents: 22637
diff changeset
1868
19330
9c8b803fe598 patch 8.2.0223: some instructions not yet tested
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1869 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker