Mercurial > vim
annotate src/testdir/test_vim9_class.vim @ 32142:64e8cd965e79 v9.0.1402
patch 9.0.1402: crash when using null_class
Commit: https://github.com/vim/vim/commit/d13dd30240e32071210f55b587182ff48757ea46
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 11 20:56:35 2023 +0000
patch 9.0.1402: crash when using null_class
Problem: Crash when using null_class.
Solution: Give an error when trying to use a null class.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 11 Mar 2023 22:00:03 +0100 |
parents | cdab211f342a |
children | d542423ef5c9 |
rev | line source |
---|---|
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test Vim9 classes |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 source check.vim |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 import './vim9.vim' as v9 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 def Test_class_basic() |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 var lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 class NotWorking |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 v9.CheckScriptFailure(lines, 'E1316:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 class notWorking |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 v9.CheckScriptFailure(lines, 'E1314:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 class Not@working |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 v9.CheckScriptFailure(lines, 'E1315:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 abstract noclass Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 v9.CheckScriptFailure(lines, 'E475:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 abstract classy Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 v9.CheckScriptFailure(lines, 'E475:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 endcl |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 v9.CheckScriptFailure(lines, 'E1065:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 class Something |
31849
dbec60b8c253
patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
51 endclass school's out |
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 v9.CheckScriptFailure(lines, 'E488:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 endclass | echo 'done' |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 v9.CheckScriptFailure(lines, 'E488:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 this |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 v9.CheckScriptFailure(lines, 'E1317:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 this. |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 v9.CheckScriptFailure(lines, 'E1317:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 this .count |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 v9.CheckScriptFailure(lines, 'E1317:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 this. count |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 v9.CheckScriptFailure(lines, 'E1317:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 this.count: number |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 that.count |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 v9.CheckScriptFailure(lines, 'E1318: Not a valid command in a class: that.count') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 this.count |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 v9.CheckScriptFailure(lines, 'E1022:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 class Something |
31517
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
114 def new() |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
115 this.state = 0 |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
116 enddef |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
117 endclass |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
118 var obj = Something.new() |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
119 END |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
120 v9.CheckScriptFailure(lines, 'E1089:') |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
121 |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
122 lines =<< trim END |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
123 vim9script |
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
124 class Something |
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 this.count : number |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 v9.CheckScriptFailure(lines, 'E1059:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 class Something |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 this.count:number |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 v9.CheckScriptFailure(lines, 'E1069:') |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 lines =<< trim END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 vim9script |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 class TextPosition |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 this.lnum: number |
31424
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
143 this.col: number |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31404
diff
changeset
|
144 |
31501
560ba934725f
patch 9.0.1083: empty and comment lines in a class cause an error
Bram Moolenaar <Bram@vim.org>
parents:
31483
diff
changeset
|
145 # make a nicely formatted string |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31404
diff
changeset
|
146 def ToString(): string |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31404
diff
changeset
|
147 return $'({this.lnum}, {this.col})' |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31404
diff
changeset
|
148 enddef |
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 endclass |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 |
31404
60b1d266548d
patch 9.0.1035: object members are not being marked as used
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
151 # use the automatically generated new() method |
60b1d266548d
patch 9.0.1035: object members are not being marked as used
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
152 var pos = TextPosition.new(2, 12) |
60b1d266548d
patch 9.0.1035: object members are not being marked as used
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
153 assert_equal(2, pos.lnum) |
60b1d266548d
patch 9.0.1035: object members are not being marked as used
Bram Moolenaar <Bram@vim.org>
parents:
31396
diff
changeset
|
154 assert_equal(12, pos.col) |
31416
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31404
diff
changeset
|
155 |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31404
diff
changeset
|
156 # call an object method |
f088f1d97eee
patch 9.0.1041: cannot define a method in a class
Bram Moolenaar <Bram@vim.org>
parents:
31404
diff
changeset
|
157 assert_equal('(2, 12)', pos.ToString()) |
31712
2d68375d5ddf
patch 9.0.1188: return value of type() for class and object unclear
Bram Moolenaar <Bram@vim.org>
parents:
31708
diff
changeset
|
158 |
2d68375d5ddf
patch 9.0.1188: return value of type() for class and object unclear
Bram Moolenaar <Bram@vim.org>
parents:
31708
diff
changeset
|
159 assert_equal(v:t_class, type(TextPosition)) |
2d68375d5ddf
patch 9.0.1188: return value of type() for class and object unclear
Bram Moolenaar <Bram@vim.org>
parents:
31708
diff
changeset
|
160 assert_equal(v:t_object, type(pos)) |
2d68375d5ddf
patch 9.0.1188: return value of type() for class and object unclear
Bram Moolenaar <Bram@vim.org>
parents:
31708
diff
changeset
|
161 assert_equal('class<TextPosition>', typename(TextPosition)) |
2d68375d5ddf
patch 9.0.1188: return value of type() for class and object unclear
Bram Moolenaar <Bram@vim.org>
parents:
31708
diff
changeset
|
162 assert_equal('object<TextPosition>', typename(pos)) |
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 END |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 v9.CheckScriptSuccess(lines) |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 enddef |
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 |
32047
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
167 def Test_class_defined_twice() |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
168 # class defined twice should fail |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
169 var lines =<< trim END |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
170 vim9script |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
171 class There |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
172 endclass |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
173 class There |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
174 endclass |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
175 END |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
176 v9.CheckScriptFailure(lines, 'E1041: Redefining script item: "There"') |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
177 |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
178 # one class, reload same script twice is OK |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
179 lines =<< trim END |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
180 vim9script |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
181 class There |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
182 endclass |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
183 END |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
184 writefile(lines, 'XclassTwice.vim', 'D') |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
185 source XclassTwice.vim |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
186 source XclassTwice.vim |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
187 enddef |
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
188 |
32051
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
189 def Test_returning_null_object() |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
190 # this was causing an internal error |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
191 var lines =<< trim END |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
192 vim9script |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
193 |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
194 class BufferList |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
195 def Current(): any |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
196 return null_object |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
197 enddef |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
198 endclass |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
199 |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
200 var buffers = BufferList.new() |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
201 echo buffers.Current() |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
202 END |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
203 v9.CheckScriptSuccess(lines) |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
204 enddef |
e8c60d35fce3
patch 9.0.1357: using null_object results in an internal error
Bram Moolenaar <Bram@vim.org>
parents:
32047
diff
changeset
|
205 |
32142
64e8cd965e79
patch 9.0.1402: crash when using null_class
Bram Moolenaar <Bram@vim.org>
parents:
32088
diff
changeset
|
206 def Test_using_null_class() |
64e8cd965e79
patch 9.0.1402: crash when using null_class
Bram Moolenaar <Bram@vim.org>
parents:
32088
diff
changeset
|
207 var lines =<< trim END |
64e8cd965e79
patch 9.0.1402: crash when using null_class
Bram Moolenaar <Bram@vim.org>
parents:
32088
diff
changeset
|
208 @_ = null_class.member |
64e8cd965e79
patch 9.0.1402: crash when using null_class
Bram Moolenaar <Bram@vim.org>
parents:
32088
diff
changeset
|
209 END |
64e8cd965e79
patch 9.0.1402: crash when using null_class
Bram Moolenaar <Bram@vim.org>
parents:
32088
diff
changeset
|
210 v9.CheckDefExecAndScriptFailure(lines, ['E715:', 'E1363:']) |
64e8cd965e79
patch 9.0.1402: crash when using null_class
Bram Moolenaar <Bram@vim.org>
parents:
32088
diff
changeset
|
211 enddef |
64e8cd965e79
patch 9.0.1402: crash when using null_class
Bram Moolenaar <Bram@vim.org>
parents:
32088
diff
changeset
|
212 |
31833
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
213 def Test_class_interface_wrong_end() |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
214 var lines =<< trim END |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
215 vim9script |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
216 abstract class SomeName |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
217 this.member = 'text' |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
218 endinterface |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
219 END |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
220 v9.CheckScriptFailure(lines, 'E476: Invalid command: endinterface, expected endclass') |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
221 |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
222 lines =<< trim END |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
223 vim9script |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
224 export interface AnotherName |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
225 this.member: string |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
226 endclass |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
227 END |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
228 v9.CheckScriptFailure(lines, 'E476: Invalid command: endclass, expected endinterface') |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
229 enddef |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
230 |
31970
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
231 def Test_object_not_set() |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
232 var lines =<< trim END |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
233 vim9script |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
234 |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
235 class State |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
236 this.value = 'xyz' |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
237 endclass |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
238 |
31972
4e59c4260d84
patch 9.0.1318: code style test fails
Bram Moolenaar <Bram@vim.org>
parents:
31970
diff
changeset
|
239 var state: State |
31970
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
240 var db = {'xyz': 789} |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
241 echo db[state.value] |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
242 END |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
243 v9.CheckScriptFailure(lines, 'E1360:') |
31976
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
244 |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
245 lines =<< trim END |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
246 vim9script |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
247 |
32078
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
248 class Class |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
249 this.id: string |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
250 def Method1() |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
251 echo 'Method1' .. this.id |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
252 enddef |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
253 endclass |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
254 |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
255 var obj: Class |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
256 def Func() |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
257 obj.Method1() |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
258 enddef |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
259 Func() |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
260 END |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
261 v9.CheckScriptFailure(lines, 'E1360:') |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
262 |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
263 lines =<< trim END |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
264 vim9script |
615964c77be3
patch 9.0.1370: crash when using a NULL object
Bram Moolenaar <Bram@vim.org>
parents:
32051
diff
changeset
|
265 |
31976
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
266 class Background |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
267 this.background = 'dark' |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
268 endclass |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
269 |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
270 class Colorscheme |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
271 this._bg: Background |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
272 |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
273 def GetBackground(): string |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
274 return this._bg.background |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
275 enddef |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
276 endclass |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
277 |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
278 var bg: Background # UNINITIALIZED |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
279 echo Colorscheme.new(bg).GetBackground() |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
280 END |
16025ef158bf
patch 9.0.1320: checking the type of a null object causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31972
diff
changeset
|
281 v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected object<Background> but got object<Unknown>') |
32088
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
282 |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
283 # TODO: this should not give an error but be handled at runtime |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
284 lines =<< trim END |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
285 vim9script |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
286 |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
287 class Class |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
288 this.id: string |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
289 def Method1() |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
290 echo 'Method1' .. this.id |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
291 enddef |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
292 endclass |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
293 |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
294 var obj = null_object |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
295 def Func() |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
296 obj.Method1() |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
297 enddef |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
298 Func() |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
299 END |
cdab211f342a
patch 9.0.1375: crash when getting member of obj of unknown class
Bram Moolenaar <Bram@vim.org>
parents:
32078
diff
changeset
|
300 v9.CheckScriptFailure(lines, 'E1363:') |
31970
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
301 enddef |
fe66019e7a23
patch 9.0.1317: crash when using an unset object variable
Bram Moolenaar <Bram@vim.org>
parents:
31928
diff
changeset
|
302 |
31424
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
303 def Test_class_member_initializer() |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
304 var lines =<< trim END |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
305 vim9script |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
306 |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
307 class TextPosition |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
308 this.lnum: number = 1 |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
309 this.col: number = 1 |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
310 |
31501
560ba934725f
patch 9.0.1083: empty and comment lines in a class cause an error
Bram Moolenaar <Bram@vim.org>
parents:
31483
diff
changeset
|
311 # constructor with only the line number |
31424
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
312 def new(lnum: number) |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
313 this.lnum = lnum |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
314 enddef |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
315 endclass |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
316 |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
317 var pos = TextPosition.new(3) |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
318 assert_equal(3, pos.lnum) |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
319 assert_equal(1, pos.col) |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
320 |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
321 var instr = execute('disassemble TextPosition.new') |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
322 assert_match('new\_s*' .. |
31426
92afb904fbee
patch 9.0.1046: class method disassemble test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
31424
diff
changeset
|
323 '0 NEW TextPosition size \d\+\_s*' .. |
31424
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
324 '\d PUSHNR 1\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
325 '\d STORE_THIS 0\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
326 '\d PUSHNR 1\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
327 '\d STORE_THIS 1\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
328 'this.lnum = lnum\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
329 '\d LOAD arg\[-1]\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
330 '\d PUSHNR 0\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
331 '\d LOAD $0\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
332 '\d\+ STOREINDEX object\_s*' .. |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
333 '\d\+ RETURN object.*', |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
334 instr) |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
335 END |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
336 v9.CheckScriptSuccess(lines) |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
337 enddef |
e31fc75f6aff
patch 9.0.1045: in a class object members cannot be initialized
Bram Moolenaar <Bram@vim.org>
parents:
31416
diff
changeset
|
338 |
31980
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
339 def Test_member_any_used_as_object() |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
340 var lines =<< trim END |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
341 vim9script |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
342 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
343 class Inner |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
344 this.value: number = 0 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
345 endclass |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
346 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
347 class Outer |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
348 this.inner: any |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
349 endclass |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
350 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
351 def F(outer: Outer) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
352 outer.inner.value = 1 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
353 enddef |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
354 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
355 var inner_obj = Inner.new(0) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
356 var outer_obj = Outer.new(inner_obj) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
357 F(outer_obj) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
358 assert_equal(1, inner_obj.value) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
359 END |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
360 v9.CheckScriptSuccess(lines) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
361 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
362 lines =<< trim END |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
363 vim9script |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
364 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
365 class Inner |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
366 this.value: number = 0 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
367 endclass |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
368 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
369 class Outer |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
370 this.inner: Inner |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
371 endclass |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
372 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
373 def F(outer: Outer) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
374 outer.inner.value = 1 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
375 enddef |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
376 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
377 def Test_assign_to_nested_typed_member() |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
378 var inner = Inner.new(0) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
379 var outer = Outer.new(inner) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
380 F(outer) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
381 assert_equal(1, inner.value) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
382 enddef |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
383 |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
384 Test_assign_to_nested_typed_member() |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
385 END |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
386 v9.CheckScriptSuccess(lines) |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
387 enddef |
13329cb9faee
patch 9.0.1322: crash when indexing "any" which is an object
Bram Moolenaar <Bram@vim.org>
parents:
31976
diff
changeset
|
388 |
31738
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
389 def Test_assignment_with_operator() |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
390 var lines =<< trim END |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
391 vim9script |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
392 |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
393 class Foo |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
394 this.x: number |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
395 |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
396 def Add(n: number) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
397 this.x += n |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
398 enddef |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
399 endclass |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
400 |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
401 var f = Foo.new(3) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
402 f.Add(17) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
403 assert_equal(20, f.x) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
404 END |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
405 v9.CheckScriptSuccess(lines) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
406 enddef |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
407 |
31740
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
408 def Test_list_of_objects() |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
409 var lines =<< trim END |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
410 vim9script |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
411 |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
412 class Foo |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
413 def Add() |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
414 enddef |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
415 endclass |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
416 |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
417 def ProcessList(fooList: list<Foo>) |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
418 for foo in fooList |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
419 foo.Add() |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
420 endfor |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
421 enddef |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
422 |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
423 var l: list<Foo> = [Foo.new()] |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
424 ProcessList(l) |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
425 END |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
426 v9.CheckScriptSuccess(lines) |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
427 enddef |
22a4824d7964
patch 9.0.1202: crash when iterating over list of objects
Bram Moolenaar <Bram@vim.org>
parents:
31738
diff
changeset
|
428 |
31744
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
429 def Test_expr_after_using_object() |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
430 var lines =<< trim END |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
431 vim9script |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
432 |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
433 class Something |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
434 this.label: string = '' |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
435 endclass |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
436 |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
437 def Foo(): Something |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
438 var v = Something.new() |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
439 echo 'in Foo(): ' .. typename(v) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
440 return v |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
441 enddef |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
442 |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
443 Foo() |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
444 END |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
445 v9.CheckScriptSuccess(lines) |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
446 enddef |
1b2bde0c64f2
patch 9.0.1204: expression compiled the wrong way after using an object
Bram Moolenaar <Bram@vim.org>
parents:
31740
diff
changeset
|
447 |
31441
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
448 def Test_class_default_new() |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
449 var lines =<< trim END |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
450 vim9script |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
451 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
452 class TextPosition |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
453 this.lnum: number = 1 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
454 this.col: number = 1 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
455 endclass |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
456 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
457 var pos = TextPosition.new() |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
458 assert_equal(1, pos.lnum) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
459 assert_equal(1, pos.col) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
460 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
461 pos = TextPosition.new(v:none, v:none) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
462 assert_equal(1, pos.lnum) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
463 assert_equal(1, pos.col) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
464 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
465 pos = TextPosition.new(3, 22) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
466 assert_equal(3, pos.lnum) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
467 assert_equal(22, pos.col) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
468 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
469 pos = TextPosition.new(v:none, 33) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
470 assert_equal(1, pos.lnum) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
471 assert_equal(33, pos.col) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
472 END |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
473 v9.CheckScriptSuccess(lines) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
474 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
475 lines =<< trim END |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
476 vim9script |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
477 class Person |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
478 this.name: string |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
479 this.age: number = 42 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
480 this.education: string = "unknown" |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
481 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
482 def new(this.name, this.age = v:none, this.education = v:none) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
483 enddef |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
484 endclass |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
485 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
486 var piet = Person.new("Piet") |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
487 assert_equal("Piet", piet.name) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
488 assert_equal(42, piet.age) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
489 assert_equal("unknown", piet.education) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
490 |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
491 var chris = Person.new("Chris", 4, "none") |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
492 assert_equal("Chris", chris.name) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
493 assert_equal(4, chris.age) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
494 assert_equal("none", chris.education) |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
495 END |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
496 v9.CheckScriptSuccess(lines) |
31443
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
497 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
498 lines =<< trim END |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
499 vim9script |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
500 class Person |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
501 this.name: string |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
502 this.age: number = 42 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
503 this.education: string = "unknown" |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
504 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
505 def new(this.name, this.age = v:none, this.education = v:none) |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
506 enddef |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
507 endclass |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
508 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
509 var missing = Person.new() |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
510 END |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
511 v9.CheckScriptFailure(lines, 'E119:') |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
512 enddef |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
513 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
514 def Test_class_object_member_inits() |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
515 var lines =<< trim END |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
516 vim9script |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
517 class TextPosition |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
518 this.lnum: number |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
519 this.col = 1 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
520 this.addcol: number = 2 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
521 endclass |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
522 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
523 var pos = TextPosition.new() |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
524 assert_equal(0, pos.lnum) |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
525 assert_equal(1, pos.col) |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
526 assert_equal(2, pos.addcol) |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
527 END |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
528 v9.CheckScriptSuccess(lines) |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
529 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
530 lines =<< trim END |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
531 vim9script |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
532 class TextPosition |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
533 this.lnum |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
534 this.col = 1 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
535 endclass |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
536 END |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
537 v9.CheckScriptFailure(lines, 'E1022:') |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
538 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
539 lines =<< trim END |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
540 vim9script |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
541 class TextPosition |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
542 this.lnum = v:none |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
543 this.col = 1 |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
544 endclass |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
545 END |
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
546 v9.CheckScriptFailure(lines, 'E1330:') |
31441
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
547 enddef |
e572ff386670
patch 9.0.1053: default constructor arguments are not optional
Bram Moolenaar <Bram@vim.org>
parents:
31426
diff
changeset
|
548 |
31455
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
549 def Test_class_object_member_access() |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
550 var lines =<< trim END |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
551 vim9script |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
552 class Triple |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
553 this._one = 1 |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
554 this.two = 2 |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
555 public this.three = 3 |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
556 |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
557 def GetOne(): number |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
558 return this._one |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
559 enddef |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
560 endclass |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
561 |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
562 var trip = Triple.new() |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
563 assert_equal(1, trip.GetOne()) |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
564 assert_equal(2, trip.two) |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
565 assert_equal(3, trip.three) |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
566 assert_fails('echo trip._one', 'E1333') |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
567 |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
568 assert_fails('trip._one = 11', 'E1333') |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
569 assert_fails('trip.two = 22', 'E1335') |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
570 trip.three = 33 |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
571 assert_equal(33, trip.three) |
31483
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
572 |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
573 assert_fails('trip.four = 4', 'E1334') |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
574 END |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
575 v9.CheckScriptSuccess(lines) |
31521
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
576 |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
577 lines =<< trim END |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
578 vim9script |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
579 |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
580 class MyCar |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
581 this.make: string |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
582 this.age = 5 |
31521
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
583 |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
584 def new(make_arg: string) |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
585 this.make = make_arg |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
586 enddef |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
587 |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
588 def GetMake(): string |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
589 return $"make = {this.make}" |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
590 enddef |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
591 def GetAge(): number |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
592 return this.age |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
593 enddef |
31521
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
594 endclass |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
595 |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
596 var c = MyCar.new("abc") |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
597 assert_equal('make = abc', c.GetMake()) |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
598 |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
599 c = MyCar.new("def") |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
600 assert_equal('make = def', c.GetMake()) |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
601 |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
602 var c2 = MyCar.new("123") |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
603 assert_equal('make = 123', c2.GetMake()) |
31616
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
604 |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
605 def CheckCar() |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
606 assert_equal("make = def", c.GetMake()) |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
607 assert_equal(5, c.GetAge()) |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
608 enddef |
0eb51cec2154
patch 9.0.1140: cannot call an object method in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31614
diff
changeset
|
609 CheckCar() |
31521
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
610 END |
065e4ccf5e10
patch 9.0.1093: using freed memory of object member
Bram Moolenaar <Bram@vim.org>
parents:
31517
diff
changeset
|
611 v9.CheckScriptSuccess(lines) |
31525
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
612 |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
613 lines =<< trim END |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
614 vim9script |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
615 |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
616 class MyCar |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
617 this.make: string |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
618 |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
619 def new(make_arg: string) |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
620 this.make = make_arg |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
621 enddef |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
622 endclass |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
623 |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
624 var c = MyCar.new("abc") |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
625 var c = MyCar.new("def") |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
626 END |
f7c82a85e88a
patch 9.0.1095: using freed memory when declaration fails
Bram Moolenaar <Bram@vim.org>
parents:
31521
diff
changeset
|
627 v9.CheckScriptFailure(lines, 'E1041:') |
31813
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
628 |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
629 lines =<< trim END |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
630 vim9script |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
631 |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
632 class Foo |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
633 this.x: list<number> = [] |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
634 |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
635 def Add(n: number): any |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
636 this.x->add(n) |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
637 return this |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
638 enddef |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
639 endclass |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
640 |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
641 echo Foo.new().Add(1).Add(2).x |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
642 echo Foo.new().Add(1).Add(2) |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
643 .x |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
644 echo Foo.new().Add(1) |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
645 .Add(2).x |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
646 echo Foo.new() |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
647 .Add(1).Add(2).x |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
648 echo Foo.new() |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
649 .Add(1) |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
650 .Add(2) |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
651 .x |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
652 END |
cd4065ab4503
patch 9.0.1239: cannot have a line break before an object member access
Bram Moolenaar <Bram@vim.org>
parents:
31770
diff
changeset
|
653 v9.CheckScriptSuccess(lines) |
31483
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
654 enddef |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
655 |
31604
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
656 def Test_class_object_compare() |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
657 var class_lines =<< trim END |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
658 vim9script |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
659 class Item |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
660 this.nr = 0 |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
661 this.name = 'xx' |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
662 endclass |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
663 END |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
664 |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
665 # used at the script level and in a compiled function |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
666 var test_lines =<< trim END |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
667 var i1 = Item.new() |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
668 assert_equal(i1, i1) |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
669 assert_true(i1 is i1) |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
670 var i2 = Item.new() |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
671 assert_equal(i1, i2) |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
672 assert_false(i1 is i2) |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
673 var i3 = Item.new(0, 'xx') |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
674 assert_equal(i1, i3) |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
675 |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
676 var io1 = Item.new(1, 'xx') |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
677 assert_notequal(i1, io1) |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
678 var io2 = Item.new(0, 'yy') |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
679 assert_notequal(i1, io2) |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
680 END |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
681 |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
682 v9.CheckScriptSuccess(class_lines + test_lines) |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
683 v9.CheckScriptSuccess( |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
684 class_lines + ['def Test()'] + test_lines + ['enddef', 'Test()']) |
31604
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
685 |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
686 for op in ['>', '>=', '<', '<=', '=~', '!~'] |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
687 var op_lines = [ |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
688 'var i1 = Item.new()', |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
689 'var i2 = Item.new()', |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
690 'echo i1 ' .. op .. ' i2', |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
691 ] |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
692 v9.CheckScriptFailure(class_lines + op_lines, 'E1153: Invalid operation for object') |
31614
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
693 v9.CheckScriptFailure(class_lines |
f3c7e573b7be
patch 9.0.1139: cannot create a new object in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31604
diff
changeset
|
694 + ['def Test()'] + op_lines + ['enddef', 'Test()'], 'E1153: Invalid operation for object') |
31604
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
695 endfor |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
696 enddef |
9b13b3a63bc0
patch 9.0.1134: comparing objects uses identity instead of equality
Bram Moolenaar <Bram@vim.org>
parents:
31590
diff
changeset
|
697 |
31698
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
698 def Test_object_type() |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
699 var lines =<< trim END |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
700 vim9script |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
701 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
702 class One |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
703 this.one = 1 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
704 endclass |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
705 class Two |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
706 this.two = 2 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
707 endclass |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
708 class TwoMore extends Two |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
709 this.more = 9 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
710 endclass |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
711 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
712 var o: One = One.new() |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
713 var t: Two = Two.new() |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
714 var m: TwoMore = TwoMore.new() |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
715 var tm: Two = TwoMore.new() |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
716 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
717 t = m |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
718 END |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
719 v9.CheckScriptSuccess(lines) |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
720 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
721 lines =<< trim END |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
722 vim9script |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
723 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
724 class One |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
725 this.one = 1 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
726 endclass |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
727 class Two |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
728 this.two = 2 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
729 endclass |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
730 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
731 var o: One = Two.new() |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
732 END |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
733 v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected object<One> but got object<Two>') |
31704
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
734 |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
735 lines =<< trim END |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
736 vim9script |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
737 |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
738 interface One |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
739 def GetMember(): number |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
740 endinterface |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
741 class Two implements One |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
742 this.one = 1 |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
743 def GetMember(): number |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
744 return this.one |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
745 enddef |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
746 endclass |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
747 |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
748 var o: One = Two.new(5) |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
749 assert_equal(5, o.GetMember()) |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
750 END |
69ee530cac28
patch 9.0.1184: interface of an object is not recognized when checking type
Bram Moolenaar <Bram@vim.org>
parents:
31698
diff
changeset
|
751 v9.CheckScriptSuccess(lines) |
31750
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
752 |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
753 lines =<< trim END |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
754 vim9script |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
755 |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
756 class Num |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
757 this.n: number = 0 |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
758 endclass |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
759 |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
760 def Ref(name: string): func(Num): Num |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
761 return (arg: Num): Num => { |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
762 return eval(name)(arg) |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
763 } |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
764 enddef |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
765 |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
766 const Fn = Ref('Double') |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
767 var Double = (m: Num): Num => Num.new(m.n * 2) |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
768 |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
769 echo Fn(Num.new(4)) |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
770 END |
13cecb002fe6
patch 9.0.1207: error when object type is expected but getting "any"
Bram Moolenaar <Bram@vim.org>
parents:
31746
diff
changeset
|
771 v9.CheckScriptSuccess(lines) |
31698
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
772 enddef |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
773 |
31590
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
774 def Test_class_member() |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
775 # check access rules |
31483
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
776 var lines =<< trim END |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
777 vim9script |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
778 class TextPos |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
779 this.lnum = 1 |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
780 this.col = 1 |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
781 static counter = 0 |
31580
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
782 static _secret = 7 |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
783 public static anybody = 42 |
31483
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
784 |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
785 static def AddToCounter(nr: number) |
31483
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
786 counter += nr |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
787 enddef |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
788 endclass |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
789 |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
790 assert_equal(0, TextPos.counter) |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
791 TextPos.AddToCounter(3) |
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
792 assert_equal(3, TextPos.counter) |
31517
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
793 assert_fails('echo TextPos.noSuchMember', 'E1338:') |
31849
dbec60b8c253
patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents:
31843
diff
changeset
|
794 |
31630
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
795 def GetCounter(): number |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
796 return TextPos.counter |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
797 enddef |
5400eba7c3f3
patch 9.0.1147: cannot access a class member in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
31616
diff
changeset
|
798 assert_equal(3, GetCounter()) |
31483
1bebc2093e6b
patch 9.0.1074: class members are not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31455
diff
changeset
|
799 |
31517
cd5247f4da06
patch 9.0.1091: assignment to non-existing member causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
31501
diff
changeset
|
800 assert_fails('TextPos.noSuchMember = 2', 'E1337:') |
31580
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
801 assert_fails('TextPos.counter = 5', 'E1335:') |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
802 assert_fails('TextPos.counter += 5', 'E1335:') |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
803 |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
804 assert_fails('echo TextPos._secret', 'E1333:') |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
805 assert_fails('TextPos._secret = 8', 'E1333:') |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
806 |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
807 assert_equal(42, TextPos.anybody) |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
808 TextPos.anybody = 12 |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
809 assert_equal(12, TextPos.anybody) |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
810 TextPos.anybody += 5 |
9f2a9dd57226
patch 9.0.1122: class member access is not fully tested yet
Bram Moolenaar <Bram@vim.org>
parents:
31525
diff
changeset
|
811 assert_equal(17, TextPos.anybody) |
31455
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
812 END |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
813 v9.CheckScriptSuccess(lines) |
31590
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
814 |
31738
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
815 # example in the help |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
816 lines =<< trim END |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
817 vim9script |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
818 class OtherThing |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
819 this.size: number |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
820 static totalSize: number |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
821 |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
822 def new(this.size) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
823 totalSize += this.size |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
824 enddef |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
825 endclass |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
826 assert_equal(0, OtherThing.totalSize) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
827 var to3 = OtherThing.new(3) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
828 assert_equal(3, OtherThing.totalSize) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
829 var to7 = OtherThing.new(7) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
830 assert_equal(10, OtherThing.totalSize) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
831 END |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
832 v9.CheckScriptSuccess(lines) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
833 |
31815
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
834 # access private member in lambda |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
835 lines =<< trim END |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
836 vim9script |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
837 |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
838 class Foo |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
839 this._x: number = 0 |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
840 |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
841 def Add(n: number): number |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
842 const F = (): number => this._x + n |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
843 return F() |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
844 enddef |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
845 endclass |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
846 |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
847 var foo = Foo.new() |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
848 assert_equal(5, foo.Add(5)) |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
849 END |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
850 v9.CheckScriptSuccess(lines) |
64f03e860c91
patch 9.0.1240: cannot access a private object member in a lambda
Bram Moolenaar <Bram@vim.org>
parents:
31813
diff
changeset
|
851 |
31590
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
852 # check shadowing |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
853 lines =<< trim END |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
854 vim9script |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
855 |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
856 class Some |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
857 static count = 0 |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
858 def Method(count: number) |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
859 echo count |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
860 enddef |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
861 endclass |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
862 |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
863 var s = Some.new() |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
864 s.Method(7) |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
865 END |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
866 v9.CheckScriptFailure(lines, 'E1340: Argument already declared in the class: count') |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
867 |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
868 lines =<< trim END |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
869 vim9script |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
870 |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
871 class Some |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
872 static count = 0 |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
873 def Method(arg: number) |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
874 var count = 3 |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
875 echo arg count |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
876 enddef |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
877 endclass |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
878 |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
879 var s = Some.new() |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
880 s.Method(7) |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
881 END |
aee868b9229a
patch 9.0.1127: no error if function argument shadows class member
Bram Moolenaar <Bram@vim.org>
parents:
31582
diff
changeset
|
882 v9.CheckScriptFailure(lines, 'E1341: Variable already declared in the class: count') |
31455
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
883 enddef |
5ef28f5ff357
patch 9.0.1060: private and public object members are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31451
diff
changeset
|
884 |
31633
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
885 func Test_class_garbagecollect() |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
886 let lines =<< trim END |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
887 vim9script |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
888 |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
889 class Point |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
890 this.p = [2, 3] |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
891 static pl = ['a', 'b'] |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
892 static pd = {a: 'a', b: 'b'} |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
893 endclass |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
894 |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
895 echo Point.pl Point.pd |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
896 call test_garbagecollect_now() |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
897 echo Point.pl Point.pd |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
898 END |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
899 call v9.CheckScriptSuccess(lines) |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
900 endfunc |
d19377e0a0b4
patch 9.0.1149: class members may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
31630
diff
changeset
|
901 |
31582
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
902 def Test_class_function() |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
903 var lines =<< trim END |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
904 vim9script |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
905 class Value |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
906 this.value = 0 |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
907 static objects = 0 |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
908 |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
909 def new(v: number) |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
910 this.value = v |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
911 ++objects |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
912 enddef |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
913 |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
914 static def GetCount(): number |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
915 return objects |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
916 enddef |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
917 endclass |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
918 |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
919 assert_equal(0, Value.GetCount()) |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
920 var v1 = Value.new(2) |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
921 assert_equal(1, Value.GetCount()) |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
922 var v2 = Value.new(7) |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
923 assert_equal(2, Value.GetCount()) |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
924 END |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
925 v9.CheckScriptSuccess(lines) |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
926 enddef |
8bbc932fbd09
patch 9.0.1123: class function not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31580
diff
changeset
|
927 |
32013
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
928 def Test_class_defcompile() |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
929 var lines =<< trim END |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
930 vim9script |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
931 |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
932 class C |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
933 def Fo(i: number): string |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
934 return i |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
935 enddef |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
936 endclass |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
937 |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
938 defcompile C.Fo |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
939 END |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
940 v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number') |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
941 |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
942 lines =<< trim END |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
943 vim9script |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
944 |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
945 class C |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
946 static def Fc(): number |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
947 return 'x' |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
948 enddef |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
949 endclass |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
950 |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
951 defcompile C.Fc |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
952 END |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
953 v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got string') |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
954 enddef |
ec05de98b0f7
patch 9.0.1338: :defcompile and :disassemble can't find class method
Bram Moolenaar <Bram@vim.org>
parents:
31980
diff
changeset
|
955 |
31451
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
956 def Test_class_object_to_string() |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
957 var lines =<< trim END |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
958 vim9script |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
959 class TextPosition |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
960 this.lnum = 1 |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
961 this.col = 22 |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
962 endclass |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
963 |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
964 assert_equal("class TextPosition", string(TextPosition)) |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
965 |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
966 var pos = TextPosition.new() |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
967 assert_equal("object of TextPosition {lnum: 1, col: 22}", string(pos)) |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
968 END |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
969 v9.CheckScriptSuccess(lines) |
5804270d6e9b
patch 9.0.1058: string value of class and object do not have information
Bram Moolenaar <Bram@vim.org>
parents:
31443
diff
changeset
|
970 enddef |
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 |
31635
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
972 def Test_interface_basics() |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
973 var lines =<< trim END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
974 vim9script |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
975 interface Something |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
976 this.value: string |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
977 static count: number |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
978 def GetCount(): number |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
979 endinterface |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
980 END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
981 v9.CheckScriptSuccess(lines) |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
982 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
983 lines =<< trim END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
984 interface SomethingWrong |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
985 static count = 7 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
986 endinterface |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
987 END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
988 v9.CheckScriptFailure(lines, 'E1342:') |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
989 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
990 lines =<< trim END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
991 vim9script |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
992 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
993 interface Some |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
994 static count: number |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
995 def Method(count: number) |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
996 endinterface |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
997 END |
31720
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
998 v9.CheckScriptFailure(lines, 'E1340: Argument already declared in the class: count') |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
999 |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1000 lines =<< trim END |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1001 vim9script |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1002 |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1003 interface Some |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1004 this.value: number |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1005 def Method(value: number) |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1006 endinterface |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1007 END |
1949c2613b3e
patch 9.0.1192: no error when class function argument shadows a member
Bram Moolenaar <Bram@vim.org>
parents:
31712
diff
changeset
|
1008 v9.CheckScriptFailure(lines, 'E1340: Argument already declared in the class: value') |
31635
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1009 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1010 lines =<< trim END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1011 vim9script |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1012 interface somethingWrong |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1013 static count = 7 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1014 endinterface |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1015 END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1016 v9.CheckScriptFailure(lines, 'E1343: Interface name must start with an uppercase letter: somethingWrong') |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1017 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1018 lines =<< trim END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1019 vim9script |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1020 interface SomethingWrong |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1021 this.value: string |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1022 static count = 7 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1023 def GetCount(): number |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1024 endinterface |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1025 END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1026 v9.CheckScriptFailure(lines, 'E1344:') |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1027 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1028 lines =<< trim END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1029 vim9script |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1030 interface SomethingWrong |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1031 this.value: string |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1032 static count: number |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1033 def GetCount(): number |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1034 return 5 |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1035 enddef |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1036 endinterface |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1037 END |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1038 v9.CheckScriptFailure(lines, 'E1345: Not a valid command in an interface: return 5') |
31831
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1039 |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1040 lines =<< trim END |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1041 vim9script |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1042 export interface EnterExit |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1043 def Enter(): void |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1044 def Exit(): void |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1045 endinterface |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1046 END |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1047 writefile(lines, 'XdefIntf.vim', 'D') |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1048 |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1049 lines =<< trim END |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1050 vim9script |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1051 import './XdefIntf.vim' as defIntf |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1052 export def With(ee: defIntf.EnterExit, F: func) |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1053 ee.Enter() |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1054 try |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1055 F() |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1056 finally |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1057 ee.Exit() |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1058 endtry |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1059 enddef |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1060 END |
554bd03ff609
patch 9.0.1248: cannot export an interface
Bram Moolenaar <Bram@vim.org>
parents:
31815
diff
changeset
|
1061 v9.CheckScriptSuccess(lines) |
31833
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1062 |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1063 var imported =<< trim END |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1064 vim9script |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1065 export abstract class EnterExit |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1066 def Enter(): void |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1067 enddef |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1068 def Exit(): void |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1069 enddef |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1070 endclass |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1071 END |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1072 writefile(imported, 'XdefIntf2.vim', 'D') |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1073 |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1074 lines[1] = " import './XdefIntf2.vim' as defIntf" |
3516e35f409f
patch 9.0.1249: cannot export an abstract class
Bram Moolenaar <Bram@vim.org>
parents:
31831
diff
changeset
|
1075 v9.CheckScriptSuccess(lines) |
31635
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1076 enddef |
5c1b7a87466e
patch 9.0.1150: :interface is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31633
diff
changeset
|
1077 |
31639
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1078 def Test_class_implements_interface() |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1079 var lines =<< trim END |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1080 vim9script |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1081 |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1082 interface Some |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1083 static count: number |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1084 def Method(nr: number) |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1085 endinterface |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1086 |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1087 class SomeImpl implements Some |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1088 static count: number |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1089 def Method(nr: number) |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1090 echo nr |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1091 enddef |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1092 endclass |
31649
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1093 |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1094 interface Another |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1095 this.member: string |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1096 endinterface |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1097 |
32047
b49db96c1e55
patch 9.0.1355: no error when declaring a class twice
Bram Moolenaar <Bram@vim.org>
parents:
32013
diff
changeset
|
1098 class AnotherImpl implements Some, Another |
31649
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1099 this.member = 'abc' |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1100 static count: number |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1101 def Method(nr: number) |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1102 echo nr |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1103 enddef |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1104 endclass |
31639
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1105 END |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1106 v9.CheckScriptSuccess(lines) |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1107 |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1108 lines =<< trim END |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1109 vim9script |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1110 |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1111 interface Some |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1112 static counter: number |
31649
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1113 endinterface |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1114 |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1115 class SomeImpl implements Some implements Some |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1116 static count: number |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1117 endclass |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1118 END |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1119 v9.CheckScriptFailure(lines, 'E1350:') |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1120 |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1121 lines =<< trim END |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1122 vim9script |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1123 |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1124 interface Some |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1125 static counter: number |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1126 endinterface |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1127 |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1128 class SomeImpl implements Some, Some |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1129 static count: number |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1130 endclass |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1131 END |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1132 v9.CheckScriptFailure(lines, 'E1351: Duplicate interface after "implements": Some') |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1133 |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1134 lines =<< trim END |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1135 vim9script |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1136 |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1137 interface Some |
520857d1fda7
patch 9.0.1157: "implements" only handles one interface name
Bram Moolenaar <Bram@vim.org>
parents:
31645
diff
changeset
|
1138 static counter: number |
31639
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1139 def Method(nr: number) |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1140 endinterface |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1141 |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1142 class SomeImpl implements Some |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1143 static count: number |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1144 def Method(nr: number) |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1145 echo nr |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1146 enddef |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1147 endclass |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1148 END |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1149 v9.CheckScriptFailure(lines, 'E1348: Member "counter" of interface "Some" not implemented') |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1150 |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1151 lines =<< trim END |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1152 vim9script |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1153 |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1154 interface Some |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1155 static count: number |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1156 def Methods(nr: number) |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1157 endinterface |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1158 |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1159 class SomeImpl implements Some |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1160 static count: number |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1161 def Method(nr: number) |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1162 echo nr |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1163 enddef |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1164 endclass |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1165 END |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1166 v9.CheckScriptFailure(lines, 'E1349: Function "Methods" of interface "Some" not implemented') |
31754
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1167 |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1168 # Check different order of members in class and interface works. |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1169 lines =<< trim END |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1170 vim9script |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1171 |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1172 interface Result |
31758
85f93e094810
patch 9.0.1211: storing value in interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31754
diff
changeset
|
1173 public this.label: string |
31754
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1174 this.errpos: number |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1175 endinterface |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1176 |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1177 # order of members is opposite of interface |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1178 class Failure implements Result |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1179 this.errpos: number = 42 |
31758
85f93e094810
patch 9.0.1211: storing value in interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31754
diff
changeset
|
1180 public this.label: string = 'label' |
31754
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1181 endclass |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1182 |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1183 def Test() |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1184 var result: Result = Failure.new() |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1185 |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1186 assert_equal('label', result.label) |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1187 assert_equal(42, result.errpos) |
31758
85f93e094810
patch 9.0.1211: storing value in interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31754
diff
changeset
|
1188 |
85f93e094810
patch 9.0.1211: storing value in interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31754
diff
changeset
|
1189 result.label = 'different' |
85f93e094810
patch 9.0.1211: storing value in interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31754
diff
changeset
|
1190 assert_equal('different', result.label) |
85f93e094810
patch 9.0.1211: storing value in interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31754
diff
changeset
|
1191 assert_equal(42, result.errpos) |
31754
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1192 enddef |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1193 |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1194 Test() |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1195 END |
48431422f766
patch 9.0.1209: getting interface member does not always work
Bram Moolenaar <Bram@vim.org>
parents:
31750
diff
changeset
|
1196 v9.CheckScriptSuccess(lines) |
31639
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1197 enddef |
62237ea155d9
patch 9.0.1152: class "implements" argument not implemented
Bram Moolenaar <Bram@vim.org>
parents:
31635
diff
changeset
|
1198 |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1199 def Test_call_interface_method() |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1200 var lines =<< trim END |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1201 vim9script |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1202 interface Base |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1203 def Enter(): void |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1204 endinterface |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1205 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1206 class Child implements Base |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1207 def Enter(): void |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1208 g:result ..= 'child' |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1209 enddef |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1210 endclass |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1211 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1212 def F(obj: Base) |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1213 obj.Enter() |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1214 enddef |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1215 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1216 g:result = '' |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1217 F(Child.new()) |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1218 assert_equal('child', g:result) |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1219 unlet g:result |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1220 END |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1221 v9.CheckScriptSuccess(lines) |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1222 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1223 lines =<< trim END |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1224 vim9script |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1225 class Base |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1226 def Enter(): void |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1227 g:result ..= 'base' |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1228 enddef |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1229 endclass |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1230 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1231 class Child extends Base |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1232 def Enter(): void |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1233 g:result ..= 'child' |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1234 enddef |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1235 endclass |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1236 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1237 def F(obj: Base) |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1238 obj.Enter() |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1239 enddef |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1240 |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1241 g:result = '' |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1242 F(Child.new()) |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1243 assert_equal('child', g:result) |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1244 unlet g:result |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1245 END |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1246 v9.CheckScriptSuccess(lines) |
31865
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1247 |
31896
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1248 # method of interface returns a value |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1249 lines =<< trim END |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1250 vim9script |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1251 interface Base |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1252 def Enter(): string |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1253 endinterface |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1254 |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1255 class Child implements Base |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1256 def Enter(): string |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1257 g:result ..= 'child' |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1258 return "/resource" |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1259 enddef |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1260 endclass |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1261 |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1262 def F(obj: Base) |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1263 var r = obj.Enter() |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1264 g:result ..= r |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1265 enddef |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1266 |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1267 g:result = '' |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1268 F(Child.new()) |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1269 assert_equal('child/resource', g:result) |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1270 unlet g:result |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1271 END |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1272 v9.CheckScriptSuccess(lines) |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1273 |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1274 lines =<< trim END |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1275 vim9script |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1276 class Base |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1277 def Enter(): string |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1278 return null_string |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1279 enddef |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1280 endclass |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1281 |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1282 class Child extends Base |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1283 def Enter(): string |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1284 g:result ..= 'child' |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1285 return "/resource" |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1286 enddef |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1287 endclass |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1288 |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1289 def F(obj: Base) |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1290 var r = obj.Enter() |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1291 g:result ..= r |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1292 enddef |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1293 |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1294 g:result = '' |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1295 F(Child.new()) |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1296 assert_equal('child/resource', g:result) |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1297 unlet g:result |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1298 END |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1299 v9.CheckScriptSuccess(lines) |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1300 |
ecfabcaafc0b
patch 9.0.1280: inssufficient testing for what 9.0.1265 fixes
Bram Moolenaar <Bram@vim.org>
parents:
31865
diff
changeset
|
1301 |
31865
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1302 # No class that implements the interface. |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1303 lines =<< trim END |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1304 vim9script |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1305 |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1306 interface IWithEE |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1307 def Enter(): any |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1308 def Exit(): void |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1309 endinterface |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1310 |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1311 def With1(ee: IWithEE, F: func) |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1312 var r = ee.Enter() |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1313 enddef |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1314 |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1315 defcompile |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1316 END |
86ed5031ff2b
patch 9.0.1265: using an interface method may give a compilation error
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
1317 v9.CheckScriptSuccess(lines) |
31843
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1318 enddef |
ffa11e2757e7
patch 9.0.1254: calling a method on an interface does not work
Bram Moolenaar <Bram@vim.org>
parents:
31835
diff
changeset
|
1319 |
31645
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1320 def Test_class_used_as_type() |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1321 var lines =<< trim END |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1322 vim9script |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1323 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1324 class Point |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1325 this.x = 0 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1326 this.y = 0 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1327 endclass |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1328 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1329 var p: Point |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1330 p = Point.new(2, 33) |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1331 assert_equal(2, p.x) |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1332 assert_equal(33, p.y) |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1333 END |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1334 v9.CheckScriptSuccess(lines) |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1335 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1336 lines =<< trim END |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1337 vim9script |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1338 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1339 interface HasX |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1340 this.x: number |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1341 endinterface |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1342 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1343 class Point implements HasX |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1344 this.x = 0 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1345 this.y = 0 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1346 endclass |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1347 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1348 var p: Point |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1349 p = Point.new(2, 33) |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1350 var hx = p |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1351 assert_equal(2, hx.x) |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1352 END |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1353 v9.CheckScriptSuccess(lines) |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1354 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1355 lines =<< trim END |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1356 vim9script |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1357 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1358 class Point |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1359 this.x = 0 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1360 this.y = 0 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1361 endclass |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1362 |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1363 var p: Point |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1364 p = 'text' |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1365 END |
31698
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1366 v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected object<Point> but got string') |
31645
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1367 enddef |
fc259e8db5bf
patch 9.0.1155: cannot use a class as a type
Bram Moolenaar <Bram@vim.org>
parents:
31639
diff
changeset
|
1368 |
31653
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1369 def Test_class_extends() |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1370 var lines =<< trim END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1371 vim9script |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1372 class Base |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1373 this.one = 1 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1374 def GetOne(): number |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1375 return this.one |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1376 enddef |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1377 endclass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1378 class Child extends Base |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1379 this.two = 2 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1380 def GetTotal(): number |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1381 return this.one + this.two |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1382 enddef |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1383 endclass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1384 var o = Child.new() |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1385 assert_equal(1, o.one) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1386 assert_equal(2, o.two) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1387 assert_equal(1, o.GetOne()) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1388 assert_equal(3, o.GetTotal()) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1389 END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1390 v9.CheckScriptSuccess(lines) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1391 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1392 lines =<< trim END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1393 vim9script |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1394 class Base |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1395 this.one = 1 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1396 endclass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1397 class Child extends Base |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1398 this.two = 2 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1399 endclass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1400 var o = Child.new(3, 44) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1401 assert_equal(3, o.one) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1402 assert_equal(44, o.two) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1403 END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1404 v9.CheckScriptSuccess(lines) |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1405 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1406 lines =<< trim END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1407 vim9script |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1408 class Base |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1409 this.one = 1 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1410 endclass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1411 class Child extends Base extends Base |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1412 this.two = 2 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1413 endclass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1414 END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1415 v9.CheckScriptFailure(lines, 'E1352: Duplicate "extends"') |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1416 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1417 lines =<< trim END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1418 vim9script |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1419 class Child extends BaseClass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1420 this.two = 2 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1421 endclass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1422 END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1423 v9.CheckScriptFailure(lines, 'E1353: Class name not found: BaseClass') |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1424 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1425 lines =<< trim END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1426 vim9script |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1427 var SomeVar = 99 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1428 class Child extends SomeVar |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1429 this.two = 2 |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1430 endclass |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1431 END |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1432 v9.CheckScriptFailure(lines, 'E1354: Cannot extend SomeVar') |
31692
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1433 |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1434 lines =<< trim END |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1435 vim9script |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1436 class Base |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1437 this.name: string |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1438 def ToString(): string |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1439 return this.name |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1440 enddef |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1441 endclass |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1442 |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1443 class Child extends Base |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1444 this.age: number |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1445 def ToString(): string |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1446 return super.ToString() .. ': ' .. this.age |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1447 enddef |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1448 endclass |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1449 |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1450 var o = Child.new('John', 42) |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1451 assert_equal('John: 42', o.ToString()) |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1452 END |
2f1af1b2f82d
patch 9.0.1178: a child class cannot override functions from a base class
Bram Moolenaar <Bram@vim.org>
parents:
31653
diff
changeset
|
1453 v9.CheckScriptSuccess(lines) |
31694
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1454 |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1455 lines =<< trim END |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1456 vim9script |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1457 class Child |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1458 this.age: number |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1459 def ToString(): number |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1460 return this.age |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1461 enddef |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1462 def ToString(): string |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1463 return this.age |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1464 enddef |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1465 endclass |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1466 END |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1467 v9.CheckScriptFailure(lines, 'E1355: Duplicate function: ToString') |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1468 |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1469 lines =<< trim END |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1470 vim9script |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1471 class Child |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1472 this.age: number |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1473 def ToString(): string |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1474 return super .ToString() .. ': ' .. this.age |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1475 enddef |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1476 endclass |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1477 var o = Child.new(42) |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1478 echo o.ToString() |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1479 END |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1480 v9.CheckScriptFailure(lines, 'E1356:') |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1481 |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1482 lines =<< trim END |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1483 vim9script |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1484 class Base |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1485 this.name: string |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1486 def ToString(): string |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1487 return this.name |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1488 enddef |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1489 endclass |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1490 |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1491 var age = 42 |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1492 def ToString(): string |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1493 return super.ToString() .. ': ' .. age |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1494 enddef |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1495 echo ToString() |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1496 END |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1497 v9.CheckScriptFailure(lines, 'E1357:') |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1498 |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1499 lines =<< trim END |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1500 vim9script |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1501 class Child |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1502 this.age: number |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1503 def ToString(): string |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1504 return super.ToString() .. ': ' .. this.age |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1505 enddef |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1506 endclass |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1507 var o = Child.new(42) |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1508 echo o.ToString() |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1509 END |
2f61e308b997
patch 9.0.1179: not all errors around inheritance are tested
Bram Moolenaar <Bram@vim.org>
parents:
31692
diff
changeset
|
1510 v9.CheckScriptFailure(lines, 'E1358:') |
31698
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1511 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1512 lines =<< trim END |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1513 vim9script |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1514 class Base |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1515 this.name: string |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1516 static def ToString(): string |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1517 return 'Base class' |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1518 enddef |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1519 endclass |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1520 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1521 class Child extends Base |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1522 this.age: number |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1523 def ToString(): string |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1524 return Base.ToString() .. ': ' .. this.age |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1525 enddef |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1526 endclass |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1527 |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1528 var o = Child.new('John', 42) |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1529 assert_equal('Base class: 42', o.ToString()) |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1530 END |
9fba3e8bbadc
patch 9.0.1181: class inheritance and typing insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
31694
diff
changeset
|
1531 v9.CheckScriptSuccess(lines) |
31738
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1532 |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1533 lines =<< trim END |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1534 vim9script |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1535 class Base |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1536 this.value = 1 |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1537 def new(init: number) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1538 this.value = number + 1 |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1539 enddef |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1540 endclass |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1541 class Child extends Base |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1542 def new() |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1543 this.new(3) |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1544 enddef |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1545 endclass |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1546 var c = Child.new() |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1547 END |
ad0712119bee
patch 9.0.1201: assignment with operator doesn't work in object method
Bram Moolenaar <Bram@vim.org>
parents:
31732
diff
changeset
|
1548 v9.CheckScriptFailure(lines, 'E1325: Method not found on class "Child": new(') |
31746
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1549 |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1550 # base class with more than one object member |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1551 lines =<< trim END |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1552 vim9script |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1553 |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1554 class Result |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1555 this.success: bool |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1556 this.value: any = null |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1557 endclass |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1558 |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1559 class Success extends Result |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1560 def new(this.value = v:none) |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1561 this.success = true |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1562 enddef |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1563 endclass |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1564 |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1565 var v = Success.new('asdf') |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1566 assert_equal("object of Success {success: true, value: 'asdf'}", string(v)) |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1567 END |
d3d3ed2c09f6
patch 9.0.1205: crash when handling class that extends another class
Bram Moolenaar <Bram@vim.org>
parents:
31744
diff
changeset
|
1568 v9.CheckScriptSuccess(lines) |
31653
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1569 enddef |
ec76f9d2319e
patch 9.0.1159: extends argument for class not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
31649
diff
changeset
|
1570 |
31928
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1571 def Test_using_base_class() |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1572 var lines =<< trim END |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1573 vim9script |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1574 |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1575 class BaseEE |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1576 def Enter(): any |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1577 return null |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1578 enddef |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1579 def Exit(resource: any): void |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1580 enddef |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1581 endclass |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1582 |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1583 class ChildEE extends BaseEE |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1584 def Enter(): any |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1585 return 42 |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1586 enddef |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1587 |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1588 def Exit(resource: number): void |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1589 g:result ..= '/exit' |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1590 enddef |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1591 endclass |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1592 |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1593 def With(ee: BaseEE) |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1594 var r = ee.Enter() |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1595 try |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1596 g:result ..= r |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1597 finally |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1598 g:result ..= '/finally' |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1599 ee.Exit(r) |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1600 endtry |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1601 enddef |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1602 |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1603 g:result = '' |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1604 With(ChildEE.new()) |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1605 assert_equal('42/finally/exit', g:result) |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1606 END |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1607 v9.CheckScriptSuccess(lines) |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1608 unlet g:result |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1609 enddef |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1610 |
7b1cbb43506c
patch 9.0.1296: calling an object method with arguments does not work
Bram Moolenaar <Bram@vim.org>
parents:
31920
diff
changeset
|
1611 |
31706
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1612 def Test_class_import() |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1613 var lines =<< trim END |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1614 vim9script |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1615 export class Animal |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1616 this.kind: string |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1617 this.name: string |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1618 endclass |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1619 END |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1620 writefile(lines, 'Xanimal.vim', 'D') |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1621 |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1622 lines =<< trim END |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1623 vim9script |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1624 import './Xanimal.vim' as animal |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1625 |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1626 var a: animal.Animal |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1627 a = animal.Animal.new('fish', 'Eric') |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1628 assert_equal('fish', a.kind) |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1629 assert_equal('Eric', a.name) |
31708
f6309f6742e5
patch 9.0.1186: imported class does not work when used twice in a line
Bram Moolenaar <Bram@vim.org>
parents:
31706
diff
changeset
|
1630 |
f6309f6742e5
patch 9.0.1186: imported class does not work when used twice in a line
Bram Moolenaar <Bram@vim.org>
parents:
31706
diff
changeset
|
1631 var b: animal.Animal = animal.Animal.new('cat', 'Garfield') |
f6309f6742e5
patch 9.0.1186: imported class does not work when used twice in a line
Bram Moolenaar <Bram@vim.org>
parents:
31706
diff
changeset
|
1632 assert_equal('cat', b.kind) |
f6309f6742e5
patch 9.0.1186: imported class does not work when used twice in a line
Bram Moolenaar <Bram@vim.org>
parents:
31706
diff
changeset
|
1633 assert_equal('Garfield', b.name) |
31706
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1634 END |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1635 v9.CheckScriptSuccess(lines) |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1636 enddef |
824fc05d9571
patch 9.0.1185: using class from imported script not tested
Bram Moolenaar <Bram@vim.org>
parents:
31704
diff
changeset
|
1637 |
31732
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1638 def Test_abstract_class() |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1639 var lines =<< trim END |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1640 vim9script |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1641 abstract class Base |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1642 this.name: string |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1643 endclass |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1644 class Person extends Base |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1645 this.age: number |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1646 endclass |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1647 var p: Base = Person.new('Peter', 42) |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1648 assert_equal('Peter', p.name) |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1649 assert_equal(42, p.age) |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1650 END |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1651 v9.CheckScriptSuccess(lines) |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1652 |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1653 lines =<< trim END |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1654 vim9script |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1655 abstract class Base |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1656 this.name: string |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1657 endclass |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1658 class Person extends Base |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1659 this.age: number |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1660 endclass |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1661 var p = Base.new('Peter') |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1662 END |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1663 v9.CheckScriptFailure(lines, 'E1325: Method not found on class "Base": new(') |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1664 |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1665 lines =<< trim END |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1666 abstract class Base |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1667 this.name: string |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1668 endclass |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1669 END |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1670 v9.CheckScriptFailure(lines, 'E1316:') |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1671 enddef |
ef7a9a7eb197
patch 9.0.1198: abstract class not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
31720
diff
changeset
|
1672 |
31770
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1673 def Test_closure_in_class() |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1674 var lines =<< trim END |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1675 vim9script |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1676 |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1677 class Foo |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1678 this.y: list<string> = ['B'] |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1679 |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1680 def new() |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1681 g:result = filter(['A', 'B'], (_, v) => index(this.y, v) == -1) |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1682 enddef |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1683 endclass |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1684 |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1685 Foo.new() |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1686 assert_equal(['A'], g:result) |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1687 END |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1688 v9.CheckScriptSuccess(lines) |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1689 enddef |
8d2bfc85e3c5
patch 9.0.1217: using an object member in a closure doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
31758
diff
changeset
|
1690 |
31835
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1691 def Test_defer_with_object() |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1692 var lines =<< trim END |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1693 vim9script |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1694 |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1695 class CWithEE |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1696 def Enter() |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1697 g:result ..= "entered/" |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1698 enddef |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1699 def Exit() |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1700 g:result ..= "exited" |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1701 enddef |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1702 endclass |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1703 |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1704 def With(ee: CWithEE, F: func) |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1705 ee.Enter() |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1706 defer ee.Exit() |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1707 F() |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1708 enddef |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1709 |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1710 g:result = '' |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1711 var obj = CWithEE.new() |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1712 obj->With(() => { |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1713 g:result ..= "called/" |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1714 }) |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1715 assert_equal('entered/called/exited', g:result) |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1716 END |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1717 v9.CheckScriptSuccess(lines) |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1718 unlet g:result |
31920
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1719 |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1720 lines =<< trim END |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1721 vim9script |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1722 |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1723 class BaseWithEE |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1724 def Enter() |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1725 g:result ..= "entered-base/" |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1726 enddef |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1727 def Exit() |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1728 g:result ..= "exited-base" |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1729 enddef |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1730 endclass |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1731 |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1732 class CWithEE extends BaseWithEE |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1733 def Enter() |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1734 g:result ..= "entered-child/" |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1735 enddef |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1736 def Exit() |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1737 g:result ..= "exited-child" |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1738 enddef |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1739 endclass |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1740 |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1741 def With(ee: BaseWithEE, F: func) |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1742 ee.Enter() |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1743 defer ee.Exit() |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1744 F() |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1745 enddef |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1746 |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1747 g:result = '' |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1748 var obj = CWithEE.new() |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1749 obj->With(() => { |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1750 g:result ..= "called/" |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1751 }) |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1752 assert_equal('entered-child/called/exited-child', g:result) |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1753 END |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1754 v9.CheckScriptSuccess(lines) |
f1a5e67e9a1b
patch 9.0.1292: :defer may call the wrong method for an object
Bram Moolenaar <Bram@vim.org>
parents:
31896
diff
changeset
|
1755 unlet g:result |
31835
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1756 enddef |
5ce5d78afcc9
patch 9.0.1250: cannot use an object method with :defer
Bram Moolenaar <Bram@vim.org>
parents:
31833
diff
changeset
|
1757 |
31443
9ae3720f9bd9
patch 9.0.1054: object member can't get type from initializer
Bram Moolenaar <Bram@vim.org>
parents:
31441
diff
changeset
|
1758 |
31396
307f68a41b03
patch 9.0.1031: Vim9 class is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |