annotate src/testdir/vim9.vim @ 26650:a07323eb647f v8.2.3854

patch 8.2.3854: Vim9: inconsistent arguments for test functions Commit: https://github.com/vim/vim/commit/86b3ab4fa0de3e8884ab6a6ced2a70592b937d0f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 19 18:33:23 2021 +0000 patch 8.2.3854: Vim9: inconsistent arguments for test functions Problem: Vim9: inconsistent arguments for test functions. Solution: When :def function and script have different arguments use a list with two items instead of a separate function.
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Dec 2021 19:45:03 +0100
parents f8bcd21e6e24
children e01607ab0fab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
c713358da074 patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents: 22500
diff changeset
6 " Check that "lines" inside a ":def" function has no error.
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
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 " 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
23 " 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
24 " 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
25 " 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
26 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
27 let cwd = getcwd()
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
28 let fname = 'XdefFailure' .. s:sequence
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
29 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
30 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
31 try
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
32 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
33 finally
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
34 call chdir(cwd)
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
35 call delete(fname)
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
36 delfunc! Func
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
37 endtry
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 endfunc
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39
20287
ce1b73835822 patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
40 " 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
41 " 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
42 " 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
43 " 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
44 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
45 let cwd = getcwd()
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
46 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
47 let s:sequence += 1
c713358da074 patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents: 22500
diff changeset
48 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
49 try
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
50 exe 'so ' .. fname
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
51 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
52 finally
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
53 call chdir(cwd)
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
54 call delete(fname)
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
55 delfunc! Func
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
56 endtry
20287
ce1b73835822 patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
57 endfunc
ce1b73835822 patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
58
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
59 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
60 var cwd = getcwd()
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
61 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
62 s:sequence += 1
c713358da074 patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents: 22500
diff changeset
63 writefile(lines, 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 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
66 finally
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
67 chdir(cwd)
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
68 delete(fname)
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
69 endtry
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 enddef
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71
23679
e8c379b20765 patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents: 23247
diff changeset
72 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
73 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
74 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
75 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
76 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
77 try
e8c379b20765 patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents: 23247
diff changeset
78 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
79 finally
e8c379b20765 patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents: 23247
diff changeset
80 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
81 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
82 endtry
e8c379b20765 patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents: 23247
diff changeset
83 enddef
e8c379b20765 patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents: 23247
diff changeset
84
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 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
86 var cwd = getcwd()
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
87 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
88 s:sequence += 1
c713358da074 patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents: 22500
diff changeset
89 writefile(lines, fname)
23247
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
90 try
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
91 exe 'so ' .. fname
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
92 finally
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
93 chdir(cwd)
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
94 delete(fname)
f2d05fb28e54 patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents: 23092
diff changeset
95 endtry
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 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
97
21937
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
98 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
99 CheckDefSuccess(lines)
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
100 CheckScriptSuccess(['vim9script'] + lines)
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
101 enddef
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
102
26650
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
103 " 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
104 " Vim9 script.
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
105 " 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
106 " 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
107 " fails with "error[1]".
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
108 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
109 var errorDef: string
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
110 var errorScript: string
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
111 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
112 errorDef = error
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
113 errorScript = error
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
114 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
115 errorDef = error[0]
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
116 errorScript = error[1]
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
117 else
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
118 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
119 return
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
120 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
121 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
122 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
123 enddef
236e9ebdb30e patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents: 23679
diff changeset
124
26650
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
125 " 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
126 " Vim9 script.
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
127 " 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
128 " 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
129 " fails with "error[1]".
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
130 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
131 var errorDef: string
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
132 var errorScript: string
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
133 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
134 errorDef = error
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
135 errorScript = error
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
136 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
137 errorDef = error[0]
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
138 errorScript = error[1]
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
139 else
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
140 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
141 return
a07323eb647f patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents: 25609
diff changeset
142 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
143 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
144 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
145 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
146
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24339
diff changeset
147
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24339
diff changeset
148 " 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
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 call Func()
24450
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
157 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
158 delfunc! Func
24450
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
159 call chdir(cwd)
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
160 call delete(fname)
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
161 endtry
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
162 endfunc
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
163
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
164 " 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
165 func CheckLegacyFailure(lines, error)
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
166 let cwd = getcwd()
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
167 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
168 let s:sequence += 1
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
169 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
170 try
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
171 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
172 finally
24450
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
173 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
174 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
175 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
176 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
177 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
178
25593
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
179 " 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
180 " CheckLegacyAndVim9Success()
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
181 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
182 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
183 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
184 ->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
185 ->substitute('\<LSTART\>', '{', 'g')
0fdacd8f0cf3 patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25593
diff changeset
186 ->substitute('\<LMIDDLE\>', '->', 'g')
0fdacd8f0cf3 patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25593
diff changeset
187 ->substitute('\<LEND\>', '}', 'g')
25593
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
188 ->substitute('#"', ' "', 'g'))
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
189 CheckLegacySuccess(legacylines)
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
190 enddef
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
191
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 :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
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 CheckTransDefSuccess(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 vim9lines = 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\>', 'var', 'g')
25597
0fdacd8f0cf3 patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25593
diff changeset
197 ->substitute('\<LET ', '', 'g')
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'))
25593
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
201 CheckDefSuccess(vim9lines)
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
202 enddef
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
203
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
204 " 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
205 " CheckLegacyAndVim9Success()
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
206 def CheckTransVim9Success(lines: list<string>)
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
207 var vim9lines = lines->mapnew((_, v) =>
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
208 v->substitute('\<VAR\>', 'var', 'g')
25597
0fdacd8f0cf3 patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25593
diff changeset
209 ->substitute('\<LET ', '', 'g')
0fdacd8f0cf3 patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25593
diff changeset
210 ->substitute('\<LSTART\>', '(', 'g')
0fdacd8f0cf3 patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25593
diff changeset
211 ->substitute('\<LMIDDLE\>', ') =>', 'g')
0fdacd8f0cf3 patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25593
diff changeset
212 ->substitute(' *\<LEND\> *', '', 'g'))
25593
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
213 CheckScriptSuccess(['vim9script'] + vim9lines)
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
214 enddef
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
215
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
216 " 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
217 " 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
218 " 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
219 " 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
220 " Use LSTART arg LMIDDLE expr LEND for lambda
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
221 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
222 CheckTransLegacySuccess(lines)
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
223 CheckTransDefSuccess(lines)
c6277019b8c1 patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents: 25016
diff changeset
224 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
225 enddef
24450
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
226
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
227 " 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
228 " 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
229 " 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
230 " Use ' #"' for a comment
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
231 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
232 var legacyError: string
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
233 var defError: string
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
234 var scriptError: string
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
235
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
236 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
237 legacyError = error
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
238 defError = error
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
239 scriptError = error
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
240 else
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
241 legacyError = error[0]
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
242 defError = error[1]
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
243 scriptError = error[2]
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
244 endif
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
245
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
246 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
247 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
248 ->substitute('\<LET\>', 'let', 'g')
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
249 ->substitute('#"', ' "', 'g'))
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
250 CheckLegacyFailure(legacylines, legacyError)
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 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
253 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
254 ->substitute('\<LET ', '', 'g'))
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
255 CheckDefExecFailure(vim9lines, defError)
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
256 CheckScriptFailure(['vim9script'] + vim9lines, scriptError)
3e1886f1e875 patch 8.2.2765: Vim9: not all blob operations work
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
257 enddef