Mercurial > vim
annotate src/testdir/test_vim9_import.vim @ 27362:2ca6dd1f62af v8.2.4209
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Commit: https://github.com/vim/vim/commit/3e93a2b075e99a2b3ced85227a6373be233712ff
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 24 21:28:01 2022 +0000
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Problem: partial in 'opfunc' cannot use an imported function.
Solution: Also expand the function name in a partial. (closes https://github.com/vim/vim/issues/9614)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 24 Jan 2022 22:30:04 +0100 |
parents | 9a9c34c84cd4 |
children | 1a6421c5be20 |
rev | line source |
---|---|
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test import/export of the Vim9 script language. |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2 " Also the autoload mechanism. |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 source check.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 source term_util.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 source vim9.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 let s:export_script_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 var name: string = 'bob' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 def Concat(arg: string): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 return name .. arg |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 g:result = Concat('bie') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 g:localname = name |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 export const CONST = 1234 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 export var exported = 9876 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 export var exp_name = 'John' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 export def Exported(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 return 'Exported' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 export def ExportedValue(): number |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 return exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 export def ExportedInc() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 exported += 5 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 export final theList = [1] |
27146
648a5f658990
patch 8.2.4102: Vim9: import cannot be used after method
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
30 export def AddSome(s: string): string |
648a5f658990
patch 8.2.4102: Vim9: import cannot be used after method
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
31 return s .. 'some' |
648a5f658990
patch 8.2.4102: Vim9: import cannot be used after method
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
32 enddef |
648a5f658990
patch 8.2.4102: Vim9: import cannot be used after method
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
33 export var AddRef = AddSome |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 def Undo_export_script_lines() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 unlet g:result |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 unlet g:localname |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 def Test_vim9_import_export() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 writefile(s:export_script_lines, 'Xexport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 var import_script_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 var dir = './' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 var ext = ".vim" |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 import dir .. 'Xexport' .. ext as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 g:exported1 = expo.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 expo.exported += 3 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 g:exported2 = expo.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 g:exported3 = expo.ExportedValue() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 expo.ExportedInc() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 g:exported_i1 = expo.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 g:exported_i2 = expo.ExportedValue() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 expo.exported = 11 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 g:exported_s1 = expo.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 g:exported_s2 = expo.ExportedValue() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 g:imported_func = expo.Exported() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 def GetExported(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 var local_dict = {ref: expo.Exported} |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 return local_dict.ref() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 g:funcref_result = GetExported() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
27265
8a097fc07aa4
patch 8.2.4161: Vim9: warning for missing white space after imported variable
Bram Moolenaar <Bram@vim.org>
parents:
27233
diff
changeset
|
70 def GetName(): string |
8a097fc07aa4
patch 8.2.4161: Vim9: warning for missing white space after imported variable
Bram Moolenaar <Bram@vim.org>
parents:
27233
diff
changeset
|
71 return expo.exp_name .. 'son' |
8a097fc07aa4
patch 8.2.4161: Vim9: warning for missing white space after imported variable
Bram Moolenaar <Bram@vim.org>
parents:
27233
diff
changeset
|
72 enddef |
8a097fc07aa4
patch 8.2.4161: Vim9: warning for missing white space after imported variable
Bram Moolenaar <Bram@vim.org>
parents:
27233
diff
changeset
|
73 g:long_name = GetName() |
8a097fc07aa4
patch 8.2.4161: Vim9: warning for missing white space after imported variable
Bram Moolenaar <Bram@vim.org>
parents:
27233
diff
changeset
|
74 |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 g:imported_name = expo.exp_name |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 expo.exp_name ..= ' Doe' |
27177
eb0a1108f885
patch 8.2.4117: Vim9: wrong white space error after using imported item
Bram Moolenaar <Bram@vim.org>
parents:
27150
diff
changeset
|
77 expo.exp_name = expo.exp_name .. ' Maar' |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 g:imported_name_appended = expo.exp_name |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 g:exported_later = expo.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 expo.theList->add(2) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 assert_equal([1, 2], expo.theList) |
27146
648a5f658990
patch 8.2.4102: Vim9: import cannot be used after method
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
83 |
648a5f658990
patch 8.2.4102: Vim9: import cannot be used after method
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
84 assert_equal('andthensome', 'andthen'->expo.AddSome()) |
648a5f658990
patch 8.2.4102: Vim9: import cannot be used after method
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
85 assert_equal('awesome', 'awe'->expo.AddRef()) |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 writefile(import_script_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 source Ximport.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 assert_equal('bobbie', g:result) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 assert_equal('bob', g:localname) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 assert_equal(9876, g:exported1) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 assert_equal(9879, g:exported2) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 assert_equal(9879, g:exported3) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 assert_equal(9884, g:exported_i1) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 assert_equal(9884, g:exported_i2) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 assert_equal(11, g:exported_s1) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 assert_equal(11, g:exported_s2) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 assert_equal(11, g:exported_later) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 assert_equal('Exported', g:imported_func) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 assert_equal('Exported', g:funcref_result) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 assert_equal('John', g:imported_name) |
27265
8a097fc07aa4
patch 8.2.4161: Vim9: warning for missing white space after imported variable
Bram Moolenaar <Bram@vim.org>
parents:
27233
diff
changeset
|
106 assert_equal('Johnson', g:long_name) |
27177
eb0a1108f885
patch 8.2.4117: Vim9: wrong white space error after using imported item
Bram Moolenaar <Bram@vim.org>
parents:
27150
diff
changeset
|
107 assert_equal('John Doe Maar', g:imported_name_appended) |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 assert_false(exists('g:name')) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 Undo_export_script_lines() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 unlet g:exported1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 unlet g:exported2 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 unlet g:exported3 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 unlet g:exported_i1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 unlet g:exported_i2 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 unlet g:exported_later |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 unlet g:imported_func |
27265
8a097fc07aa4
patch 8.2.4161: Vim9: warning for missing white space after imported variable
Bram Moolenaar <Bram@vim.org>
parents:
27233
diff
changeset
|
118 unlet g:imported_name g:long_name g:imported_name_appended |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 delete('Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 # similar, with line breaks |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 var import_line_break_script_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 import './Xexport.vim' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 g:exported = expo.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 expo.exported += 7 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 g:exported_added = expo.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 g:imported_func = expo.Exported() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 writefile(import_line_break_script_lines, 'Ximport_lbr.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 source Ximport_lbr.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 assert_equal(11, g:exported) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 assert_equal(18, g:exported_added) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 assert_equal('Exported', g:imported_func) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 # exported script not sourced again |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 assert_false(exists('g:result')) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 unlet g:exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 unlet g:exported_added |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 unlet g:imported_func |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 delete('Ximport_lbr.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 var line_break_before_dot =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 import './Xexport.vim' as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 g:exported = expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 .exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 writefile(line_break_before_dot, 'Ximport_lbr_before_dot.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 assert_fails('source Ximport_lbr_before_dot.vim', 'E1060:', '', 3) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 delete('Ximport_lbr_before_dot.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 var line_break_after_dot =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 import './Xexport.vim' as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 g:exported = expo. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 writefile(line_break_after_dot, 'Ximport_lbr_after_dot.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 assert_fails('source Ximport_lbr_after_dot.vim', 'E1074:', '', 3) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 delete('Ximport_lbr_after_dot.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 var import_star_as_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 import './Xexport.vim' as Export |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 def UseExport() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 g:exported_def = Export.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 g:exported_script = Export.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 assert_equal(1, exists('Export.exported')) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 assert_equal(0, exists('Export.notexported')) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 UseExport() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 writefile(import_star_as_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 source Ximport.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 assert_equal(18, g:exported_def) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 assert_equal(18, g:exported_script) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 unlet g:exported_def |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 unlet g:exported_script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 var import_star_as_lines_no_dot =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 import './Xexport.vim' as Export |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 def Func() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 var dummy = 1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 var imported = Export + dummy |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 defcompile |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 writefile(import_star_as_lines_no_dot, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 assert_fails('source Ximport.vim', 'E1060:', '', 2, 'Func') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 var import_star_as_lines_dot_space =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 import './Xexport.vim' as Export |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 def Func() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 var imported = Export . exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 defcompile |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 writefile(import_star_as_lines_dot_space, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 assert_fails('source Ximport.vim', 'E1074:', '', 1, 'Func') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
207 writefile(s:export_script_lines, 'Xexport2.vim') |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
208 var import_as_duplicated =<< trim END |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 import './Xexport.vim' as expo |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
211 import './Xexport2.vim' as expo |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 END |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
213 writefile(import_as_duplicated, 'Ximport.vim') |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 assert_fails('source Ximport.vim', 'E1073:', '', 3, 'Ximport.vim') |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
215 delete('Xexport2.vim') |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 var import_star_as_lines_script_no_dot =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 import './Xexport.vim' as Export |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 g:imported_script = Export exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 writefile(import_star_as_lines_script_no_dot, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 assert_fails('source Ximport.vim', 'E1060: Expected dot after name: Export exported') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 var import_star_as_lines_script_space_after_dot =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 import './Xexport.vim' as Export |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 g:imported_script = Export. exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 writefile(import_star_as_lines_script_space_after_dot, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 assert_fails('source Ximport.vim', 'E1074:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 var import_star_as_lines_missing_name =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 import './Xexport.vim' as Export |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 def Func() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 var imported = Export. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 defcompile |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 writefile(import_star_as_lines_missing_name, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 assert_fails('source Ximport.vim', 'E1048:', '', 1, 'Func') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 var import_star_as_lbr_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 import './Xexport.vim' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 as Export |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 def UseExport() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 g:exported = Export.exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 UseExport() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 writefile(import_star_as_lbr_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 source Ximport.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 assert_equal(18, g:exported) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 unlet g:exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 # try to use something that exists but is not exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 var import_not_exported_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 import './Xexport.vim' as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 echo expo.name |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 writefile(import_not_exported_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 assert_fails('source Ximport.vim', 'E1049:', '', 3, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 # try to import something that is already defined |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 var import_already_defined =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 var exported = 'something' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 import './Xexport.vim' as exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 writefile(import_already_defined, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 assert_fails('source Ximport.vim', 'E1054:', '', 3, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 # try changing an imported const |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 var import_assign_to_const =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 import './Xexport.vim' as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 def Assign() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 expo.CONST = 987 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 defcompile |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 writefile(import_assign_to_const, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 # try changing an imported final |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 var import_assign_to_final =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 import './Xexport.vim' as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 def Assign() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 expo.theList = [2] |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 defcompile |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 writefile(import_assign_to_final, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 var import_no_as_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 import './Xexport.vim' name |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 writefile(import_no_as_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 assert_fails('source Ximport.vim', 'E488:', '', 2, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 var import_invalid_string_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 import Xexport.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 writefile(import_invalid_string_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 assert_fails('source Ximport.vim', 'E121:', '', 2, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 var import_wrong_name_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 import './XnoExport.vim' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 writefile(import_wrong_name_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 assert_fails('source Ximport.vim', 'E1053:', '', 2, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 var import_redefining_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 import './Xexport.vim' as exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 var exported = 5 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 writefile(import_redefining_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 assert_fails('source Ximport.vim', 'E1213: Redefining imported item "exported"', '', 3) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
329 var import_missing_dot_lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
330 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
331 import './Xexport.vim' as expo |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
332 def Test() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
333 expo = 9 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
334 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
335 defcompile |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
336 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
337 writefile(import_missing_dot_lines, 'Ximport.vim') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
338 assert_fails('source Ximport.vim', 'E1258:', '', 1) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
339 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
340 var import_missing_name_lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
341 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
342 import './Xexport.vim' as expo |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
343 def Test() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
344 expo.99 = 9 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
345 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
346 defcompile |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
347 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
348 writefile(import_missing_name_lines, 'Ximport.vim') |
27059
e97cf16731d9
patch 8.2.4058: Vim9: import test failure in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
27057
diff
changeset
|
349 assert_fails('source Ximport.vim', 'E1259:', '', 1) |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
350 |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 var import_assign_wrong_type_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 import './Xexport.vim' as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 expo.exported = 'xxx' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 writefile(import_assign_wrong_type_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 assert_fails('source Ximport.vim', 'E1012: Type mismatch; expected number but got string', '', 3) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 var import_assign_const_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 import './Xexport.vim' as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 expo.CONST = 4321 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 writefile(import_assign_const_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 assert_fails('source Ximport.vim', 'E46: Cannot change read-only variable "CONST"', '', 3) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 delete('Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 delete('Ximport3.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 delete('Xexport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 # Check that in a Vim9 script 'cpo' is set to the Vim default. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 # Flags added or removed are also applied to the restored value. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 set cpo=abcd |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 g:cpo_in_vim9script = &cpo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 set cpo+=f |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 set cpo-=c |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 g:cpo_after_vim9script = &cpo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 writefile(lines, 'Xvim9_script') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 source Xvim9_script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 assert_equal('fabd', &cpo) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 set cpo&vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 assert_equal(&cpo, g:cpo_in_vim9script) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 var newcpo = substitute(&cpo, 'c', '', '') .. 'f' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 assert_equal(newcpo, g:cpo_after_vim9script) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 delete('Xvim9_script') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 def Test_import_funcref() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 export def F(): number |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 return 42 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 export const G = F |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 writefile(lines, 'Xlib.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 import './Xlib.vim' as lib |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 const Foo = lib.G() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 assert_equal(42, Foo) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 def DoTest() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 const Goo = lib.G() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 assert_equal(42, Goo) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 DoTest() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 CheckScriptSuccess(lines) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 delete('Xlib.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 def Test_import_fails() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 writefile([], 'Xfoo.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 import './Xfoo.vim' as foo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 foo = 'bar' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself']) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 import './Xfoo.vim' as foo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 var that = foo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') |
27277
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
432 lines =<< trim END |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
433 vim9script |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
434 import './Xfoo.vim' as foo |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
435 var that: any |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
436 that += foo |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
437 END |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
438 CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
439 lines =<< trim END |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
440 vim9script |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
441 import './Xfoo.vim' as foo |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
442 foo += 9 |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
443 END |
b73e3617c1d6
patch 8.2.4167: Vim9: error message for old style import
Bram Moolenaar <Bram@vim.org>
parents:
27269
diff
changeset
|
444 CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 import './Xfoo.vim' as 9foo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 CheckScriptFailure(lines, 'E1047:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 import './Xfoo.vim' as the#foo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 CheckScriptFailure(lines, 'E1047:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 import './Xfoo.vim' as g:foo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 CheckScriptFailure(lines, 'E1047:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 delete('Xfoo.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 def TheFunc() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 echo 'the func' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 export var Ref = TheFunc |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 writefile([], 'Xthat.vim') |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
472 |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 import './Xthat.vim' as That |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 That() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
478 |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
479 lines =<< trim END |
27233
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
480 vim9script |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
481 import './Xthat.vim' as That |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
482 def Func() |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
483 echo That() |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
484 enddef |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
485 Func() |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
486 END |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
487 CheckScriptFailure(lines, 'E1236: Cannot use That itself') |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
488 |
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
489 lines =<< trim END |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
490 import './Xthat.vim' as one |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
491 import './Xthat.vim' as two |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
492 END |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
493 CheckScriptFailure(lines, 'E1262:') |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
494 |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
495 delete('Xthat.vim') |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 mkdir('Ximport') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 writefile(['vim9script'], 'Ximport/.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 import './Ximport/.vim' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 CheckScriptFailure(lines, 'E1261: Cannot import .vim without using "as"') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 import './Ximport/.vim' as vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 CheckScriptSuccess(lines) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 writefile(['vim9script'], 'Ximport/.vimrc') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 import './Ximport/.vimrc' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 CheckScriptFailure(lines, 'E1257: Imported script must use "as" or end in .vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 import './Ximport/.vimrc' as vimrc |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 CheckScriptSuccess(lines) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 delete('Ximport', 'rf') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 func g:Trigger() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 source Ximport.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 return "echo 'yes'\<CR>" |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 endfunc |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 def Test_import_export_expr_map() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 # check that :import and :export work when buffer is locked |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 var export_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 export def That(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 return 'yes' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 writefile(export_lines, 'Xexport_that.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 var import_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 import './Xexport_that.vim' as that |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 assert_equal('yes', that.That()) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 writefile(import_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 nnoremap <expr> trigger g:Trigger() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 feedkeys('trigger', "xt") |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 delete('Xexport_that.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 delete('Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 nunmap trigger |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 def Test_import_in_filetype() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 # check that :import works when the buffer is locked |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 mkdir('ftplugin', 'p') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 var export_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 export var That = 'yes' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 writefile(export_lines, 'ftplugin/Xexport_ft.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 var import_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 import './Xexport_ft.vim' as ft |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 assert_equal('yes', ft.That) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 g:did_load_mytpe = 1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 writefile(import_lines, 'ftplugin/qf.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 var save_rtp = &rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 &rtp = getcwd() .. ',' .. &rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 filetype plugin on |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 copen |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 assert_equal(1, g:did_load_mytpe) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 quit! |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 delete('Xexport_ft.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 delete('ftplugin', 'rf') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 &rtp = save_rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 def Test_use_import_in_mapping() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 export def Funcx() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 g:result = 42 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 writefile(lines, 'XsomeExport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 import './XsomeExport.vim' as some |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 var Funcy = some.Funcx |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 nnoremap <F3> :call <sid>Funcy()<cr> |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 writefile(lines, 'Xmapscript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
602 source Xmapscript.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 feedkeys("\<F3>", "xt") |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
604 assert_equal(42, g:result) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 unlet g:result |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 delete('XsomeExport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 delete('Xmapscript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 nunmap <F3> |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 |
27285
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
612 def Test_use_import_in_command_completion() |
27189
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
613 var lines =<< trim END |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
614 vim9script |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
615 export def Complete(..._): list<string> |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
616 return ['abcd'] |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
617 enddef |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
618 END |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
619 writefile(lines, 'Xscript.vim') |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
620 |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
621 lines =<< trim END |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
622 vim9script |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
623 import './Xscript.vim' |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
624 |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
625 command -nargs=1 -complete=customlist,Xscript.Complete Cmd echo 'ok' |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
626 feedkeys(":Cmd ab\<Tab>\<C-B>#\<CR>", 'xnt') |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
627 assert_equal('#Cmd abcd', @:) |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
628 END |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
629 CheckScriptSuccess(lines) |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
630 |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
631 delcommand Cmd |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
632 delete('Xscript.vim') |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
633 enddef |
a10936038ec9
patch 8.2.4123: complete function cannot be import.Name
Bram Moolenaar <Bram@vim.org>
parents:
27177
diff
changeset
|
634 |
27285
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
635 def Test_use_autoload_import_in_insert_completion() |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
636 mkdir('Xdir/autoload', 'p') |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
637 var save_rtp = &rtp |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
638 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
639 |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
640 var lines =<< trim END |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
641 vim9script |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
642 export def ThesaurusFunc(findbase: bool, _): any |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
643 if findbase |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
644 return 1 |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
645 endif |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
646 return [ |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
647 'check', |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
648 'experiment', |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
649 'test', |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
650 'verification' |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
651 ] |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
652 enddef |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
653 g:completion_loaded = 'yes' |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
654 END |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
655 writefile(lines, 'Xdir/autoload/completion.vim') |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
656 |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
657 new |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
658 lines =<< trim END |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
659 vim9script |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
660 g:completion_loaded = 'no' |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
661 import autoload 'completion.vim' |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
662 set thesaurusfunc=completion.ThesaurusFunc |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
663 assert_equal('no', g:completion_loaded) |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
664 feedkeys("i\<C-X>\<C-T>\<C-N>\<Esc>", 'xt') |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
665 assert_equal('experiment', getline(1)) |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
666 assert_equal('yes', g:completion_loaded) |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
667 END |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
668 CheckScriptSuccess(lines) |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
669 |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
670 set thesaurusfunc= |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
671 bwipe! |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
672 delete('Xdir', 'rf') |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
673 &rtp = save_rtp |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
674 enddef |
53edd190a607
patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents:
27277
diff
changeset
|
675 |
27362
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
676 def Test_use_autoload_import_partial_in_opfunc() |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
677 mkdir('Xdir/autoload', 'p') |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
678 var save_rtp = &rtp |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
679 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
680 |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
681 var lines =<< trim END |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
682 vim9script |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
683 export def Opfunc(..._) |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
684 g:opfunc_called = 'yes' |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
685 enddef |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
686 END |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
687 writefile(lines, 'Xdir/autoload/opfunc.vim') |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
688 |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
689 new |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
690 lines =<< trim END |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
691 vim9script |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
692 import autoload 'opfunc.vim' |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
693 nnoremap <expr> <F3> TheFunc() |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
694 def TheFunc(): string |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
695 &operatorfunc = function('opfunc.Opfunc', [0]) |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
696 return 'g@' |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
697 enddef |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
698 feedkeys("\<F3>l", 'xt') |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
699 assert_equal('yes', g:opfunc_called) |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
700 END |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
701 CheckScriptSuccess(lines) |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
702 |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
703 set opfunc= |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
704 bwipe! |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
705 delete('Xdir', 'rf') |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
706 &rtp = save_rtp |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
707 enddef |
2ca6dd1f62af
patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Bram Moolenaar <Bram@vim.org>
parents:
27348
diff
changeset
|
708 |
27289
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
709 def Test_use_autoload_import_in_fold_expression() |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
710 mkdir('Xdir/autoload', 'p') |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
711 var save_rtp = &rtp |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
712 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
713 |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
714 var lines =<< trim END |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
715 vim9script |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
716 export def Expr(): string |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
717 return getline(v:lnum) =~ '^#' ? '>1' : '1' |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
718 enddef |
27301
ebe56a24acb6
patch 8.2.4179: 'foldtext' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27297
diff
changeset
|
719 export def Text(): string |
ebe56a24acb6
patch 8.2.4179: 'foldtext' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27297
diff
changeset
|
720 return 'fold text' |
ebe56a24acb6
patch 8.2.4179: 'foldtext' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27297
diff
changeset
|
721 enddef |
27289
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
722 g:fold_loaded = 'yes' |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
723 END |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
724 writefile(lines, 'Xdir/autoload/fold.vim') |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
725 |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
726 lines =<< trim END |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
727 vim9script |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
728 import autoload 'fold.vim' |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
729 &foldexpr = 'fold.Expr()' |
27301
ebe56a24acb6
patch 8.2.4179: 'foldtext' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27297
diff
changeset
|
730 &foldtext = 'fold.Text()' |
27289
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
731 &foldmethod = 'expr' |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
732 &debug = 'throw' |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
733 END |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
734 new |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
735 setline(1, ['# one', 'text', '# two', 'text']) |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
736 g:fold_loaded = 'no' |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
737 CheckScriptSuccess(lines) |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
738 assert_equal('no', g:fold_loaded) |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
739 redraw |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
740 assert_equal('yes', g:fold_loaded) |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
741 |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
742 # Check that script context of 'foldexpr' is copied to another buffer. |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
743 edit! otherfile |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
744 redraw |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
745 |
27301
ebe56a24acb6
patch 8.2.4179: 'foldtext' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents:
27297
diff
changeset
|
746 set foldexpr= foldtext& foldmethod& debug= |
27289
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
747 bwipe! |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
748 delete('Xdir', 'rf') |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
749 &rtp = save_rtp |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
750 enddef |
e11682ba8c80
patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27285
diff
changeset
|
751 |
27305
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
752 func Test_import_in_diffexpr() |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
753 CheckExecutable diff |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
754 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
755 call Run_Test_import_in_diffexpr() |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
756 endfunc |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
757 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
758 def Run_Test_import_in_diffexpr() |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
759 var lines =<< trim END |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
760 vim9script |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
761 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
762 export def DiffExpr() |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
763 # Prepend some text to check diff type detection |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
764 writefile(['warning', ' message'], v:fname_out) |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
765 silent exe '!diff ' .. v:fname_in .. ' ' |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
766 .. v:fname_new .. '>>' .. v:fname_out |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
767 enddef |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
768 END |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
769 writefile(lines, 'Xdiffexpr') |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
770 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
771 lines =<< trim END |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
772 vim9script |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
773 import './Xdiffexpr' as diff |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
774 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
775 set diffexpr=diff.DiffExpr() |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
776 set diffopt=foldcolumn:0 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
777 END |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
778 CheckScriptSuccess(lines) |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
779 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
780 enew! |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
781 call setline(1, ['one', 'two', 'three']) |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
782 diffthis |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
783 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
784 botright vert new |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
785 call setline(1, ['one', 'two', 'three.']) |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
786 diffthis |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
787 # we only check if this does not cause errors |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
788 redraw |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
789 |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
790 diffoff! |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
791 bwipe! |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
792 bwipe! |
27344
44e82999b4e1
patch 8.2.4200: some tests do not clean up properly
Bram Moolenaar <Bram@vim.org>
parents:
27338
diff
changeset
|
793 delete('Xdiffexpr') |
27305
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
794 enddef |
30d8437ad7cc
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27301
diff
changeset
|
795 |
27315
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
796 def Test_import_in_patchexpr() |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
797 var lines =<< trim END |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
798 vim9script |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
799 export def TPatch() |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
800 call writefile(['output file'], v:fname_out) |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
801 enddef |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
802 END |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
803 writefile(lines, 'Xpatchexpr') |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
804 |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
805 lines =<< trim END |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
806 vim9script |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
807 import './Xpatchexpr' as patch |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
808 set patchexpr=patch.TPatch() |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
809 END |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
810 CheckScriptSuccess(lines) |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
811 |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
812 call writefile(['input file'], 'Xinput') |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
813 call writefile(['diff file'], 'Xdiff') |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
814 :%bwipe! |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
815 edit Xinput |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
816 diffpatch Xdiff |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
817 call assert_equal('output file', getline(1)) |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
818 |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
819 call delete('Xinput') |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
820 call delete('Xdiff') |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
821 call delete('Xpatchexpr') |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
822 set patchexpr& |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
823 :%bwipe! |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
824 enddef |
a195a900a329
patch 8.2.4186: cannot use an import in 'patchexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27313
diff
changeset
|
825 |
27309
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
826 def Test_import_in_formatexpr() |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
827 var lines =<< trim END |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
828 vim9script |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
829 export def MyFormatExpr(): number |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
830 g:did_format = 'yes' |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
831 return 0 |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
832 enddef |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
833 END |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
834 writefile(lines, 'Xformatter') |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
835 |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
836 lines =<< trim END |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
837 vim9script |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
838 import './Xformatter' as format |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
839 set formatexpr=format.MyFormatExpr() |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
840 END |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
841 CheckScriptSuccess(lines) |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
842 |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
843 new |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
844 setline(1, ['a', 'b', 'c']) |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
845 normal gqG |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
846 assert_equal('yes', g:did_format) |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
847 |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
848 bwipe! |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
849 delete('Xformatter') |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
850 unlet g:did_format |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
851 set formatexpr= |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
852 enddef |
391011658d95
patch 8.2.4183: cannot use an import in 'formatexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27305
diff
changeset
|
853 |
27311
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
854 def Test_import_in_includeexpr() |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
855 writefile(['found it'], 'Xthisfile') |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
856 new |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
857 |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
858 var lines =<< trim END |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
859 vim9script |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
860 export def DoSub(): string |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
861 return substitute(v:fname, 'that', 'this', '') |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
862 enddef |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
863 END |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
864 writefile(lines, 'Xinclude.vim') |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
865 |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
866 lines =<< trim END |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
867 vim9script |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
868 import './Xinclude.vim' |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
869 set includeexpr=Xinclude.DoSub() |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
870 END |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
871 CheckScriptSuccess(lines) |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
872 |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
873 setline(1, ['Xthatfile']) |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
874 exe "normal \<C-W>f" |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
875 assert_equal('Xthisfile', expand('%')) |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
876 |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
877 bwipe! |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
878 bwipe! |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
879 set includeexpr= |
27344
44e82999b4e1
patch 8.2.4200: some tests do not clean up properly
Bram Moolenaar <Bram@vim.org>
parents:
27338
diff
changeset
|
880 delete('Xinclude.vim') |
27311
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
881 delete('Xthisfile') |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
882 enddef |
b3ef31c6a922
patch 8.2.4184: cannot use an import in 'includeexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27309
diff
changeset
|
883 |
27313
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
884 def Test_import_in_indentexpr() |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
885 var lines =<< trim END |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
886 vim9script |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
887 export def GetIndent(): number |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
888 return 5 |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
889 enddef |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
890 END |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
891 writefile(lines, 'Xindenter') |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
892 |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
893 lines =<< trim END |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
894 vim9script |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
895 import './Xindenter' as indent |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
896 set indentexpr=indent.GetIndent() |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
897 set debug=throw |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
898 END |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
899 CheckScriptSuccess(lines) |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
900 |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
901 new |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
902 setline(1, 'hello') |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
903 normal == |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
904 assert_equal(' hello', getline(1)) |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
905 |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
906 bwipe! |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
907 set indentexpr= debug= |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
908 delete('Xindenter') |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
909 enddef |
748ab01dbdc5
patch 8.2.4185: cannot use an import in 'indentexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27311
diff
changeset
|
910 |
27328
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
911 func Test_import_in_printexpr() |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
912 CheckFeature postscript |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
913 call Run_Test_import_in_printexpr() |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
914 endfunc |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
915 |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
916 def Run_Test_import_in_printexpr() |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
917 var lines =<< trim END |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
918 vim9script |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
919 export def PrintFile(): bool |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
920 g:printed = 'yes' |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
921 delete('v:fname_in') |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
922 return false |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
923 enddef |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
924 END |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
925 writefile(lines, 'Xprint.vim') |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
926 |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
927 lines =<< trim END |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
928 vim9script |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
929 import './Xprint.vim' |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
930 set printexpr=Xprint.PrintFile() |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
931 END |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
932 CheckScriptSuccess(lines) |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
933 |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
934 help |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
935 hardcopy dummy args |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
936 assert_equal('yes', g:printed) |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
937 |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
938 delete('Xprint.vim') |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
939 set printexpr= |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
940 enddef |
7382135dac01
patch 8.2.4192: cannot use an import in 'printexpr'
Bram Moolenaar <Bram@vim.org>
parents:
27315
diff
changeset
|
941 |
27330
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
942 def Test_import_in_charconvert() |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
943 var lines =<< trim END |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
944 vim9script |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
945 export def MakeUpper(): bool |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
946 var data = readfile(v:fname_in) |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
947 map(data, 'toupper(v:val)') |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
948 writefile(data, v:fname_out) |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
949 return false # success |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
950 enddef |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
951 END |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
952 writefile(lines, 'Xconvert.vim') |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
953 |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
954 lines =<< trim END |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
955 vim9script |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
956 import './Xconvert.vim' as conv |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
957 set charconvert=conv.MakeUpper() |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
958 END |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
959 CheckScriptSuccess(lines) |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
960 |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
961 writefile(['one', 'two'], 'Xfile') |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
962 new Xfile |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
963 write ++enc=ucase Xfile1 |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
964 assert_equal(['ONE', 'TWO'], readfile('Xfile1')) |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
965 |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
966 delete('Xfile') |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
967 delete('Xfile1') |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
968 delete('Xconvert.vim') |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
969 bwipe! |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
970 set charconvert& |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
971 enddef |
aeadf4315bef
patch 8.2.4193: cannot use an import in 'charconvert'
Bram Moolenaar <Bram@vim.org>
parents:
27328
diff
changeset
|
972 |
27338
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
973 func Test_import_in_spellsuggest_expr() |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
974 CheckFeature spell |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
975 call Run_Test_import_in_spellsuggest_expr() |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
976 endfunc |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
977 |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
978 def Run_Test_import_in_spellsuggest_expr() |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
979 var lines =<< trim END |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
980 vim9script |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
981 export def MySuggest(): list<any> |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
982 return [['Fox', 8], ['Fop', 9]] |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
983 enddef |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
984 END |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
985 writefile(lines, 'Xsuggest.vim') |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
986 |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
987 lines =<< trim END |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
988 vim9script |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
989 import './Xsuggest.vim' as sugg |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
990 set spell spellsuggest=expr:sugg.MySuggest() |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
991 END |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
992 CheckScriptSuccess(lines) |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
993 |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
994 set verbose=1 # report errors |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
995 call assert_equal(['Fox', 'Fop'], spellsuggest('Fo', 2)) |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
996 |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
997 delete('Xsuggest.vim') |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
998 set nospell spellsuggest& verbose=0 |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
999 enddef |
c62006deb5c1
patch 8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'
Bram Moolenaar <Bram@vim.org>
parents:
27330
diff
changeset
|
1000 |
27348
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1001 def Test_export_shadows_global_function() |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1002 mkdir('Xdir/autoload', 'p') |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1003 var save_rtp = &rtp |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1004 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1005 |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1006 var lines =<< trim END |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1007 vim9script |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1008 export def Shadow(): string |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1009 return 'Shadow()' |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1010 enddef |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1011 END |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1012 writefile(lines, 'Xdir/autoload/shadow.vim') |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1013 |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1014 lines =<< trim END |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1015 vim9script |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1016 |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1017 def g:Shadow(): string |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1018 return 'global' |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1019 enddef |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1020 |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1021 import autoload 'shadow.vim' |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1022 assert_equal('Shadow()', shadow.Shadow()) |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1023 END |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1024 CheckScriptSuccess(lines) |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1025 |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1026 delfunc g:Shadow |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1027 bwipe! |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1028 delete('Xdir', 'rf') |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1029 &rtp = save_rtp |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1030 enddef |
9a9c34c84cd4
patch 8.2.4202: Vim9: cannot export function that exists globally
Bram Moolenaar <Bram@vim.org>
parents:
27344
diff
changeset
|
1031 |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 def Test_export_fails() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 CheckScriptFailure(['export var some = 123'], 'E1042:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 assert_fails('export something', 'E1043:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 func Test_import_fails_without_script() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 CheckRunVimInTerminal |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 " call indirectly to avoid compilation error for missing functions |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 call Run_Test_import_fails_on_command_line() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 endfunc |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 def Run_Test_import_fails_on_command_line() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 var export =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 export def Foo(): number |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 return 0 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 writefile(export, 'XexportCmd.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 var buf = RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', { |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 rows: 6, wait_for_ruler: 0}) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 WaitForAssert(() => assert_match('^E1094:', term_getline(buf, 5))) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 delete('XexportCmd.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 StopVimInTerminal(buf) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 def Test_vim9_reload_noclear() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 export var exported = 'thexport' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 export def TheFunc(x = 0) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 writefile(lines, 'XExportReload') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 vim9script noclear |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 g:loadCount += 1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 var s:reloaded = 'init' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 import './XExportReload' as exp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 def Again(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 return 'again' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 exp.TheFunc() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 if exists('s:loaded') | finish | endif |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 var s:loaded = true |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 var s:notReloaded = 'yes' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 s:reloaded = 'first' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 def g:Values(): list<string> |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 return [s:reloaded, s:notReloaded, Again(), Once(), exp.exported] |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 def Once(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 return 'once' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 writefile(lines, 'XReloaded') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 g:loadCount = 0 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 source XReloaded |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 assert_equal(1, g:loadCount) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 assert_equal(['first', 'yes', 'again', 'once', 'thexport'], g:Values()) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 source XReloaded |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 assert_equal(2, g:loadCount) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 source XReloaded |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 assert_equal(3, g:loadCount) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 delete('XReloaded') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1111 delete('XExportReload') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 delfunc g:Values |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 unlet g:loadCount |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1115 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 def Inner() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 lines->writefile('XreloadScript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 source XreloadScript.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 def Outer() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 def Inner() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 defcompile |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1130 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 lines->writefile('XreloadScript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 source XreloadScript.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 delete('XreloadScript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 def Test_vim9_reload_import() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 const var = '' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 var valone = 1234 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 def MyFunc(arg: string) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 valone = 5678 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 var morelines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 var valtwo = 222 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 export def GetValtwo(): number |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 return valtwo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 writefile(lines + morelines, 'Xreload.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 source Xreload.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 source Xreload.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 source Xreload.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 # cannot declare a var twice |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 var valone = 1234 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 var valone = 5678 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 writefile(lines, 'Xreload.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 assert_fails('source Xreload.vim', 'E1041:', '', 3, 'Xreload.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 delete('Xreload.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 delete('Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1170 " if a script is reloaded with a script-local variable that changed its type, a |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 " compiled function using that variable must fail. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 def Test_script_reload_change_type() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 vim9script noclear |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 var str = 'string' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 def g:GetStr(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 return str .. 'xxx' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 writefile(lines, 'Xreload.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 source Xreload.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 echo g:GetStr() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 vim9script noclear |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 var str = 1234 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 writefile(lines, 'Xreload.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 source Xreload.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 assert_fails('echo g:GetStr()', 'E1150:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 delfunc g:GetStr |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 delete('Xreload.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 " Define CallFunc so that the test can be compiled |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 command CallFunc echo 'nop' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 def Test_script_reload_from_function() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 if exists('g:loaded') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 finish |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 endif |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 g:loaded = 1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 delcommand CallFunc |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 command CallFunc Func() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 def Func() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 so XreloadFunc.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 g:didTheFunc = 1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 writefile(lines, 'XreloadFunc.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 source XreloadFunc.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 CallFunc |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 assert_equal(1, g:didTheFunc) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 delete('XreloadFunc.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 delcommand CallFunc |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 unlet g:loaded |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 unlet g:didTheFunc |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 def s:RetSome(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 return 'some' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 " Not exported function that is referenced needs to be accessed by the |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 " script-local name. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 def Test_vim9_funcref() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 var sortlines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 def Compare(i1: number, i2: number): number |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 return i2 - i1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 export def FastSort(): list<number> |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 return range(5)->sort(Compare) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 export def GetString(arg: string): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 return arg |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 writefile(sortlines, 'Xsort.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 import './Xsort.vim' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 def Test() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 g:result = Xsort.FastSort() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 Test() |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
1255 END |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
1256 writefile(lines, 'Xscript.vim') |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
1257 source Xscript.vim |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
1258 assert_equal([4, 3, 2, 1, 0], g:result) |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
1259 unlet g:result |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 |
27030
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
1261 lines =<< trim END |
c8809b8d19de
patch 8.2.4044: Vim9: no error when importing the same script twice
Bram Moolenaar <Bram@vim.org>
parents:
27014
diff
changeset
|
1262 vim9script |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 # using a function imported with "as" |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 import './Xsort.vim' as anAlias |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 assert_equal('yes', anAlias.GetString('yes')) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 # using the function from a compiled function |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 def TestMore(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 var s = s:anAlias.GetString('foo') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 return s .. anAlias.GetString('bar') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 assert_equal('foobar', TestMore()) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 # error when using a function that isn't exported |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 assert_fails('anAlias.Compare(1, 2)', 'E1049:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 writefile(lines, 'Xscript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 delete('Xsort.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 delete('Xscript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 var Funcref = function('s:RetSome') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 assert_equal('some', Funcref()) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 " Check that when searching for "FilterFunc" it finds the import in the |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 " script where FastFilter() is called from, both as a string and as a direct |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 " function reference. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 def Test_vim9_funcref_other_script() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 var filterLines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 export def FilterFunc(idx: number, val: number): bool |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 return idx % 2 == 1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 export def FastFilter(): list<number> |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 return range(10)->filter('FilterFunc(v:key, v:val)') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 export def FastFilterDirect(): list<number> |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 return range(10)->filter(FilterFunc) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 writefile(filterLines, 'Xfilter.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 import './Xfilter.vim' as filter |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 def Test() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 var x: list<number> = filter.FastFilter() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 Test() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 def TestDirect() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 var x: list<number> = filter.FastFilterDirect() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 TestDirect() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 CheckScriptSuccess(lines) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 delete('Xfilter.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 def Test_import_absolute() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 var import_lines = [ |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 'vim9script', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 'import "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim" as abs', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 'def UseExported()', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 ' g:imported_abs = abs.exported', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 ' abs.exported = 8888', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 ' g:imported_after = abs.exported', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 'enddef', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 'UseExported()', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 'g:import_disassembled = execute("disass UseExported")', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 ] |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 writefile(import_lines, 'Ximport_abs.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 writefile(s:export_script_lines, 'Xexport_abs.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 source Ximport_abs.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 assert_equal(9876, g:imported_abs) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 assert_equal(8888, g:imported_after) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 assert_match('<SNR>\d\+_UseExported\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 'g:imported_abs = abs.exported\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 '0 LOADSCRIPT exported-2 from .*Xexport_abs.vim\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 '1 STOREG g:imported_abs\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 'abs.exported = 8888\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 '2 PUSHNR 8888\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 '3 STORESCRIPT exported-2 in .*Xexport_abs.vim\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 'g:imported_after = abs.exported\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 '4 LOADSCRIPT exported-2 from .*Xexport_abs.vim\_s*' .. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 '5 STOREG g:imported_after', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 g:import_disassembled) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 Undo_export_script_lines() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 unlet g:imported_abs |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 unlet g:import_disassembled |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1355 delete('Ximport_abs.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 delete('Xexport_abs.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 def Test_import_rtp() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 var import_lines = [ |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 'vim9script', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 'import "Xexport_rtp.vim" as rtp', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 'g:imported_rtp = rtp.exported', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 ] |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 writefile(import_lines, 'Ximport_rtp.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 mkdir('import', 'p') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 writefile(s:export_script_lines, 'import/Xexport_rtp.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 var save_rtp = &rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 &rtp = getcwd() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 source Ximport_rtp.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 &rtp = save_rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 assert_equal(9876, g:imported_rtp) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 Undo_export_script_lines() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 unlet g:imported_rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 delete('Ximport_rtp.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 delete('import', 'rf') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 def Test_import_compile_error() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 var export_lines = [ |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 'vim9script', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 'export def ExpFunc(): string', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 ' return notDefined', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 'enddef', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 ] |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 writefile(export_lines, 'Xexported.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 var import_lines = [ |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 'vim9script', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 'import "./Xexported.vim" as expo', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1394 'def ImpFunc()', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 ' echo expo.ExpFunc()', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 'enddef', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 'defcompile', |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 ] |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 writefile(import_lines, 'Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 try |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 source Ximport.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 catch /E1001/ |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 # Error should be before the Xexported.vim file. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 assert_match('E1001: Variable not found: notDefined', v:exception) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 assert_match('function <SNR>\d\+_ImpFunc\[1\]..<SNR>\d\+_ExpFunc, line 1', v:throwpoint) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 endtry |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 delete('Xexported.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 delete('Ximport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 def Test_func_overrules_import_fails() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 var export_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 export def Func() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 echo 'imported' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 writefile(export_lines, 'XexportedFunc.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 import './XexportedFunc.vim' as Func |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 def Func() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 echo 'local to function' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 END |
27233
73232ed49cf2
patch 8.2.4145: confusing error when using name of import for a function
Bram Moolenaar <Bram@vim.org>
parents:
27217
diff
changeset
|
1429 CheckScriptFailure(lines, 'E1213: Redefining imported item "Func"') |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1430 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 import './XexportedFunc.vim' as Func |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 def Outer() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 def Func() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 echo 'local to function' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 defcompile |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 CheckScriptFailure(lines, 'E1236:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 delete('XexportedFunc.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 def Test_source_vim9_from_legacy() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 var vim9_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 var local = 'local' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 g:global = 'global' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 export var exported = 'exported' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 export def GetText(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 return 'text' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 writefile(vim9_lines, 'Xvim9_script.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 var legacy_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 source Xvim9_script.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 call assert_false(exists('local')) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 call assert_false(exists('exported')) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 call assert_false(exists('s:exported')) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 call assert_equal('global', global) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 call assert_equal('global', g:global) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 writefile(legacy_lines, 'Xlegacy_script.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 source Xlegacy_script.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 assert_equal('global', g:global) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 unlet g:global |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 delete('Xlegacy_script.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 delete('Xvim9_script.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 |
27112
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1477 def Test_import_vim9_from_legacy() |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1478 var vim9_lines =<< trim END |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1479 vim9script |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1480 var local = 'local' |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1481 g:global = 'global' |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1482 export var exported = 'exported' |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1483 export def GetText(): string |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1484 return 'text' |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1485 enddef |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1486 END |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1487 writefile(vim9_lines, 'Xvim9_export.vim') |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1488 |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1489 var legacy_lines =<< trim END |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1490 import './Xvim9_export.vim' as vim9 |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1491 |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1492 call assert_false(exists('vim9')) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1493 call assert_false(exists('local')) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1494 call assert_false(exists('s:vim9.local')) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1495 call assert_equal('global', global) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1496 call assert_equal('global', g:global) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1497 call assert_false(exists('exported')) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1498 call assert_false(exists('s:exported')) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1499 call assert_false(exists('*GetText')) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1500 |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1501 " imported symbol is script-local |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1502 call assert_equal('exported', s:vim9.exported) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1503 call assert_equal('text', s:vim9.GetText()) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1504 END |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1505 writefile(legacy_lines, 'Xlegacy_script.vim') |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1506 |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1507 source Xlegacy_script.vim |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1508 assert_equal('global', g:global) |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1509 unlet g:global |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1510 |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1511 delete('Xlegacy_script.vim') |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1512 delete('Xvim9_export.vim') |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1513 enddef |
60df9f2679a6
patch 8.2.4085: Vim9: no test for using import in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
27108
diff
changeset
|
1514 |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 def Test_cmdline_win() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 # if the Vim syntax highlighting uses Vim9 constructs they can be used from |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 # the command line window. |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 mkdir('rtp/syntax', 'p') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 var export_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 export var That = 'yes' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 writefile(export_lines, 'rtp/syntax/Xexport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 var import_lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 import './Xexport.vim' as exp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 echo exp.That |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 writefile(import_lines, 'rtp/syntax/vim.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 var save_rtp = &rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 &rtp = getcwd() .. '/rtp' .. ',' .. &rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 syntax on |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 augroup CmdWin |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 autocmd CmdwinEnter * g:got_there = 'yes' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 augroup END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 # this will open and also close the cmdline window |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 feedkeys('q:', 'xt') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 assert_equal('yes', g:got_there) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 augroup CmdWin |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 au! |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 augroup END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 &rtp = save_rtp |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 delete('rtp', 'rf') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 def Test_import_gone_when_sourced_twice() |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 var exportlines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 if exists('g:guard') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 finish |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 endif |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 g:guard = 1 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 export var name = 'someName' |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 writefile(exportlines, 'XexportScript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 var lines =<< trim END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 vim9script |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 import './XexportScript.vim' as expo |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 def g:GetName(): string |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 return expo.name |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 END |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 writefile(lines, 'XscriptImport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 so XscriptImport.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 assert_equal('someName', g:GetName()) |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 so XexportScript.vim |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 assert_fails('call g:GetName()', 'E1149:') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 delfunc g:GetName |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 delete('XexportScript.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 delete('XscriptImport.vim') |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 unlet g:guard |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 enddef |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1577 |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1578 " test using an auto-loaded function and variable |
27108
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1579 def Test_vim9_autoload_full_name() |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1580 var lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1581 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1582 def some#gettest(): string |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1583 return 'test' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1584 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1585 g:some#name = 'name' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1586 g:some#dict = {key: 'value'} |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1587 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1588 def some#varargs(a1: string, ...l: list<string>): string |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1589 return a1 .. l[0] .. l[1] |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1590 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1591 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1592 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1593 mkdir('Xdir/autoload', 'p') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1594 writefile(lines, 'Xdir/autoload/some.vim') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1595 var save_rtp = &rtp |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1596 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1597 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1598 assert_equal('test', g:some#gettest()) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1599 assert_equal('name', g:some#name) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1600 assert_equal('value', g:some#dict.key) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1601 g:some#other = 'other' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1602 assert_equal('other', g:some#other) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1603 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1604 assert_equal('abc', some#varargs('a', 'b', 'c')) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1605 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1606 # upper case script name works |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1607 lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1608 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1609 def Other#getOther(): string |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1610 return 'other' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1611 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1612 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1613 writefile(lines, 'Xdir/autoload/Other.vim') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1614 assert_equal('other', g:Other#getOther()) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1615 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1616 delete('Xdir', 'rf') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1617 &rtp = save_rtp |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1618 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1619 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1620 def Test_vim9script_autoload() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1621 mkdir('Xdir/autoload', 'p') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1622 var save_rtp = &rtp |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1623 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1624 |
27215
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
1625 # when the path has "/autoload/" prefix is not needed |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1626 var lines =<< trim END |
27215
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
1627 vim9script |
27074
19fefc42a063
patch 8.2.4066: Vim9: imported autoload script loaded again
Bram Moolenaar <Bram@vim.org>
parents:
27068
diff
changeset
|
1628 g:prefixed_loaded += 1 |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1629 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1630 export def Gettest(): string |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1631 return 'test' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1632 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1633 |
27108
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1634 export var name = 'name' |
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1635 |
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1636 export func GetFunc() |
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1637 return Gettest() .. 'more' .. s:name |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1638 endfunc |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1639 |
27108
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1640 export def GetDef(): string |
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1641 return Gettest() .. 'more' .. name |
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1642 enddef |
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1643 |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1644 export final fname = 'final' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1645 export const cname = 'const' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1646 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1647 writefile(lines, 'Xdir/autoload/prefixed.vim') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1648 |
27074
19fefc42a063
patch 8.2.4066: Vim9: imported autoload script loaded again
Bram Moolenaar <Bram@vim.org>
parents:
27068
diff
changeset
|
1649 g:prefixed_loaded = 0 |
19fefc42a063
patch 8.2.4066: Vim9: imported autoload script loaded again
Bram Moolenaar <Bram@vim.org>
parents:
27068
diff
changeset
|
1650 g:expected_loaded = 0 |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1651 lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1652 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1653 import autoload 'prefixed.vim' |
27074
19fefc42a063
patch 8.2.4066: Vim9: imported autoload script loaded again
Bram Moolenaar <Bram@vim.org>
parents:
27068
diff
changeset
|
1654 assert_equal(g:expected_loaded, g:prefixed_loaded) |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1655 assert_equal('test', prefixed.Gettest()) |
27074
19fefc42a063
patch 8.2.4066: Vim9: imported autoload script loaded again
Bram Moolenaar <Bram@vim.org>
parents:
27068
diff
changeset
|
1656 assert_equal(1, g:prefixed_loaded) |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1657 |
27108
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1658 assert_equal('testmorename', prefixed.GetFunc()) |
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1659 assert_equal('testmorename', prefixed.GetDef()) |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1660 assert_equal('name', prefixed.name) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1661 assert_equal('final', prefixed.fname) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1662 assert_equal('const', prefixed.cname) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1663 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1664 CheckScriptSuccess(lines) |
27074
19fefc42a063
patch 8.2.4066: Vim9: imported autoload script loaded again
Bram Moolenaar <Bram@vim.org>
parents:
27068
diff
changeset
|
1665 # can source it again, autoload script not loaded again |
19fefc42a063
patch 8.2.4066: Vim9: imported autoload script loaded again
Bram Moolenaar <Bram@vim.org>
parents:
27068
diff
changeset
|
1666 g:expected_loaded = 1 |
19fefc42a063
patch 8.2.4066: Vim9: imported autoload script loaded again
Bram Moolenaar <Bram@vim.org>
parents:
27068
diff
changeset
|
1667 CheckScriptSuccess(lines) |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1668 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1669 # can also get the items by autoload name |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1670 lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1671 call assert_equal('test', prefixed#Gettest()) |
27108
92e2e96ff559
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Bram Moolenaar <Bram@vim.org>
parents:
27106
diff
changeset
|
1672 call assert_equal('testmorename', prefixed#GetFunc()) |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1673 call assert_equal('name', prefixed#name) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1674 call assert_equal('final', prefixed#fname) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1675 call assert_equal('const', prefixed#cname) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1676 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1677 CheckScriptSuccess(lines) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1678 |
27076
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1679 unlet g:prefixed_loaded |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1680 unlet g:expected_loaded |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1681 delete('Xdir', 'rf') |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1682 &rtp = save_rtp |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1683 enddef |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1684 |
27217
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1685 def Test_import_autoload_not_exported() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1686 mkdir('Xdir/autoload', 'p') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1687 var save_rtp = &rtp |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1688 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1689 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1690 # error when using an item that is not exported from an autoload script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1691 var exportLines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1692 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1693 var notExported = 123 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1694 def NotExport() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1695 echo 'nop' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1696 enddef |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1697 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1698 writefile(exportLines, 'Xdir/autoload/notExport1.vim') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1699 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1700 var lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1701 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1702 import autoload 'notExport1.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1703 echo notExport1.notFound |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1704 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1705 CheckScriptFailure(lines, 'E1048: Item not found in script: notFound') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1706 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1707 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1708 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1709 import autoload 'notExport1.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1710 echo notExport1.notExported |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1711 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1712 CheckScriptFailure(lines, 'E1049: Item not exported in script: notExported') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1713 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1714 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1715 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1716 import autoload 'notExport1.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1717 echo notExport1.NotFunc() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1718 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1719 CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1720 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1721 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1722 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1723 import autoload 'notExport1.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1724 echo notExport1.NotExport() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1725 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1726 CheckScriptFailure(lines, 'E1049: Item not exported in script: NotExport') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1727 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1728 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1729 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1730 import autoload 'notExport1.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1731 echo 'text'->notExport1.NotFunc() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1732 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1733 CheckScriptFailure(lines, 'E1048: Item not found in script: NotFunc') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1734 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1735 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1736 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1737 import autoload 'notExport1.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1738 echo 'text'->notExport1.NotExport() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1739 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1740 CheckScriptFailure(lines, 'E1049: Item not exported in script: NotExport') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1741 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1742 # using a :def function we use a different autoload script every time so that |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1743 # the function is compiled without the script loaded |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1744 writefile(exportLines, 'Xdir/autoload/notExport2.vim') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1745 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1746 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1747 import autoload 'notExport2.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1748 def Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1749 echo notExport2.notFound |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1750 enddef |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1751 Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1752 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1753 CheckScriptFailure(lines, 'E1048: Item not found in script: notExport2#notFound') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1754 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1755 writefile(exportLines, 'Xdir/autoload/notExport3.vim') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1756 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1757 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1758 import autoload 'notExport3.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1759 def Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1760 echo notExport3.notExported |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1761 enddef |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1762 Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1763 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1764 # don't get E1049 because it is too complicated to figure out |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1765 CheckScriptFailure(lines, 'E1048: Item not found in script: notExport3#notExported') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1766 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1767 writefile(exportLines, 'Xdir/autoload/notExport4.vim') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1768 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1769 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1770 import autoload 'notExport4.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1771 def Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1772 echo notExport4.NotFunc() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1773 enddef |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1774 Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1775 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1776 CheckScriptFailure(lines, 'E117: Unknown function: notExport4#NotFunc') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1777 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1778 writefile(exportLines, 'Xdir/autoload/notExport5.vim') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1779 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1780 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1781 import autoload 'notExport5.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1782 def Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1783 echo notExport5.NotExport() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1784 enddef |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1785 Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1786 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1787 CheckScriptFailure(lines, 'E117: Unknown function: notExport5#NotExport') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1788 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1789 writefile(exportLines, 'Xdir/autoload/notExport6.vim') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1790 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1791 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1792 import autoload 'notExport6.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1793 def Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1794 echo 'text'->notExport6.NotFunc() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1795 enddef |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1796 Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1797 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1798 CheckScriptFailure(lines, 'E117: Unknown function: notExport6#NotFunc') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1799 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1800 writefile(exportLines, 'Xdir/autoload/notExport7.vim') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1801 lines =<< trim END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1802 vim9script |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1803 import autoload 'notExport7.vim' |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1804 def Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1805 echo 'text'->notExport7.NotExport() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1806 enddef |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1807 Testit() |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1808 END |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1809 CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1810 |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1811 delete('Xdir', 'rf') |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1812 &rtp = save_rtp |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1813 enddef |
facb54d20a50
patch 8.2.4137: Vim9: calling import with and without method is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27215
diff
changeset
|
1814 |
27076
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1815 def Test_vim9script_autoload_call() |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1816 mkdir('Xdir/autoload', 'p') |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1817 var save_rtp = &rtp |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1818 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1819 |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1820 var lines =<< trim END |
27215
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
1821 vim9script |
27076
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1822 |
27205
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1823 export def RetArg(arg: string): string |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1824 return arg |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1825 enddef |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1826 |
27076
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1827 export def Getother() |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1828 g:result = 'other' |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1829 enddef |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1830 END |
27080
9897dd3c6530
patch 8.2.4069: Vim9: import test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
27076
diff
changeset
|
1831 writefile(lines, 'Xdir/autoload/another.vim') |
27076
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1832 |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1833 lines =<< trim END |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1834 vim9script |
27080
9897dd3c6530
patch 8.2.4069: Vim9: import test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
27076
diff
changeset
|
1835 import autoload 'another.vim' |
27205
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1836 |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1837 # compile this before 'another.vim' is loaded |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1838 def CallAnother() |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1839 assert_equal('foo', 'foo'->another.RetArg()) |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1840 enddef |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1841 CallAnother() |
6c177a9b436e
patch 8.2.4131: Vim9: calling function in autoload import does not work
Bram Moolenaar <Bram@vim.org>
parents:
27189
diff
changeset
|
1842 |
27080
9897dd3c6530
patch 8.2.4069: Vim9: import test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
27076
diff
changeset
|
1843 call another.Getother() |
27076
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1844 assert_equal('other', g:result) |
27295
69aa20a6e7ae
patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents:
27291
diff
changeset
|
1845 |
69aa20a6e7ae
patch 8.2.4176: Vim9: cannot use imported function with call()
Bram Moolenaar <Bram@vim.org>
parents:
27291
diff
changeset
|
1846 assert_equal('arg', call('another.RetArg', ['arg'])) |
27076
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1847 END |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1848 CheckScriptSuccess(lines) |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1849 |
ceff6a546748
patch 8.2.4067: Vim9: cannot call imported function with :call
Bram Moolenaar <Bram@vim.org>
parents:
27074
diff
changeset
|
1850 unlet g:result |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1851 delete('Xdir', 'rf') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1852 &rtp = save_rtp |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1853 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
1854 |
27297
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1855 def Test_vim9script_noclear_autoload() |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1856 mkdir('Xdir/autoload', 'p') |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1857 var save_rtp = &rtp |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1858 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1859 |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1860 var lines =<< trim END |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1861 vim9script |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1862 export def Func(): string |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1863 return 'called' |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1864 enddef |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1865 g:double_loaded = 'yes' |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1866 END |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1867 writefile(lines, 'Xdir/autoload/double.vim') |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1868 |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1869 lines =<< trim END |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1870 vim9script noclear |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1871 if exists('g:script_loaded') |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1872 finish |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1873 endif |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1874 g:script_loaded = true |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1875 |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1876 import autoload 'double.vim' |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1877 nnoremap <F3> <ScriptCmd>g:result = double.Func()<CR> |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1878 END |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1879 g:double_loaded = 'no' |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1880 writefile(lines, 'Xloaddouble') |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1881 source Xloaddouble |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1882 assert_equal('no', g:double_loaded) |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1883 assert_equal(true, g:script_loaded) |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1884 source Xloaddouble |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1885 feedkeys("\<F3>", 'xt') |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1886 assert_equal('called', g:result) |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1887 assert_equal('yes', g:double_loaded) |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1888 |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1889 delete('Xloaddouble') |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1890 unlet g:double_loaded |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1891 unlet g:script_loaded |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1892 unlet g:result |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1893 delete('Xdir', 'rf') |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1894 &rtp = save_rtp |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1895 enddef |
f7cb41ff22a4
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"
Bram Moolenaar <Bram@vim.org>
parents:
27295
diff
changeset
|
1896 |
27267
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1897 def Test_vim9script_autoload_duplicate() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1898 mkdir('Xdir/autoload', 'p') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1899 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1900 var lines =<< trim END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1901 vim9script |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1902 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1903 export def Func() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1904 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1905 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1906 def Func() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1907 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1908 END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1909 writefile(lines, 'Xdir/autoload/dupfunc.vim') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1910 assert_fails('source Xdir/autoload/dupfunc.vim', 'E1073:') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1911 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1912 lines =<< trim END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1913 vim9script |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1914 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1915 def Func() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1916 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1917 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1918 export def Func() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1919 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1920 END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1921 writefile(lines, 'Xdir/autoload/dup2func.vim') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1922 assert_fails('source Xdir/autoload/dup2func.vim', 'E1073:') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1923 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1924 lines =<< trim END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1925 vim9script |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1926 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1927 def Func() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1928 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1929 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1930 export var Func = 'asdf' |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1931 END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1932 writefile(lines, 'Xdir/autoload/dup3func.vim') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1933 assert_fails('source Xdir/autoload/dup3func.vim', 'E1041: Redefining script item Func') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1934 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1935 lines =<< trim END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1936 vim9script |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1937 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1938 export var Func = 'asdf' |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1939 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1940 def Func() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1941 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1942 END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1943 writefile(lines, 'Xdir/autoload/dup4func.vim') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1944 assert_fails('source Xdir/autoload/dup4func.vim', 'E707:') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1945 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1946 lines =<< trim END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1947 vim9script |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1948 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1949 var Func = 'asdf' |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1950 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1951 export def Func() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1952 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1953 END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1954 writefile(lines, 'Xdir/autoload/dup5func.vim') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1955 assert_fails('source Xdir/autoload/dup5func.vim', 'E707:') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1956 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1957 lines =<< trim END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1958 vim9script |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1959 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1960 export def Func() |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1961 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1962 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1963 var Func = 'asdf' |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1964 END |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1965 writefile(lines, 'Xdir/autoload/dup6func.vim') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1966 assert_fails('source Xdir/autoload/dup6func.vim', 'E1041: Redefining script item Func') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1967 |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1968 delete('Xdir', 'rf') |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1969 enddef |
322b79b002b7
patch 8.2.4162: Vim9: no error for redefining function with export
Bram Moolenaar <Bram@vim.org>
parents:
27265
diff
changeset
|
1970 |
27269
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1971 def Test_autoload_missing_function_name() |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1972 mkdir('Xdir/autoload', 'p') |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1973 |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1974 var lines =<< trim END |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1975 vim9script |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1976 |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1977 def loadme#() |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1978 enddef |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1979 END |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1980 writefile(lines, 'Xdir/autoload/loadme.vim') |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1981 assert_fails('source Xdir/autoload/loadme.vim', 'E129:') |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1982 |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1983 delete('Xdir', 'rf') |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1984 enddef |
24da57a079ef
patch 8.2.4163: no error for omitting function name after autoload prefix
Bram Moolenaar <Bram@vim.org>
parents:
27267
diff
changeset
|
1985 |
27291
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1986 def Test_autoload_name_wring() |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1987 var lines =<< trim END |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1988 vim9script |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1989 def Xscriptname#Func() |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1990 enddef |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1991 END |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1992 writefile(lines, 'Xscriptname.vim') |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1993 CheckScriptFailure(lines, 'E1263:') |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1994 |
27344
44e82999b4e1
patch 8.2.4200: some tests do not clean up properly
Bram Moolenaar <Bram@vim.org>
parents:
27338
diff
changeset
|
1995 delete('Xscriptname.vim') |
27291
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1996 enddef |
0f0fa4d12303
patch 8.2.4174: Vim9: can use an autoload name in normal script
Bram Moolenaar <Bram@vim.org>
parents:
27289
diff
changeset
|
1997 |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
1998 def Test_import_autoload_postponed() |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
1999 mkdir('Xdir/autoload', 'p') |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2000 var save_rtp = &rtp |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2001 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2002 |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2003 var lines =<< trim END |
27215
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2004 vim9script |
27086
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2005 |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2006 g:loaded_postponed = 'true' |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2007 export var variable = 'bla' |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2008 export def Function(): string |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2009 return 'bla' |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2010 enddef |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2011 END |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2012 writefile(lines, 'Xdir/autoload/postponed.vim') |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2013 |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2014 lines =<< trim END |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2015 vim9script |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2016 |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2017 import autoload 'postponed.vim' |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2018 def Tryit() |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2019 echo postponed.variable |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2020 echo postponed.Function() |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2021 enddef |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2022 defcompile |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2023 END |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2024 CheckScriptSuccess(lines) |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2025 assert_false(exists('g:loaded_postponed')) |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2026 CheckScriptSuccess(lines + ['Tryit()']) |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2027 assert_equal('true', g:loaded_postponed) |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2028 |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2029 unlet g:loaded_postponed |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2030 delete('Xdir', 'rf') |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2031 &rtp = save_rtp |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2032 enddef |
1e2a6c6c7e42
patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded
Bram Moolenaar <Bram@vim.org>
parents:
27080
diff
changeset
|
2033 |
27116
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2034 def Test_import_autoload_override() |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2035 mkdir('Xdir/autoload', 'p') |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2036 var save_rtp = &rtp |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2037 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2038 test_override('autoload', 1) |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2039 |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2040 var lines =<< trim END |
27215
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2041 vim9script |
27116
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2042 |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2043 g:loaded_override = 'true' |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2044 export var variable = 'bla' |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2045 export def Function(): string |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2046 return 'bla' |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2047 enddef |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2048 END |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2049 writefile(lines, 'Xdir/autoload/override.vim') |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2050 |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2051 lines =<< trim END |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2052 vim9script |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2053 |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2054 import autoload 'override.vim' |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2055 assert_equal('true', g:loaded_override) |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2056 |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2057 def Tryit() |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2058 echo override.doesNotExist |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2059 enddef |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2060 defcompile |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2061 END |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2062 CheckScriptFailure(lines, 'E1048: Item not found in script: doesNotExist', 1) |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2063 |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2064 test_override('autoload', 0) |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2065 unlet g:loaded_override |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2066 delete('Xdir', 'rf') |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2067 &rtp = save_rtp |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2068 enddef |
5b267700e6ab
patch 8.2.4087: cannot test items from an autoload script easily
Bram Moolenaar <Bram@vim.org>
parents:
27112
diff
changeset
|
2069 |
27061
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2070 def Test_autoload_mapping() |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2071 mkdir('Xdir/autoload', 'p') |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2072 var save_rtp = &rtp |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2073 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2074 |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2075 var lines =<< trim END |
27215
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2076 vim9script |
27061
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2077 |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2078 g:toggle_loaded = 'yes' |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2079 |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2080 export def Toggle(): string |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2081 return ":g:toggle_called = 'yes'\<CR>" |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2082 enddef |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2083 export def Doit() |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2084 g:doit_called = 'yes' |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2085 enddef |
27061
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2086 END |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2087 writefile(lines, 'Xdir/autoload/toggle.vim') |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2088 |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2089 lines =<< trim END |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2090 vim9script |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2091 |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2092 import autoload 'toggle.vim' |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2093 |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2094 nnoremap <silent> <expr> tt toggle.Toggle() |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2095 nnoremap <silent> xx <ScriptCmd>toggle.Doit()<CR> |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2096 nnoremap <silent> yy <Cmd>toggle.Doit()<CR> |
27061
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2097 END |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2098 CheckScriptSuccess(lines) |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2099 assert_false(exists("g:toggle_loaded")) |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2100 assert_false(exists("g:toggle_called")) |
27213
42561e956a70
patch 8.2.4135: Vim9: ":scriptnames" shows unloaded imported autoload script
Bram Moolenaar <Bram@vim.org>
parents:
27207
diff
changeset
|
2101 assert_match('\d A: \f*[/\\]toggle.vim', execute('scriptnames')) |
27061
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2102 |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2103 feedkeys("tt", 'xt') |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2104 assert_equal('yes', g:toggle_loaded) |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2105 assert_equal('yes', g:toggle_called) |
27213
42561e956a70
patch 8.2.4135: Vim9: ":scriptnames" shows unloaded imported autoload script
Bram Moolenaar <Bram@vim.org>
parents:
27207
diff
changeset
|
2106 assert_match('\d: \f*[/\\]toggle.vim', execute('scriptnames')) |
27061
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2107 |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2108 feedkeys("xx", 'xt') |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2109 assert_equal('yes', g:doit_called) |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2110 |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2111 assert_fails('call feedkeys("yy", "xt")', 'E121: Undefined variable: toggle') |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2112 |
27061
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2113 nunmap tt |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2114 nunmap xx |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27116
diff
changeset
|
2115 nunmap yy |
27061
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2116 unlet g:toggle_loaded |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2117 unlet g:toggle_called |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2118 delete('Xdir', 'rf') |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2119 &rtp = save_rtp |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2120 enddef |
1a56c0252772
patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Bram Moolenaar <Bram@vim.org>
parents:
27059
diff
changeset
|
2121 |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2122 def Test_vim9script_autoload_fails() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2123 var lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2124 vim9script autoload |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2125 var n = 0 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2126 END |
27215
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2127 CheckScriptFailure(lines, 'E475: Invalid argument: autoload') |
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2128 |
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2129 lines =<< trim END |
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2130 vim9script noclear noclear |
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2131 var n = 0 |
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2132 END |
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2133 CheckScriptFailure(lines, 'E983: Duplicate argument: noclear') |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2134 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2135 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2136 def Test_import_autoload_fails() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2137 var lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2138 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2139 import autoload autoload 'prefixed.vim' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2140 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2141 CheckScriptFailure(lines, 'E121: Undefined variable: autoload') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2142 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2143 lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2144 vim9script |
27207
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2145 import autoload './doesNotExist.vim' |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2146 END |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2147 CheckScriptFailure(lines, 'E1264:') |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2148 |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2149 lines =<< trim END |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2150 vim9script |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2151 import autoload '/dir/doesNotExist.vim' |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2152 END |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2153 CheckScriptFailure(lines, 'E1264:') |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2154 |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2155 lines =<< trim END |
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2156 vim9script |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2157 import autoload 'doesNotExist.vim' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2158 END |
27207
7b8e2bea0ec5
patch 8.2.4132: Vim9: wrong error message when autoload script can't be found
Bram Moolenaar <Bram@vim.org>
parents:
27205
diff
changeset
|
2159 CheckScriptFailure(lines, 'E1053: Could not import "doesNotExist.vim"') |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2160 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2161 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2162 " test disassembling an auto-loaded function starting with "debug" |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2163 def Test_vim9_autoload_disass() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2164 mkdir('Xdir/autoload', 'p') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2165 var save_rtp = &rtp |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2166 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2167 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2168 var lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2169 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2170 def debugit#test(): string |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2171 return 'debug' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2172 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2173 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2174 writefile(lines, 'Xdir/autoload/debugit.vim') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2175 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2176 lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2177 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2178 def profileit#test(): string |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2179 return 'profile' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2180 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2181 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2182 writefile(lines, 'Xdir/autoload/profileit.vim') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2183 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2184 lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2185 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2186 assert_equal('debug', debugit#test()) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2187 disass debugit#test |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2188 assert_equal('profile', profileit#test()) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2189 disass profileit#test |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2190 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2191 CheckScriptSuccess(lines) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2192 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2193 delete('Xdir', 'rf') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2194 &rtp = save_rtp |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2195 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2196 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2197 " test using a vim9script that is auto-loaded from an autocmd |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2198 def Test_vim9_aucmd_autoload() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2199 var lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2200 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2201 def foo#test() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2202 echomsg getreg('"') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2203 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2204 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2205 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2206 mkdir('Xdir/autoload', 'p') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2207 writefile(lines, 'Xdir/autoload/foo.vim') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2208 var save_rtp = &rtp |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2209 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2210 augroup test |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2211 autocmd TextYankPost * call foo#test() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2212 augroup END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2213 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2214 normal Y |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2215 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2216 augroup test |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2217 autocmd! |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2218 augroup END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2219 delete('Xdir', 'rf') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2220 &rtp = save_rtp |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2221 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2222 |
27106
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2223 " test using a autoloaded file that is case sensitive |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2224 def Test_vim9_autoload_case_sensitive() |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2225 var lines =<< trim END |
27215
5b54f413d132
patch 8.2.4136: Vim9: the "autoload" argument of ":vim9script" is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27213
diff
changeset
|
2226 vim9script |
27106
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2227 export def CaseSensitive(): string |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2228 return 'done' |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2229 enddef |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2230 END |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2231 |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2232 mkdir('Xdir/autoload', 'p') |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2233 writefile(lines, 'Xdir/autoload/CaseSensitive.vim') |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2234 var save_rtp = &rtp |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2235 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2236 |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2237 lines =<< trim END |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2238 vim9script |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2239 import autoload 'CaseSensitive.vim' |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2240 assert_equal('done', CaseSensitive.CaseSensitive()) |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2241 END |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2242 CheckScriptSuccess(lines) |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2243 |
27150
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2244 if !has('fname_case') |
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2245 lines =<< trim END |
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2246 vim9script |
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2247 import autoload 'CaseSensitive.vim' |
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2248 import autoload 'casesensitive.vim' |
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2249 END |
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2250 CheckScriptFailure(lines, 'E1262:') |
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2251 endif |
2d0ea3f9ffe1
patch 8.2.4104: Vim9: lower casing the autoload prefix causes problems
Bram Moolenaar <Bram@vim.org>
parents:
27146
diff
changeset
|
2252 |
27106
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2253 delete('Xdir', 'rf') |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2254 &rtp = save_rtp |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2255 enddef |
d7e6b85dd89d
patch 8.2.4082: check for autoload file name and prefix fails
Bram Moolenaar <Bram@vim.org>
parents:
27086
diff
changeset
|
2256 |
27057
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2257 " This was causing a crash because suppress_errthrow wasn't reset. |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2258 def Test_vim9_autoload_error() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2259 var lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2260 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2261 def crash#func() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2262 try |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2263 for x in List() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2264 endfor |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2265 catch |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2266 endtry |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2267 g:ok = true |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2268 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2269 fu List() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2270 invalid |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2271 endfu |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2272 try |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2273 alsoinvalid |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2274 catch /wontmatch/ |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2275 endtry |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2276 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2277 call mkdir('Xruntime/autoload', 'p') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2278 call writefile(lines, 'Xruntime/autoload/crash.vim') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2279 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2280 # run in a separate Vim to avoid the side effects of assert_fails() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2281 lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2282 exe 'set rtp^=' .. getcwd() .. '/Xruntime' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2283 call crash#func() |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2284 call writefile(['ok'], 'Xdidit') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2285 qall! |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2286 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2287 writefile(lines, 'Xscript') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2288 RunVim([], [], '-S Xscript') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2289 assert_equal(['ok'], readfile('Xdidit')) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2290 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2291 delete('Xdidit') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2292 delete('Xscript') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2293 delete('Xruntime', 'rf') |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2294 |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2295 lines =<< trim END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2296 vim9script |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2297 var foo#bar = 'asdf' |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2298 END |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2299 CheckScriptFailure(lines, 'E461: Illegal variable name: foo#bar', 2) |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2300 enddef |
8f6cab688901
patch 8.2.4057: Vim9: not fully implementing the autoload mechanism
Bram Moolenaar <Bram@vim.org>
parents:
27030
diff
changeset
|
2301 |
27014
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2302 |
b861ae62860d
patch 8.2.4036: Vim9: script test file is getting too long
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2303 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |