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