Mercurial > vim
annotate src/testdir/vim9.vim @ 28103:1615d305c71d v8.2.4576
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Commit: https://github.com/vim/vim/commit/056678184f679c2989b73bd48eda112f3c79a62f
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Mar 15 20:21:33 2022 +0000
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Problem: Vim9: error for comparing with null can be annoying.
Solution: Allow comparing anything with null. (closes https://github.com/vim/vim/issues/9948)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 15 Mar 2022 21:30:03 +0100 |
parents | 5c4ab8d4472c |
children | dbec60b8c253 |
rev | line source |
---|---|
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
1 vim9script |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
2 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
3 # Utility functions for testing vim9 script |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
5 # Use a different file name for each run. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
6 var sequence = 1 |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
7 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
8 # Check that "lines" inside a ":def" function has no error when called. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
9 export func CheckDefSuccess(lines) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
10 let cwd = getcwd() |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
11 let fname = 'XdefSuccess' .. s:sequence |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
12 let s:sequence += 1 |
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
13 call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
14 try |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
15 exe 'so ' .. fname |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
16 call Func() |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
17 finally |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
18 call chdir(cwd) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
19 call delete(fname) |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
20 delfunc! Func |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
21 endtry |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
22 endfunc |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
23 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
24 # Check that "lines" inside a ":def" function has no error when compiled. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
25 export func CheckDefCompileSuccess(lines) |
26686
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
26 let fname = 'XdefSuccess' .. s:sequence |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
27 let s:sequence += 1 |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
28 call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname) |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
29 try |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
30 exe 'so ' .. fname |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
31 finally |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
32 call delete(fname) |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
33 delfunc! Func |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
34 endtry |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
35 endfunc |
c04b28fad0cc
patch 8.2.3872: Vim9: finddir() and uniq() return types can be more specific
Bram Moolenaar <Bram@vim.org>
parents:
26654
diff
changeset
|
36 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
37 # Check that "lines" inside ":def" results in an "error" message. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
38 # If "lnum" is given check that the error is reported for this line. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
39 # Add a line before and after to make it less likely that the line number is |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
40 # accidentally correct. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
41 export func CheckDefFailure(lines, error, lnum = -3) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
42 let cwd = getcwd() |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
43 let fname = 'XdefFailure' .. s:sequence |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
44 let s:sequence += 1 |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
45 call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], fname) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
46 try |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
47 call assert_fails('so ' .. fname, a:error, a:lines, a:lnum + 1) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
48 finally |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
49 call chdir(cwd) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
50 call delete(fname) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
51 delfunc! Func |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
52 endtry |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 endfunc |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
55 # Check that "lines" inside ":def" results in an "error" message when executed. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
56 # If "lnum" is given check that the error is reported for this line. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
57 # Add a line before and after to make it less likely that the line number is |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
58 # accidentally correct. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
59 export func CheckDefExecFailure(lines, error, lnum = -3) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
60 let cwd = getcwd() |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
61 let fname = 'XdefExecFailure' .. s:sequence |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
62 let s:sequence += 1 |
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
63 call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], fname) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
64 try |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
65 exe 'so ' .. fname |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
66 call assert_fails('call Func()', a:error, a:lines, a:lnum + 1) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
67 finally |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
68 call chdir(cwd) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
69 call delete(fname) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
70 delfunc! Func |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
71 endtry |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
72 endfunc |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
73 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
74 export def CheckScriptFailure(lines: list<string>, error: string, lnum = -3) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
75 var cwd = getcwd() |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
76 var fname = 'XScriptFailure' .. sequence |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
77 sequence += 1 |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
78 writefile(lines, fname) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
79 try |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
80 assert_fails('so ' .. fname, error, lines, lnum) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
81 finally |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
82 chdir(cwd) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
83 delete(fname) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
84 endtry |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 enddef |
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
87 export def CheckScriptFailureList(lines: list<string>, errors: list<string>, lnum = -3) |
23679
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
88 var cwd = getcwd() |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
89 var fname = 'XScriptFailure' .. sequence |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
90 sequence += 1 |
23679
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
91 writefile(lines, fname) |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
92 try |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
93 assert_fails('so ' .. fname, errors, lines, lnum) |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
94 finally |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
95 chdir(cwd) |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
96 delete(fname) |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
97 endtry |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
98 enddef |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
99 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
100 export def CheckScriptSuccess(lines: list<string>) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
101 var cwd = getcwd() |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
102 var fname = 'XScriptSuccess' .. sequence |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
103 sequence += 1 |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
104 writefile(lines, fname) |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
105 try |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
106 exe 'so ' .. fname |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
107 finally |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
108 chdir(cwd) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
109 delete(fname) |
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
110 endtry |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 enddef |
21909
a211bca98bc3
patch 8.2.1504: Vim9: white space checks are only done for a :def function
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
112 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
113 export def CheckDefAndScriptSuccess(lines: list<string>) |
21937
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
114 CheckDefSuccess(lines) |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
115 CheckScriptSuccess(['vim9script'] + lines) |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
116 enddef |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
117 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
118 # Check that a command fails when used in a :def function and when used in |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
119 # Vim9 script. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
120 # When "error" is a string, both with the same error. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
121 # When "error" is a list, the :def function fails with "error[0]" , the script |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
122 # fails with "error[1]". |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
123 export def CheckDefAndScriptFailure(lines: list<string>, error: any, lnum = -3) |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
124 var errorDef: string |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
125 var errorScript: string |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
126 if type(error) == v:t_string |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
127 errorDef = error |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
128 errorScript = error |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
129 elseif type(error) == v:t_list && len(error) == 2 |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
130 errorDef = error[0] |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
131 errorScript = error[1] |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
132 else |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
133 echoerr 'error argument must be a string or a list with two items' |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
134 return |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
135 endif |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
23679
diff
changeset
|
136 CheckDefFailure(lines, errorDef, lnum) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
23679
diff
changeset
|
137 CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
23679
diff
changeset
|
138 enddef |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
23679
diff
changeset
|
139 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
140 # Check that a command fails when executed in a :def function and when used in |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
141 # Vim9 script. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
142 # When "error" is a string, both with the same error. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
143 # When "error" is a list, the :def function fails with "error[0]" , the script |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
144 # fails with "error[1]". |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
145 export def CheckDefExecAndScriptFailure(lines: list<string>, error: any, lnum = -3) |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
146 var errorDef: string |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
147 var errorScript: string |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
148 if type(error) == v:t_string |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
149 errorDef = error |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
150 errorScript = error |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
151 elseif type(error) == v:t_list && len(error) == 2 |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
152 errorDef = error[0] |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
153 errorScript = error[1] |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
154 else |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
155 echoerr 'error argument must be a string or a list with two items' |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
156 return |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
157 endif |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
23679
diff
changeset
|
158 CheckDefExecFailure(lines, errorDef, lnum) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
23679
diff
changeset
|
159 CheckScriptFailure(['vim9script'] + lines, errorScript, lnum + 1) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
23679
diff
changeset
|
160 enddef |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
161 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
162 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
163 # Check that "lines" inside a legacy function has no error. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
164 export func CheckLegacySuccess(lines) |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
165 let cwd = getcwd() |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
166 let fname = 'XlegacySuccess' .. s:sequence |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
167 let s:sequence += 1 |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
168 call writefile(['func Func()'] + a:lines + ['endfunc'], fname) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
169 try |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
170 exe 'so ' .. fname |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
171 call Func() |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
172 finally |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
173 delfunc! Func |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
174 call chdir(cwd) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
175 call delete(fname) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
176 endtry |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
177 endfunc |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
178 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
179 # Check that "lines" inside a legacy function results in the expected error |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
180 export func CheckLegacyFailure(lines, error) |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
181 let cwd = getcwd() |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
182 let fname = 'XlegacyFails' .. s:sequence |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
183 let s:sequence += 1 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
184 call writefile(['func Func()'] + a:lines + ['endfunc', 'call Func()'], fname) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
185 try |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
186 call assert_fails('so ' .. fname, a:error) |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
187 finally |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
188 delfunc! Func |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
189 call chdir(cwd) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
190 call delete(fname) |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
191 endtry |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
192 endfunc |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
193 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
194 # Execute "lines" in a legacy function, translated as in |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
195 # CheckLegacyAndVim9Success() |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
196 export def CheckTransLegacySuccess(lines: list<string>) |
25593
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
197 var legacylines = lines->mapnew((_, v) => |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
198 v->substitute('\<VAR\>', 'let', 'g') |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
199 ->substitute('\<LET\>', 'let', 'g') |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
200 ->substitute('\<LSTART\>', '{', 'g') |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
201 ->substitute('\<LMIDDLE\>', '->', 'g') |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
202 ->substitute('\<LEND\>', '}', 'g') |
26654
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
203 ->substitute('\<TRUE\>', '1', 'g') |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
204 ->substitute('\<FALSE\>', '0', 'g') |
25593
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
205 ->substitute('#"', ' "', 'g')) |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
206 CheckLegacySuccess(legacylines) |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
207 enddef |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
208 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
209 export def Vim9Trans(lines: list<string>): list<string> |
26654
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
210 return lines->mapnew((_, v) => |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
211 v->substitute('\<VAR\>', 'var', 'g') |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
212 ->substitute('\<LET ', '', 'g') |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
213 ->substitute('\<LSTART\>', '(', 'g') |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
214 ->substitute('\<LMIDDLE\>', ') =>', 'g') |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
215 ->substitute(' *\<LEND\> *', '', 'g') |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
216 ->substitute('\<TRUE\>', 'true', 'g') |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
217 ->substitute('\<FALSE\>', 'false', 'g')) |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
218 enddef |
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
219 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
220 # Execute "lines" in a :def function, translated as in |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
221 # CheckLegacyAndVim9Success() |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
222 export def CheckTransDefSuccess(lines: list<string>) |
26654
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
223 CheckDefSuccess(Vim9Trans(lines)) |
25593
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
224 enddef |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
225 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
226 # Execute "lines" in a Vim9 script, translated as in |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
227 # CheckLegacyAndVim9Success() |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
228 export def CheckTransVim9Success(lines: list<string>) |
26654
e01607ab0fab
patch 8.2.3856: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
229 CheckScriptSuccess(['vim9script'] + Vim9Trans(lines)) |
25593
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
230 enddef |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
231 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
232 # Execute "lines" in a legacy function, :def function and Vim9 script. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
233 # Use 'VAR' for a declaration. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
234 # Use 'LET' for an assignment |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
235 # Use ' #"' for a comment |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
236 # Use LSTART arg LMIDDLE expr LEND for lambda |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
237 # Use 'TRUE' for 1 in legacy, true in Vim9 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
238 # Use 'FALSE' for 0 in legacy, false in Vim9 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
239 export def CheckLegacyAndVim9Success(lines: list<string>) |
25593
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
240 CheckTransLegacySuccess(lines) |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
241 CheckTransDefSuccess(lines) |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25016
diff
changeset
|
242 CheckTransVim9Success(lines) |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
243 enddef |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
244 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
245 # Execute "lines" in a legacy function, :def function and Vim9 script. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
246 # Use 'VAR' for a declaration. |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
247 # Use 'LET' for an assignment |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
248 # Use ' #"' for a comment |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26686
diff
changeset
|
249 export def CheckLegacyAndVim9Failure(lines: list<string>, error: any) |
24450
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
250 var legacyError: string |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
251 var defError: string |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
252 var scriptError: string |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
253 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
254 if type(error) == type('string') |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
255 legacyError = error |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
256 defError = error |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
257 scriptError = error |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
258 else |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
259 legacyError = error[0] |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
260 defError = error[1] |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
261 scriptError = error[2] |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
262 endif |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
263 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
264 var legacylines = lines->mapnew((_, v) => |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
265 v->substitute('\<VAR\>', 'let', 'g') |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
266 ->substitute('\<LET\>', 'let', 'g') |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
267 ->substitute('#"', ' "', 'g')) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
268 CheckLegacyFailure(legacylines, legacyError) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
269 |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
270 var vim9lines = lines->mapnew((_, v) => |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
271 v->substitute('\<VAR\>', 'var', 'g') |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
272 ->substitute('\<LET ', '', 'g')) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
273 CheckDefExecFailure(vim9lines, defError) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
274 CheckScriptFailure(['vim9script'] + vim9lines, scriptError) |
3e1886f1e875
patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
275 enddef |