Mercurial > vim
annotate src/testdir/test_vim9_class.vim @ 33385:b5ad84fdc702 v9.0.1951
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Commit: https://github.com/vim/vim/commit/b90e3bc491c02bd6e4db1a1c1849ce3d21811c43
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Sep 28 23:06:48 2023 +0200
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Problem: Vim9: hard to debug vim9_class errors from CI
Solution: Include the line number in assert_xxx() calls. Include the
entire error message in the tests. Fix the indentation in the
test file. Add tags for new error codes.
closes: #13206
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 28 Sep 2023 23:30:03 +0200 |
parents | 17301c641749 |
children | 016d8f863230 |
rev | line source |
---|---|
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1 " Test Vim9 classes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3 source check.vim |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4 import './vim9.vim' as v9 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6 def Test_class_basic() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
7 # Class supported only in "vim9script" |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
8 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
9 class NotWorking |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
10 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
11 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
12 v9.CheckSourceFailure(lines, 'E1316: Class can only be defined in Vim9 script', 1) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
13 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
14 # First character in a class name should be capitalized. |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
15 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
16 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
17 class notWorking |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
18 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
19 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
20 v9.CheckSourceFailure(lines, 'E1314: Class name must start with an uppercase letter: notWorking', 2) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
21 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
22 # Only alphanumeric characters are supported in a class name |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
23 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
24 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
25 class Not@working |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
26 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
27 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
28 v9.CheckSourceFailure(lines, 'E1315: White space required after name: Not@working', 2) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
29 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
30 # Unsupported keyword (instead of class) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
31 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
32 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
33 abstract noclass Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
34 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
35 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
36 v9.CheckSourceFailure(lines, 'E475: Invalid argument: noclass Something', 2) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
37 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
38 # Only the completed word "class" should be recognized |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
39 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
40 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
41 abstract classy Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
42 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
43 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
44 v9.CheckSourceFailure(lines, 'E475: Invalid argument: classy Something', 2) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
45 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
46 # The complete "endclass" should be specified. |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
47 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
48 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
49 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
50 endcl |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
51 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
52 v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: endcl', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
53 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
54 # Additional words after "endclass" |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
55 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
56 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
57 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
58 endclass school's out |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
59 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
60 v9.CheckSourceFailure(lines, "E488: Trailing characters: school's out", 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
61 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
62 # Additional commands after "endclass" |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
63 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
64 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
65 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
66 endclass | echo 'done' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
67 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
68 v9.CheckSourceFailure(lines, "E488: Trailing characters: | echo 'done'", 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
69 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
70 # Use "this" without any member variable name |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
71 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
72 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
73 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
74 this |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
75 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
76 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
77 v9.CheckSourceFailure(lines, 'E1317: Invalid object variable declaration: this', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
78 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
79 # Use "this." without any member variable name |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
80 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
81 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
82 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
83 this. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
84 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
85 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
86 v9.CheckSourceFailure(lines, 'E1317: Invalid object variable declaration: this.', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
87 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
88 # Space between "this" and ".<variable>" |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
89 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
90 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
91 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
92 this .count |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
93 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
94 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
95 v9.CheckSourceFailure(lines, 'E1317: Invalid object variable declaration: this .count', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
96 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
97 # Space between "this." and the member variable name |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
98 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
99 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
100 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
101 this. count |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
102 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
103 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
104 v9.CheckSourceFailure(lines, 'E1317: Invalid object variable declaration: this. count', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
105 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
106 # Use "that" instead of "this" |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
107 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
108 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
109 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
110 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
111 that.count |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
112 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
113 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
114 v9.CheckSourceFailure(lines, 'E1318: Not a valid command in a class: that.count', 4) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
115 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
116 # Member variable without a type or initialization |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
117 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
118 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
119 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
120 this.count |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
121 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
122 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
123 v9.CheckSourceFailure(lines, 'E1022: Type or initialization required', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
124 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
125 # Use a non-existing member variable in new() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
126 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
127 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
128 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
129 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
130 this.state = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
131 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
132 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
133 var obj = Something.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
134 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
135 v9.CheckSourceFailure(lines, 'E1326: Variable not found on object "Something": state', 1) |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
136 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
137 # Space before ":" in a member variable declaration |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
138 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
139 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
140 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
141 this.count : number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
142 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
143 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
144 v9.CheckSourceFailure(lines, 'E1059: No white space allowed before colon: count : number', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
145 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
146 # No space after ":" in a member variable declaration |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
147 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
148 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
149 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
150 this.count:number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
151 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
152 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
153 v9.CheckSourceFailure(lines, "E1069: White space required after ':'", 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
154 |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
155 # Test for unsupported comment specifier |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
156 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
157 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
158 class Something |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
159 # comment |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
160 #{ |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
161 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
162 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
163 v9.CheckSourceFailure(lines, 'E1170: Cannot use #{ to start a comment', 3) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
164 |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
165 # Test for using class as a bool |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
166 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
167 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
168 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
169 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
170 if A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
171 endif |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
172 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
173 v9.CheckSourceFailure(lines, 'E1319: Using a class as a Number', 4) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
174 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
175 # Test for using object as a bool |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
176 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
177 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
178 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
179 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
180 var a = A.new() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
181 if a |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
182 endif |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
183 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
184 v9.CheckSourceFailure(lines, 'E1320: Using an object as a Number', 5) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
185 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
186 # Test for using class as a float |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
187 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
188 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
189 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
190 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
191 sort([1.1, A], 'f') |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
192 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
193 v9.CheckSourceFailure(lines, 'E1321: Using a class as a Float', 4) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
194 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
195 # Test for using object as a float |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
196 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
197 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
198 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
199 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
200 var a = A.new() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
201 sort([1.1, a], 'f') |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
202 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
203 v9.CheckSourceFailure(lines, 'E1322: Using an object as a Float', 5) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
204 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
205 # Test for using class as a string |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
206 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
207 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
208 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
209 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
210 :exe 'call ' .. A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
211 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
212 v9.CheckSourceFailure(lines, 'E1323: Using a class as a String', 4) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
213 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
214 # Test for using object as a string |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
215 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
216 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
217 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
218 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
219 var a = A.new() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
220 :exe 'call ' .. a |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
221 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
222 v9.CheckSourceFailure(lines, 'E1324: Using an object as a String', 5) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
223 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
224 # Test creating a class with member variables and methods, calling a object |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
225 # method. Check for using type() and typename() with a class and an object. |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
226 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
227 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
228 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
229 class TextPosition |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
230 this.lnum: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
231 this.col: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
232 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
233 # make a nicely formatted string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
234 def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
235 return $'({this.lnum}, {this.col})' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
236 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
237 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
238 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
239 # use the automatically generated new() method |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
240 var pos = TextPosition.new(2, 12) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
241 assert_equal(2, pos.lnum) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
242 assert_equal(12, pos.col) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
243 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
244 # call an object method |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
245 assert_equal('(2, 12)', pos.ToString()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
246 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
247 assert_equal(v:t_class, type(TextPosition)) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
248 assert_equal(v:t_object, type(pos)) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
249 assert_equal('class<TextPosition>', typename(TextPosition)) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
250 assert_equal('object<TextPosition>', typename(pos)) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
251 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
252 v9.CheckSourceSuccess(lines) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
253 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
254 # When referencing object methods, space cannot be used after a "." |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
255 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
256 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
257 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
258 def Foo(): number |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
259 return 10 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
260 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
261 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
262 var a = A.new() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
263 var v = a. Foo() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
264 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
265 v9.CheckSourceFailure(lines, "E1202: No white space allowed after '.'", 8) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
266 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
267 # Using an object without specifying a method or a member variable |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
268 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
269 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
270 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
271 def Foo(): number |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
272 return 10 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
273 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
274 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
275 var a = A.new() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
276 var v = a. |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
277 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
278 v9.CheckSourceFailure(lines, 'E15: Invalid expression: "a."', 8) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
279 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
280 # Error when parsing the arguments of an object method. |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
281 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
282 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
283 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
284 def Foo() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
285 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
286 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
287 var a = A.new() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
288 var v = a.Foo(,) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
289 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
290 v9.CheckSourceFailure(lines, 'E15: Invalid expression: "a.Foo(,)"', 7) |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
291 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
292 # Use a multi-line initialization for a member variable |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
293 lines =<< trim END |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
294 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
295 class A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
296 this.y = { |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
297 X: 1 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
298 } |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
299 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
300 var a = A.new() |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
301 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
302 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
303 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
304 |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
305 " Tests for object/class methods in a class |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
306 def Test_class_def_method() |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
307 # Using the "public" keyword when defining an object method |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
308 var lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
309 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
310 class A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
311 public def Foo() |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
312 enddef |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
313 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
314 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
315 v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "this" or "static"', 3) |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
316 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
317 # Using the "public" keyword when defining a class method |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
318 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
319 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
320 class A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
321 public static def Foo() |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
322 enddef |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
323 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
324 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
325 v9.CheckSourceFailure(lines, 'E1388: Public keyword not supported for a method', 3) |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
326 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
327 # Using the "public" keyword when defining an object private method |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
328 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
329 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
330 class A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
331 public def _Foo() |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
332 enddef |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
333 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
334 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
335 v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "this" or "static"', 3) |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
336 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
337 # Using the "public" keyword when defining a class private method |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
338 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
339 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
340 class A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
341 public static def _Foo() |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
342 enddef |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
343 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
344 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
345 v9.CheckSourceFailure(lines, 'E1388: Public keyword not supported for a method', 3) |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
346 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
347 # Using a "def" keyword without an object method name |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
348 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
349 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
350 class A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
351 def |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
352 enddef |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
353 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
354 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
355 v9.CheckSourceFailure(lines, 'E1318: Not a valid command in a class: def', 3) |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
356 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
357 # Using a "def" keyword without a class method name |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
358 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
359 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
360 class A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
361 static def |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
362 enddef |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
363 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
364 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
365 v9.CheckSourceFailure(lines, 'E1318: Not a valid command in a class: static def', 3) |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
366 enddef |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
367 |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
368 def Test_class_defined_twice() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
369 # class defined twice should fail |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
370 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
371 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
372 class There |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
373 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
374 class There |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
375 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
376 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
377 v9.CheckSourceFailure(lines, 'E1041: Redefining script item: "There"', 4) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
378 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
379 # one class, reload same script twice is OK |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
380 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
381 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
382 class There |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
383 endclass |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
384 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
385 writefile(lines, 'XclassTwice.vim', 'D') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
386 source XclassTwice.vim |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
387 source XclassTwice.vim |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
388 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
389 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
390 def Test_returning_null_object() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
391 # this was causing an internal error |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
392 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
393 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
394 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
395 class BufferList |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
396 def Current(): any |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
397 return null_object |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
398 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
399 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
400 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
401 var buffers = BufferList.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
402 echo buffers.Current() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
403 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
404 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
405 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
406 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
407 def Test_using_null_class() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
408 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
409 @_ = null_class.member |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
410 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
411 v9.CheckDefExecAndScriptFailure(lines, ['E715: Dictionary required', 'E1363: Incomplete type']) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
412 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
413 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
414 def Test_class_interface_wrong_end() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
415 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
416 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
417 abstract class SomeName |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
418 this.member = 'text' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
419 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
420 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
421 v9.CheckSourceFailure(lines, 'E476: Invalid command: endinterface, expected endclass', 4) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
422 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
423 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
424 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
425 export interface AnotherName |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
426 this.member: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
427 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
428 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
429 v9.CheckSourceFailure(lines, 'E476: Invalid command: endclass, expected endinterface', 4) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
430 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
431 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
432 def Test_object_not_set() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
433 # Use an uninitialized object in script context |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
434 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
435 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
436 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
437 class State |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
438 this.value = 'xyz' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
439 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
440 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
441 var state: State |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
442 var db = {'xyz': 789} |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
443 echo db[state.value] |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
444 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
445 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 9) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
446 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
447 # Use an uninitialized object from a def function |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
448 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
449 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
450 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
451 class Class |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
452 this.id: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
453 def Method1() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
454 echo 'Method1' .. this.id |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
455 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
456 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
457 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
458 var obj: Class |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
459 def Func() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
460 obj.Method1() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
461 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
462 Func() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
463 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
464 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 1) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
465 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
466 # Pass an uninitialized object variable to a "new" function and try to call an |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
467 # object method. |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
468 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
469 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
470 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
471 class Background |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
472 this.background = 'dark' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
473 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
474 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
475 class Colorscheme |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
476 this._bg: Background |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
477 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
478 def GetBackground(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
479 return this._bg.background |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
480 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
481 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
482 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
483 var bg: Background # UNINITIALIZED |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
484 echo Colorscheme.new(bg).GetBackground() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
485 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
486 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 1) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
487 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
488 # TODO: this should not give an error but be handled at runtime |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
489 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
490 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
491 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
492 class Class |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
493 this.id: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
494 def Method1() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
495 echo 'Method1' .. this.id |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
496 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
497 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
498 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
499 var obj = null_object |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
500 def Func() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
501 obj.Method1() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
502 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
503 Func() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
504 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
505 v9.CheckSourceFailure(lines, 'E1363: Incomplete type', 1) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
506 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
507 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
508 " Null object assignment and comparison |
33008
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
509 def Test_null_object_assign_compare() |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
510 var lines =<< trim END |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
511 vim9script |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
512 |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
513 var nullo = null_object |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
514 def F(): any |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
515 return nullo |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
516 enddef |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
517 assert_equal('object<Unknown>', typename(F())) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
518 |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
519 var o0 = F() |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
520 assert_true(o0 == null_object) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
521 assert_true(o0 == null) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
522 |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
523 var o1: any = nullo |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
524 assert_true(o1 == null_object) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
525 assert_true(o1 == null) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
526 |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
527 def G() |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
528 var x = null_object |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
529 enddef |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
530 |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
531 class C |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
532 endclass |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
533 var o2: C |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
534 assert_true(o2 == null_object) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
535 assert_true(o2 == null) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
536 |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
537 o2 = null_object |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
538 assert_true(o2 == null) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
539 |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
540 o2 = C.new() |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
541 assert_true(o2 != null) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
542 |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
543 o2 = null_object |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
544 assert_true(o2 == null) |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
545 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
546 v9.CheckSourceSuccess(lines) |
33008
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
547 enddef |
ba1b40b520e8
patch 9.0.1796: Vim9 problems with null_objects
Christian Brabandt <cb@256bit.org>
parents:
32972
diff
changeset
|
548 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
549 " Test for object member initialization and disassembly |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
550 def Test_class_member_initializer() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
551 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
552 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
553 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
554 class TextPosition |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
555 this.lnum: number = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
556 this.col: number = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
557 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
558 # constructor with only the line number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
559 def new(lnum: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
560 this.lnum = lnum |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
561 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
562 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
563 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
564 var pos = TextPosition.new(3) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
565 assert_equal(3, pos.lnum) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
566 assert_equal(1, pos.col) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
567 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
568 var instr = execute('disassemble TextPosition.new') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
569 assert_match('new\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
570 '0 NEW TextPosition size \d\+\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
571 '\d PUSHNR 1\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
572 '\d STORE_THIS 0\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
573 '\d PUSHNR 1\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
574 '\d STORE_THIS 1\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
575 'this.lnum = lnum\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
576 '\d LOAD arg\[-1]\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
577 '\d PUSHNR 0\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
578 '\d LOAD $0\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
579 '\d\+ STOREINDEX object\_s*' .. |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
580 '\d\+ RETURN object.*', |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
581 instr) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
582 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
583 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
584 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
585 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
586 def Test_member_any_used_as_object() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
587 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
588 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
589 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
590 class Inner |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
591 this.value: number = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
592 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
593 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
594 class Outer |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
595 this.inner: any |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
596 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
597 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
598 def F(outer: Outer) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
599 outer.inner.value = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
600 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
601 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
602 var inner_obj = Inner.new(0) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
603 var outer_obj = Outer.new(inner_obj) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
604 F(outer_obj) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
605 assert_equal(1, inner_obj.value) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
606 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
607 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
608 |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
609 # Try modifying a private variable using an "any" object |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
610 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
611 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
612 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
613 class Inner |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
614 this._value: string = '' |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
615 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
616 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
617 class Outer |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
618 this.inner: any |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
619 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
620 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
621 def F(outer: Outer) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
622 outer.inner._value = 'b' |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
623 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
624 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
625 var inner_obj = Inner.new('a') |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
626 var outer_obj = Outer.new(inner_obj) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
627 F(outer_obj) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
628 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
629 v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable: _value', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
630 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
631 # Try modifying a non-existing variable using an "any" object |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
632 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
633 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
634 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
635 class Inner |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
636 this.value: string = '' |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
637 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
638 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
639 class Outer |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
640 this.inner: any |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
641 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
642 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
643 def F(outer: Outer) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
644 outer.inner.someval = 'b' |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
645 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
646 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
647 var inner_obj = Inner.new('a') |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
648 var outer_obj = Outer.new(inner_obj) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
649 F(outer_obj) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
650 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
651 v9.CheckSourceFailure(lines, 'E1326: Variable not found on object "Inner": someval', 1) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
652 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
653 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
654 " Nested assignment to a object variable which is of another class type |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
655 def Test_assignment_nested_type() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
656 var lines =<< trim END |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
657 vim9script |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
658 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
659 class Inner |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
660 public this.value: number = 0 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
661 endclass |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
662 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
663 class Outer |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
664 this.inner: Inner |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
665 endclass |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
666 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
667 def F(outer: Outer) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
668 outer.inner.value = 1 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
669 enddef |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
670 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
671 def Test_assign_to_nested_typed_member() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
672 var inner = Inner.new(0) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
673 var outer = Outer.new(inner) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
674 F(outer) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
675 assert_equal(1, inner.value) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
676 enddef |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
677 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
678 Test_assign_to_nested_typed_member() |
33309
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
679 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
680 var script_inner = Inner.new(0) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
681 var script_outer = Outer.new(script_inner) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
682 script_outer.inner.value = 1 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
683 assert_equal(1, script_inner.value) |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
684 END |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
685 v9.CheckSourceSuccess(lines) |
33309
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
686 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
687 # Assignment where target item is read only in :def |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
688 lines =<< trim END |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
689 vim9script |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
690 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
691 class Inner |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
692 this.value: number = 0 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
693 endclass |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
694 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
695 class Outer |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
696 this.inner: Inner |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
697 endclass |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
698 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
699 def F(outer: Outer) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
700 outer.inner.value = 1 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
701 enddef |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
702 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
703 def Test_assign_to_nested_typed_member() |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
704 var inner = Inner.new(0) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
705 var outer = Outer.new(inner) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
706 F(outer) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
707 assert_equal(1, inner.value) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
708 enddef |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
709 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
710 Test_assign_to_nested_typed_member() |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
711 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
712 v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "Inner" is not writable', 1) |
33309
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
713 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
714 # Assignment where target item is read only script level |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
715 lines =<< trim END |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
716 vim9script |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
717 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
718 class Inner |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
719 this.value: number = 0 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
720 endclass |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
721 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
722 class Outer |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
723 this.inner: Inner |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
724 endclass |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
725 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
726 def F(outer: Outer) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
727 outer.inner.value = 1 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
728 enddef |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
729 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
730 var script_inner = Inner.new(0) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
731 var script_outer = Outer.new(script_inner) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
732 script_outer.inner.value = 1 |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
733 assert_equal(1, script_inner.value) |
ab0ecf1bd6b5
patch 9.0.1920: Vim9: cannot write public var in nested object
Christian Brabandt <cb@256bit.org>
parents:
33297
diff
changeset
|
734 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
735 v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "Inner" is not writable', 17) |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
736 enddef |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
737 |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
738 def Test_assignment_with_operator() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
739 # Use "+=" to assign to a object variable |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
740 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
741 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
742 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
743 class Foo |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
744 public this.x: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
745 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
746 def Add(n: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
747 this.x += n |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
748 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
749 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
750 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
751 var f = Foo.new(3) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
752 f.Add(17) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
753 assert_equal(20, f.x) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
754 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
755 def AddToFoo(obj: Foo) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
756 obj.x += 3 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
757 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
758 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
759 AddToFoo(f) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
760 assert_equal(23, f.x) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
761 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
762 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
763 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
764 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
765 def Test_list_of_objects() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
766 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
767 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
768 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
769 class Foo |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
770 def Add() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
771 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
772 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
773 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
774 def ProcessList(fooList: list<Foo>) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
775 for foo in fooList |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
776 foo.Add() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
777 endfor |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
778 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
779 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
780 var l: list<Foo> = [Foo.new()] |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
781 ProcessList(l) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
782 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
783 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
784 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
785 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
786 def Test_expr_after_using_object() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
787 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
788 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
789 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
790 class Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
791 this.label: string = '' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
792 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
793 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
794 def Foo(): Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
795 var v = Something.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
796 echo 'in Foo(): ' .. typename(v) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
797 return v |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
798 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
799 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
800 Foo() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
801 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
802 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
803 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
804 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
805 def Test_class_default_new() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
806 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
807 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
808 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
809 class TextPosition |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
810 this.lnum: number = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
811 this.col: number = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
812 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
813 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
814 var pos = TextPosition.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
815 assert_equal(1, pos.lnum) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
816 assert_equal(1, pos.col) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
817 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
818 pos = TextPosition.new(v:none, v:none) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
819 assert_equal(1, pos.lnum) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
820 assert_equal(1, pos.col) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
821 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
822 pos = TextPosition.new(3, 22) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
823 assert_equal(3, pos.lnum) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
824 assert_equal(22, pos.col) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
825 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
826 pos = TextPosition.new(v:none, 33) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
827 assert_equal(1, pos.lnum) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
828 assert_equal(33, pos.col) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
829 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
830 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
831 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
832 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
833 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
834 class Person |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
835 this.name: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
836 this.age: number = 42 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
837 this.education: string = "unknown" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
838 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
839 def new(this.name, this.age = v:none, this.education = v:none) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
840 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
841 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
842 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
843 var piet = Person.new("Piet") |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
844 assert_equal("Piet", piet.name) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
845 assert_equal(42, piet.age) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
846 assert_equal("unknown", piet.education) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
847 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
848 var chris = Person.new("Chris", 4, "none") |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
849 assert_equal("Chris", chris.name) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
850 assert_equal(4, chris.age) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
851 assert_equal("none", chris.education) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
852 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
853 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
854 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
855 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
856 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
857 class Person |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
858 this.name: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
859 this.age: number = 42 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
860 this.education: string = "unknown" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
861 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
862 def new(this.name, this.age = v:none, this.education = v:none) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
863 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
864 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
865 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
866 var missing = Person.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
867 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
868 v9.CheckSourceFailure(lines, 'E119: Not enough arguments for function: new', 11) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
869 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
870 # Using a specific value to initialize an instance variable in the new() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
871 # method. |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
872 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
873 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
874 class A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
875 this.val: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
876 def new(this.val = 'a') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
877 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
878 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
879 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
880 v9.CheckSourceFailure(lines, "E1328: Constructor default value must be v:none: = 'a'", 4) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
881 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
882 |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32812
diff
changeset
|
883 def Test_class_new_with_object_member() |
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32812
diff
changeset
|
884 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
885 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
886 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
887 class C |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
888 this.str: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
889 this.num: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
890 def new(this.str, this.num) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
891 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
892 def newVals(this.str, this.num) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
893 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
894 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
895 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
896 def Check() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
897 try |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
898 var c = C.new('cats', 2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
899 assert_equal('cats', c.str) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
900 assert_equal(2, c.num) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
901 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
902 c = C.newVals('dogs', 4) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
903 assert_equal('dogs', c.str) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
904 assert_equal(4, c.num) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
905 catch |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
906 assert_report($'Unexpected exception was caught: {v:exception}') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
907 endtry |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
908 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
909 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
910 Check() |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32812
diff
changeset
|
911 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
912 v9.CheckSourceSuccess(lines) |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32812
diff
changeset
|
913 |
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32812
diff
changeset
|
914 lines =<< trim END |
33379
7c9124711f99
patch 9.0.1948: Vim9: object variable "this." should only be used in constructor
Christian Brabandt <cb@256bit.org>
parents:
33372
diff
changeset
|
915 vim9script |
7c9124711f99
patch 9.0.1948: Vim9: object variable "this." should only be used in constructor
Christian Brabandt <cb@256bit.org>
parents:
33372
diff
changeset
|
916 |
7c9124711f99
patch 9.0.1948: Vim9: object variable "this." should only be used in constructor
Christian Brabandt <cb@256bit.org>
parents:
33372
diff
changeset
|
917 class C |
7c9124711f99
patch 9.0.1948: Vim9: object variable "this." should only be used in constructor
Christian Brabandt <cb@256bit.org>
parents:
33372
diff
changeset
|
918 this.str: string |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
919 this.num: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
920 def new(this.str, this.num) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
921 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
922 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
923 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
924 def Check() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
925 try |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
926 var c = C.new(1, 2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
927 catch |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
928 assert_report($'Unexpected exception was caught: {v:exception}') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
929 endtry |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
930 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
931 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
932 Check() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
933 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
934 v9.CheckSourceFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got number', 2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
935 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
936 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
937 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
938 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
939 class C |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
940 this.str: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
941 this.num: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
942 def newVals(this.str, this.num) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
943 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
944 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
945 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
946 def Check() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
947 try |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
948 var c = C.newVals('dogs', 'apes') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
949 catch |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
950 assert_report($'Unexpected exception was caught: {v:exception}') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
951 endtry |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
952 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
953 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
954 Check() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
955 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
956 v9.CheckSourceFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got string', 2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
957 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
958 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
959 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
960 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
961 class C |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
962 this.str: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
963 def new(str: any) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
964 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
965 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
966 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
967 def Check() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
968 try |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
969 var c = C.new(1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
970 catch |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
971 assert_report($'Unexpected exception was caught: {v:exception}') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
972 endtry |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
973 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
974 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
975 Check() |
33326
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33322
diff
changeset
|
976 END |
4e531adb3fac
patch 9.0.1928: Vim9: constructor type checking bug
Christian Brabandt <cb@256bit.org>
parents:
33322
diff
changeset
|
977 v9.CheckSourceSuccess(lines) |
32822
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32812
diff
changeset
|
978 enddef |
b3a42579bb3f
patch 9.0.1724: vim9class constructor argument type checking bug
Christian Brabandt <cb@256bit.org>
parents:
32812
diff
changeset
|
979 |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
980 def Test_class_object_member_inits() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
981 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
982 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
983 class TextPosition |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
984 this.lnum: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
985 this.col = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
986 this.addcol: number = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
987 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
988 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
989 var pos = TextPosition.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
990 assert_equal(0, pos.lnum) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
991 assert_equal(1, pos.col) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
992 assert_equal(2, pos.addcol) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
993 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
994 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
995 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
996 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
997 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
998 class TextPosition |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
999 this.lnum |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1000 this.col = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1001 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1002 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1003 v9.CheckSourceFailure(lines, 'E1022: Type or initialization required', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1004 |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
1005 # If the type is not specified for a member, then it should be set during |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
1006 # object creation and not when defining the class. |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1007 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1008 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1009 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1010 var init_count = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1011 def Init(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1012 init_count += 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1013 return 'foo' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1014 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1015 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1016 class A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1017 this.str1 = Init() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1018 this.str2: string = Init() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1019 this.col = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1020 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1021 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1022 assert_equal(init_count, 0) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1023 var a = A.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1024 assert_equal(init_count, 2) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1025 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1026 v9.CheckSourceSuccess(lines) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1027 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1028 # Test for initializing an object member with an unknown variable/type |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1029 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1030 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1031 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1032 this.value = init_val |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1033 endclass |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
1034 var a = A.new() |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1035 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1036 v9.CheckSourceFailure(lines, 'E1001: Variable not found: init_val', 1) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1037 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1038 # Test for initializing an object member with an special type |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1039 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1040 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1041 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1042 this.value: void |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1043 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1044 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1045 v9.CheckSourceFailure(lines, 'E1330: Invalid type for object variable: void', 3) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1046 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1047 |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1048 " Test for instance variable access |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1049 def Test_instance_variable_access() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1050 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1051 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1052 class Triple |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1053 this._one = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1054 this.two = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1055 public this.three = 3 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1056 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1057 def GetOne(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1058 return this._one |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1059 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1060 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1061 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1062 var trip = Triple.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1063 assert_equal(1, trip.GetOne()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1064 assert_equal(2, trip.two) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1065 assert_equal(3, trip.three) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1066 assert_fails('echo trip._one', 'E1333: Cannot access private variable: _one') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1067 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1068 assert_fails('trip._one = 11', 'E1333: Cannot access private variable: _one') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1069 assert_fails('trip.two = 22', 'E1335: Variable "two" in class "Triple" is not writable') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1070 trip.three = 33 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1071 assert_equal(33, trip.three) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1072 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1073 assert_fails('trip.four = 4', 'E1326: Variable not found on object "Triple": four') |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1074 END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1075 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1076 |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1077 # Test for a public member variable name beginning with an underscore |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1078 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1079 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1080 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1081 public this._val = 10 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1082 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1083 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1084 v9.CheckSourceFailure(lines, 'E1332: Public variable name cannot start with underscore: public this._val = 10', 3) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1085 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1086 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1087 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1088 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1089 class MyCar |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1090 this.make: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1091 this.age = 5 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1092 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1093 def new(make_arg: string) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1094 this.make = make_arg |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1095 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1096 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1097 def GetMake(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1098 return $"make = {this.make}" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1099 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1100 def GetAge(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1101 return this.age |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1102 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1103 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1104 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1105 var c = MyCar.new("abc") |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1106 assert_equal('make = abc', c.GetMake()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1107 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1108 c = MyCar.new("def") |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1109 assert_equal('make = def', c.GetMake()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1110 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1111 var c2 = MyCar.new("123") |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1112 assert_equal('make = 123', c2.GetMake()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1113 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1114 def CheckCar() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1115 assert_equal("make = def", c.GetMake()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1116 assert_equal(5, c.GetAge()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1117 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1118 CheckCar() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1119 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1120 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1121 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1122 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1123 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1124 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1125 class MyCar |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1126 this.make: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1127 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1128 def new(make_arg: string) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1129 this.make = make_arg |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1130 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1131 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1132 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1133 var c = MyCar.new("abc") |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1134 var c = MyCar.new("def") |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1135 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1136 v9.CheckSourceFailure(lines, 'E1041: Redefining script item: "c"', 12) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1137 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1138 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1139 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1140 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1141 class Foo |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1142 this.x: list<number> = [] |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1143 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1144 def Add(n: number): any |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1145 this.x->add(n) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1146 return this |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1147 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1148 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1149 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1150 echo Foo.new().Add(1).Add(2).x |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1151 echo Foo.new().Add(1).Add(2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1152 .x |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1153 echo Foo.new().Add(1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1154 .Add(2).x |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1155 echo Foo.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1156 .Add(1).Add(2).x |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1157 echo Foo.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1158 .Add(1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1159 .Add(2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1160 .x |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1161 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1162 v9.CheckSourceSuccess(lines) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1163 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1164 # Test for "public" cannot be abbreviated |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1165 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1166 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1167 class Something |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1168 pub this.val = 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1169 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1170 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1171 v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: pub this.val = 1', 3) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1172 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1173 # Test for "public" keyword must be followed by "this" or "static". |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1174 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1175 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1176 class Something |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1177 public val = 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1178 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1179 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1180 v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "this" or "static"', 3) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1181 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1182 # Modify a instance variable using the class name in the script context |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1183 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1184 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1185 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1186 public this.val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1187 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1188 A.val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1189 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1190 v9.CheckSourceFailure(lines, 'E1376: Object variable "val" accessible only using class "A" object', 5) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1191 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1192 # Read a instance variable using the class name in the script context |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1193 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1194 vim9script |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1195 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1196 public this.val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1197 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1198 var i = A.val |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1199 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1200 v9.CheckSourceFailure(lines, 'E1376: Object variable "val" accessible only using class "A" object', 5) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1201 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1202 # Modify a instance variable using the class name in a def function |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
1203 lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
1204 vim9script |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1205 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1206 public this.val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1207 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1208 def T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1209 A.val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1210 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1211 T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1212 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1213 v9.CheckSourceFailure(lines, 'E1376: Object variable "val" accessible only using class "A" object', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1214 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1215 # Read a instance variable using the class name in a def function |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1216 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1217 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1218 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1219 public this.val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1220 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1221 def T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1222 var i = A.val |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1223 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1224 T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1225 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1226 v9.CheckSourceFailure(lines, 'E1376: Object variable "val" accessible only using class "A" object', 1) |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
1227 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
1228 # Access from child class extending a class: |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
1229 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1230 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1231 class A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1232 this.ro_obj_var = 10 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1233 public this.rw_obj_var = 20 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1234 this._priv_obj_var = 30 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1235 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1236 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1237 class B extends A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1238 def Foo() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1239 var x: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1240 x = this.ro_obj_var |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1241 this.ro_obj_var = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1242 x = this.rw_obj_var |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1243 this.rw_obj_var = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1244 x = this._priv_obj_var |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1245 this._priv_obj_var = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1246 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1247 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1248 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1249 var b = B.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1250 b.Foo() |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1251 END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1252 v9.CheckSourceSuccess(lines) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1253 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1254 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1255 " Test for class variable access |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1256 def Test_class_variable_access() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1257 # Test for "static" cannot be abbreviated |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1258 var lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1259 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1260 class Something |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1261 stat this.val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1262 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1263 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1264 v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: stat this.val = 1', 3) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1265 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1266 # Test for "static" cannot be followed by "this". |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1267 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1268 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1269 class Something |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1270 static this.val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1271 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1272 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1273 v9.CheckSourceFailure(lines, 'E1368: Static cannot be followed by "this" in a variable name', 3) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1274 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1275 # Test for "static" cannot be followed by "public". |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1276 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1277 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1278 class Something |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1279 static public val = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1280 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1281 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1282 v9.CheckSourceFailure(lines, 'E1022: Type or initialization required', 3) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1283 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1284 # A readonly class variable cannot be modified from a child class |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1285 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1286 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1287 class A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1288 static ro_class_var = 40 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1289 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1290 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1291 class B extends A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1292 def Foo() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1293 A.ro_class_var = 50 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1294 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1295 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1296 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1297 var b = B.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1298 b.Foo() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1299 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1300 v9.CheckSourceFailure(lines, 'E1335: Variable "ro_class_var" in class "A" is not writable', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1301 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1302 # A private class variable cannot be accessed from a child class |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1303 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1304 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1305 class A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1306 static _priv_class_var = 60 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1307 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1308 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1309 class B extends A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1310 def Foo() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1311 var i = A._priv_class_var |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1312 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1313 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1314 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1315 var b = B.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1316 b.Foo() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1317 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1318 v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable: _priv_class_var', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1319 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1320 # A private class variable cannot be modified from a child class |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1321 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1322 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1323 class A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1324 static _priv_class_var = 60 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1325 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1326 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1327 class B extends A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1328 def Foo() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1329 A._priv_class_var = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1330 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1331 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1332 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1333 var b = B.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1334 b.Foo() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1335 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1336 v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable: _priv_class_var', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1337 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1338 # Access from child class extending a class and from script context |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1339 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1340 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1341 class A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1342 static ro_class_var = 10 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1343 public static rw_class_var = 20 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1344 static _priv_class_var = 30 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1345 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1346 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1347 class B extends A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1348 def Foo() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1349 var x: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1350 x = A.ro_class_var |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1351 assert_equal(10, x) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1352 x = A.rw_class_var |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1353 assert_equal(25, x) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1354 A.rw_class_var = 20 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1355 assert_equal(20, A.rw_class_var) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1356 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1357 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1358 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1359 assert_equal(10, A.ro_class_var) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1360 assert_equal(20, A.rw_class_var) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1361 A.rw_class_var = 25 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1362 assert_equal(25, A.rw_class_var) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1363 var b = B.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1364 b.Foo() |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1365 END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1366 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1367 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1368 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1369 def Test_class_object_compare() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1370 var class_lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1371 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1372 class Item |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1373 this.nr = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1374 this.name = 'xx' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1375 endclass |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1376 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1377 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1378 # used at the script level and in a compiled function |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1379 var test_lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1380 var i1 = Item.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1381 assert_equal(i1, i1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1382 assert_true(i1 is i1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1383 var i2 = Item.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1384 assert_equal(i1, i2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1385 assert_false(i1 is i2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1386 var i3 = Item.new(0, 'xx') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1387 assert_equal(i1, i3) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1388 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1389 var io1 = Item.new(1, 'xx') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1390 assert_notequal(i1, io1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1391 var io2 = Item.new(0, 'yy') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1392 assert_notequal(i1, io2) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1393 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1394 |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1395 v9.CheckSourceSuccess(class_lines + test_lines) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1396 v9.CheckSourceSuccess( |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1397 class_lines + ['def Test()'] + test_lines + ['enddef', 'Test()']) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1398 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1399 for op in ['>', '>=', '<', '<=', '=~', '!~'] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1400 var op_lines = [ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1401 'var i1 = Item.new()', |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1402 'var i2 = Item.new()', |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1403 'echo i1 ' .. op .. ' i2', |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1404 ] |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1405 v9.CheckSourceFailure(class_lines + op_lines, 'E1153: Invalid operation for object', 8) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1406 v9.CheckSourceFailure(class_lines |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1407 + ['def Test()'] + op_lines + ['enddef', 'Test()'], 'E1153: Invalid operation for object') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1408 endfor |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1409 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1410 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1411 def Test_object_type() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1412 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1413 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1414 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1415 class One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1416 this.one = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1417 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1418 class Two |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1419 this.two = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1420 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1421 class TwoMore extends Two |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1422 this.more = 9 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1423 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1424 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1425 var o: One = One.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1426 var t: Two = Two.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1427 var m: TwoMore = TwoMore.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1428 var tm: Two = TwoMore.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1429 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1430 t = m |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1431 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1432 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1433 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1434 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1435 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1436 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1437 class One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1438 this.one = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1439 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1440 class Two |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1441 this.two = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1442 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1443 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1444 var o: One = Two.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1445 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1446 v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected object<One> but got object<Two>', 10) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1447 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1448 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1449 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1450 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1451 interface One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1452 def GetMember(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1453 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1454 class Two implements One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1455 this.one = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1456 def GetMember(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1457 return this.one |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1458 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1459 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1460 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1461 var o: One = Two.new(5) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1462 assert_equal(5, o.GetMember()) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1463 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1464 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1465 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1466 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1467 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1468 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1469 class Num |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1470 this.n: number = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1471 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1472 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1473 def Ref(name: string): func(Num): Num |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1474 return (arg: Num): Num => { |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1475 return eval(name)(arg) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1476 } |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1477 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1478 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1479 const Fn = Ref('Double') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1480 var Double = (m: Num): Num => Num.new(m.n * 2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1481 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1482 echo Fn(Num.new(4)) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1483 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1484 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1485 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1486 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1487 def Test_class_member() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1488 # check access rules |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1489 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1490 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1491 class TextPos |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1492 this.lnum = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1493 this.col = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1494 static counter = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1495 static _secret = 7 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1496 public static anybody = 42 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1497 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1498 static def AddToCounter(nr: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1499 counter += nr |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1500 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1501 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1502 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1503 assert_equal(0, TextPos.counter) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1504 TextPos.AddToCounter(3) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1505 assert_equal(3, TextPos.counter) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1506 assert_fails('echo TextPos.noSuchMember', 'E1337: Class variable "noSuchMember" not found in class "TextPos"') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1507 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1508 def GetCounter(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1509 return TextPos.counter |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1510 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1511 assert_equal(3, GetCounter()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1512 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1513 assert_fails('TextPos.noSuchMember = 2', 'E1337: Class variable "noSuchMember" not found in class "TextPos"') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1514 assert_fails('TextPos.counter = 5', 'E1335: Variable "counter" in class "TextPos" is not writable') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1515 assert_fails('TextPos.counter += 5', 'E1335: Variable "counter" in class "TextPos" is not writable') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1516 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1517 assert_fails('echo TextPos._secret', 'E1333: Cannot access private variable: _secret') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1518 assert_fails('TextPos._secret = 8', 'E1333: Cannot access private variable: _secret') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1519 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1520 assert_equal(42, TextPos.anybody) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1521 TextPos.anybody = 12 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1522 assert_equal(12, TextPos.anybody) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1523 TextPos.anybody += 5 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1524 assert_equal(17, TextPos.anybody) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1525 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1526 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1527 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1528 # example in the help |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1529 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1530 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1531 class OtherThing |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1532 this.size: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1533 static totalSize: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1534 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1535 def new(this.size) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1536 totalSize += this.size |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1537 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1538 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1539 assert_equal(0, OtherThing.totalSize) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1540 var to3 = OtherThing.new(3) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1541 assert_equal(3, OtherThing.totalSize) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1542 var to7 = OtherThing.new(7) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1543 assert_equal(10, OtherThing.totalSize) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1544 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1545 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1546 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1547 # using static class member twice |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1548 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1549 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1550 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1551 class HTML |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1552 static author: string = 'John Doe' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1553 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1554 static def MacroSubstitute(s: string): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1555 return substitute(s, '{{author}}', author, 'gi') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1556 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1557 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1558 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1559 assert_equal('some text', HTML.MacroSubstitute('some text')) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1560 assert_equal('some text', HTML.MacroSubstitute('some text')) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1561 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1562 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1563 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1564 # access private member in lambda |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1565 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1566 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1567 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1568 class Foo |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1569 this._x: number = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1570 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1571 def Add(n: number): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1572 const F = (): number => this._x + n |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1573 return F() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1574 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1575 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1576 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1577 var foo = Foo.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1578 assert_equal(5, foo.Add(5)) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1579 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1580 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1581 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1582 # access private member in lambda body |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1583 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1584 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1585 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1586 class Foo |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1587 this._x: number = 6 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1588 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1589 def Add(n: number): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1590 var Lam = () => { |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1591 this._x = this._x + n |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1592 } |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1593 Lam() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1594 return this._x |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1595 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1596 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1597 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1598 var foo = Foo.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1599 assert_equal(13, foo.Add(7)) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1600 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1601 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1602 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1603 # check shadowing |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1604 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1605 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1606 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1607 class Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1608 static count = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1609 def Method(count: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1610 echo count |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1611 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1612 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1613 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1614 var s = Some.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1615 s.Method(7) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1616 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1617 v9.CheckSourceFailure(lines, 'E1340: Argument already declared in the class: count', 5) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1618 |
33297
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
1619 # Use a local variable in a method with the same name as a class variable |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1620 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1621 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1622 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1623 class Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1624 static count = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1625 def Method(arg: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1626 var count = 3 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1627 echo arg count |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1628 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1629 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1630 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1631 var s = Some.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1632 s.Method(7) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1633 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1634 v9.CheckSourceFailure(lines, 'E1341: Variable already declared in the class: count', 1) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1635 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1636 # Test for using an invalid type for a member variable |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1637 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1638 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1639 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1640 this.val: xxx |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1641 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1642 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1643 v9.CheckSourceFailure(lines, 'E1010: Type not recognized: xxx', 3) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1644 |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1645 # Test for setting a member on a null object |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1646 lines =<< trim END |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1647 vim9script |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1648 class A |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1649 public this.val: string |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1650 endclass |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1651 |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1652 def F() |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1653 var obj: A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1654 obj.val = "" |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1655 enddef |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1656 F() |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1657 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1658 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 2) |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1659 |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1660 # Test for accessing a member on a null object |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1661 lines =<< trim END |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1662 vim9script |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1663 class A |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1664 this.val: string |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1665 endclass |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1666 |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1667 def F() |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1668 var obj: A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1669 echo obj.val |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1670 enddef |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1671 F() |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1672 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1673 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 2) |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1674 |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1675 # Test for setting a member on a null object, at script level |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1676 lines =<< trim END |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1677 vim9script |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1678 class A |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1679 public this.val: string |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1680 endclass |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1681 |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1682 var obj: A |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1683 obj.val = "" |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1684 END |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1685 # FIXME(in source): this should give E1360 as well! |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1686 v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected object<A> but got string', 7) |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1687 |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1688 # Test for accessing a member on a null object, at script level |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1689 lines =<< trim END |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1690 vim9script |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1691 class A |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1692 this.val: string |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1693 endclass |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1694 |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1695 var obj: A |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1696 echo obj.val |
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1697 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1698 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 7) |
33090
461541d860ac
patch 9.0.1830: Vim9: crash when accessing a null object
Christian Brabandt <cb@256bit.org>
parents:
33088
diff
changeset
|
1699 |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1700 # Test for no space before or after the '=' when initializing a member |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1701 # variable |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1702 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1703 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1704 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1705 this.val: number= 10 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1706 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1707 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1708 v9.CheckSourceFailure(lines, "E1004: White space required before and after '='", 3) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1709 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1710 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1711 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1712 this.val: number =10 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1713 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1714 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1715 v9.CheckSourceFailure(lines, "E1004: White space required before and after '='", 3) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1716 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1717 # Access a non-existing member |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1718 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1719 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1720 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1721 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1722 var a = A.new() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1723 var v = a.bar |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1724 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1725 v9.CheckSourceFailure(lines, 'E1326: Variable not found on object "A": bar', 5) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1726 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1727 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1728 func Test_class_garbagecollect() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1729 let lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1730 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1731 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1732 class Point |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1733 this.p = [2, 3] |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1734 static pl = ['a', 'b'] |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1735 static pd = {a: 'a', b: 'b'} |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1736 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1737 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1738 echo Point.pl Point.pd |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1739 call test_garbagecollect_now() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1740 echo Point.pl Point.pd |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1741 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1742 call v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1743 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1744 let lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1745 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1746 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1747 interface View |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1748 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1749 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1750 class Widget |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1751 this.view: View |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1752 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1753 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1754 class MyView implements View |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1755 this.widget: Widget |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1756 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1757 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1758 # this will result in a circular reference to this object |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1759 this.widget = Widget.new(this) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1760 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1761 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1762 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1763 var view = MyView.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1764 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1765 # overwrite "view", will be garbage-collected next |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1766 view = MyView.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1767 test_garbagecollect_now() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1768 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1769 call v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1770 endfunc |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1771 |
33167
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1772 " Test interface garbage collection |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1773 func Test_interface_garbagecollect() |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1774 let lines =<< trim END |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1775 vim9script |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1776 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1777 interface I |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1778 this.ro_obj_var: number |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
1779 |
33167
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1780 def ObjFoo(): number |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1781 endinterface |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1782 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1783 class A implements I |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1784 static ro_class_var: number = 10 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1785 public static rw_class_var: number = 20 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1786 static _priv_class_var: number = 30 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1787 this.ro_obj_var: number = 40 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1788 this._priv_obj_var: number = 60 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1789 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1790 static def _ClassBar(): number |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1791 return _priv_class_var |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1792 enddef |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1793 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1794 static def ClassFoo(): number |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1795 return ro_class_var + rw_class_var + A._ClassBar() |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1796 enddef |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1797 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1798 def _ObjBar(): number |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1799 return this._priv_obj_var |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1800 enddef |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1801 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1802 def ObjFoo(): number |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
1803 return this.ro_obj_var + this._ObjBar() |
33167
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1804 enddef |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1805 endclass |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1806 |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1807 assert_equal(60, A.ClassFoo()) |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1808 var o = A.new() |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
1809 assert_equal(100, o.ObjFoo()) |
33167
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1810 test_garbagecollect_now() |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1811 assert_equal(60, A.ClassFoo()) |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
1812 assert_equal(100, o.ObjFoo()) |
33167
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1813 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1814 call v9.CheckSourceSuccess(lines) |
33167
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1815 endfunc |
13258b342d38
patch 9.0.1865: Vim9: garbage collection may cause crash
Christian Brabandt <cb@256bit.org>
parents:
33160
diff
changeset
|
1816 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1817 def Test_class_method() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1818 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1819 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1820 class Value |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1821 this.value = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1822 static objects = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1823 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1824 def new(v: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1825 this.value = v |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1826 ++objects |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1827 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1828 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1829 static def GetCount(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1830 return objects |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1831 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1832 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1833 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1834 assert_equal(0, Value.GetCount()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1835 var v1 = Value.new(2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1836 assert_equal(1, Value.GetCount()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1837 var v2 = Value.new(7) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1838 assert_equal(2, Value.GetCount()) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1839 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1840 v9.CheckSourceSuccess(lines) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1841 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1842 # Test for cleaning up after a class definition failure when using class |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1843 # functions. |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1844 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1845 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1846 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1847 static def Foo() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1848 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1849 aaa |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1850 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1851 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1852 v9.CheckSourceFailure(lines, 'E1318: Not a valid command in a class: aaa', 5) |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1853 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1854 # Test for calling a class method from another class method without the class |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1855 # name prefix. |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1856 lines =<< trim END |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1857 vim9script |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1858 class A |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1859 static myList: list<number> = [1] |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1860 static def Foo(n: number) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1861 myList->add(n) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1862 enddef |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1863 static def Bar() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1864 Foo(2) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1865 enddef |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1866 def Baz() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1867 Foo(3) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1868 enddef |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1869 endclass |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1870 A.Bar() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1871 var a = A.new() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1872 a.Baz() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1873 assert_equal([1, 2, 3], A.myList) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1874 END |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
1875 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1876 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1877 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1878 def Test_class_defcompile() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1879 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1880 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1881 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1882 class C |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1883 def Fo(i: number): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1884 return i |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1885 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1886 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1887 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1888 defcompile C.Fo |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1889 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1890 v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected string but got number', 1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1891 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1892 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1893 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1894 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1895 class C |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1896 static def Fc(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1897 return 'x' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1898 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1899 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1900 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1901 defcompile C.Fc |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1902 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1903 v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected number but got string', 1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1904 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1905 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1906 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1907 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1908 class C |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1909 static def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1910 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1911 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1912 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1913 defcompile C.new |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1914 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1915 v9.CheckSourceFailure(lines, 'E1370: Cannot define a "new" method as static', 5) |
33068
d42927c6e556
patch 9.0.1821: Vim9 constructors are always static
Christian Brabandt <cb@256bit.org>
parents:
33047
diff
changeset
|
1916 |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1917 # Trying to compile a function using a non-existing class variable |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1918 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1919 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1920 defcompile x.Foo() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1921 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1922 v9.CheckSourceFailure(lines, 'E475: Invalid argument: x.Foo()', 2) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1923 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1924 # Trying to compile a function using a variable which is not a class |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1925 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1926 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1927 var x: number |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1928 defcompile x.Foo() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1929 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1930 v9.CheckSourceFailure(lines, 'E475: Invalid argument: x.Foo()', 3) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1931 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1932 # Trying to compile a function without specifying the name |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1933 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1934 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1935 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1936 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1937 defcompile A. |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1938 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1939 v9.CheckSourceFailure(lines, 'E475: Invalid argument: A.', 4) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1940 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1941 # Trying to compile a non-existing class object member function |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1942 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1943 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1944 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1945 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1946 var a = A.new() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1947 defcompile a.Foo() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
1948 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1949 v9.CheckSourceFailureList(lines, ['E1326: Variable not found on object "A": Foo', 'E475: Invalid argument: a.Foo()']) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1950 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1951 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1952 def Test_class_object_to_string() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1953 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1954 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1955 class TextPosition |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1956 this.lnum = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1957 this.col = 22 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1958 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1959 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1960 assert_equal("class TextPosition", string(TextPosition)) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1961 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1962 var pos = TextPosition.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1963 assert_equal("object of TextPosition {lnum: 1, col: 22}", string(pos)) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1964 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1965 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1966 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1967 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1968 def Test_interface_basics() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1969 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1970 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1971 interface Something |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1972 this.ro_var: list<number> |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1973 def GetCount(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1974 endinterface |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1975 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1976 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1977 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1978 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1979 interface SomethingWrong |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1980 static count = 7 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1981 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1982 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1983 v9.CheckSourceFailure(lines, 'E1342: Interface can only be defined in Vim9 script', 1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1984 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1985 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1986 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1987 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1988 interface Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1989 this.value: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1990 def Method(value: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1991 endinterface |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1992 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1993 # The argument name and the object member name are the same, but this is not a |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1994 # problem because object members are always accessed with the "this." prefix. |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
1995 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1996 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1997 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1998 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
1999 interface somethingWrong |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2000 static count = 7 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2001 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2002 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2003 v9.CheckSourceFailure(lines, 'E1343: Interface name must start with an uppercase letter: somethingWrong', 2) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2004 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2005 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2006 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2007 interface SomethingWrong |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2008 this.value: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2009 this.count = 7 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2010 def GetCount(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2011 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2012 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2013 v9.CheckSourceFailure(lines, 'E1344: Cannot initialize a variable in an interface', 4) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2014 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2015 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2016 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2017 interface SomethingWrong |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2018 this.value: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2019 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2020 def GetCount(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2021 return 5 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2022 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2023 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2024 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2025 v9.CheckSourceFailure(lines, 'E1345: Not a valid command in an interface: return 5', 6) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2026 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2027 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2028 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2029 export interface EnterExit |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2030 def Enter(): void |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2031 def Exit(): void |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2032 endinterface |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2033 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2034 writefile(lines, 'XdefIntf.vim', 'D') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2035 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2036 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2037 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2038 import './XdefIntf.vim' as defIntf |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2039 export def With(ee: defIntf.EnterExit, F: func) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2040 ee.Enter() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2041 try |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2042 F() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2043 finally |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2044 ee.Exit() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2045 endtry |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2046 enddef |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2047 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2048 v9.CheckScriptSuccess(lines) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2049 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2050 var imported =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2051 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2052 export abstract class EnterExit |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2053 def Enter(): void |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2054 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2055 def Exit(): void |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2056 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2057 endclass |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2058 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2059 writefile(imported, 'XdefIntf2.vim', 'D') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2060 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2061 lines[1] = " import './XdefIntf2.vim' as defIntf" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2062 v9.CheckScriptSuccess(lines) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2063 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2064 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2065 def Test_class_implements_interface() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2066 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2067 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2068 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2069 interface Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2070 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2071 def Method(nr: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2072 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2073 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2074 class SomeImpl implements Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2075 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2076 def Method(nr: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2077 echo nr |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2078 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2079 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2080 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2081 interface Another |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2082 this.member: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2083 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2084 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2085 class AnotherImpl implements Some, Another |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2086 this.member = 'abc' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2087 this.count = 20 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2088 def Method(nr: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2089 echo nr |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2090 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2091 endclass |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2092 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2093 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2094 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2095 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2096 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2097 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2098 interface Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2099 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2100 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2101 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2102 class SomeImpl implements Some implements Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2103 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2104 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2105 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2106 v9.CheckSourceFailure(lines, 'E1350: Duplicate "implements"', 7) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2107 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2108 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2109 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2110 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2111 interface Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2112 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2113 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2114 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2115 class SomeImpl implements Some, Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2116 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2117 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2118 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2119 v9.CheckSourceFailure(lines, 'E1351: Duplicate interface after "implements": Some', 7) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2120 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2121 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2122 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2123 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2124 interface Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2125 this.counter: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2126 def Method(nr: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2127 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2128 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2129 class SomeImpl implements Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2130 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2131 def Method(nr: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2132 echo nr |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2133 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2134 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2135 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2136 v9.CheckSourceFailure(lines, 'E1348: Variable "counter" of interface "Some" is not implemented', 13) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2137 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2138 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2139 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2140 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2141 interface Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2142 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2143 def Methods(nr: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2144 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2145 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2146 class SomeImpl implements Some |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2147 this.count: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2148 def Method(nr: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2149 echo nr |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2150 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2151 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2152 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2153 v9.CheckSourceFailure(lines, 'E1349: Method "Methods" of interface "Some" is not implemented', 13) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2154 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2155 # Check different order of members in class and interface works. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2156 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2157 vim9script |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2158 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2159 interface Result |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2160 this.label: string |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2161 this.errpos: number |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2162 endinterface |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2163 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2164 # order of members is opposite of interface |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2165 class Failure implements Result |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2166 public this.lnum: number = 5 |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2167 this.errpos: number = 42 |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2168 this.label: string = 'label' |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2169 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2170 |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2171 def Test() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2172 var result: Result = Failure.new() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2173 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2174 assert_equal('label', result.label) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2175 assert_equal(42, result.errpos) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2176 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2177 |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2178 Test() |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2179 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2180 v9.CheckSourceSuccess(lines) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2181 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2182 # Interface name after "extends" doesn't end in a space or NUL character |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2183 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2184 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2185 interface A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2186 endinterface |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2187 class B extends A" |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2188 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2189 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2190 v9.CheckSourceFailure(lines, 'E1315: White space required after name: A"', 4) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2191 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2192 # Trailing characters after a class name |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2193 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2194 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2195 class A bbb |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2196 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2197 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2198 v9.CheckSourceFailure(lines, 'E488: Trailing characters: bbb', 2) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2199 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2200 # using "implements" with a non-existing class |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2201 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2202 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2203 class A implements B |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2204 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2205 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2206 v9.CheckSourceFailure(lines, 'E1346: Interface name not found: B', 3) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2207 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2208 # using "implements" with a regular class |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2209 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2210 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2211 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2212 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2213 class B implements A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2214 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2215 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2216 v9.CheckSourceFailure(lines, 'E1347: Not a valid interface: A', 5) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2217 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2218 # using "implements" with a variable |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2219 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2220 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2221 var T: number = 10 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2222 class A implements T |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2223 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2224 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2225 v9.CheckSourceFailure(lines, 'E1347: Not a valid interface: T', 4) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2226 |
32903
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
2227 # implements should be followed by a white space |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
2228 lines =<< trim END |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
2229 vim9script |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
2230 interface A |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
2231 endinterface |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
2232 class B implements A; |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
2233 endclass |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
2234 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2235 v9.CheckSourceFailure(lines, 'E1315: White space required after name: A;', 4) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2236 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2237 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2238 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2239 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2240 interface One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2241 def IsEven(nr: number): bool |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2242 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2243 class Two implements One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2244 def IsEven(nr: number): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2245 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2246 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2247 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2248 v9.CheckSourceFailure(lines, 'E1383: Method "IsEven": type mismatch, expected func(number): bool but got func(number): string', 9) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2249 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2250 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2251 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2252 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2253 interface One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2254 def IsEven(nr: number): bool |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2255 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2256 class Two implements One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2257 def IsEven(nr: bool): bool |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2258 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2259 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2260 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2261 v9.CheckSourceFailure(lines, 'E1383: Method "IsEven": type mismatch, expected func(number): bool but got func(bool): bool', 9) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2262 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2263 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2264 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2265 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2266 interface One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2267 def IsEven(nr: number): bool |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2268 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2269 class Two implements One |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2270 def IsEven(nr: number, ...extra: list<number>): bool |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2271 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2272 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2273 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2274 v9.CheckSourceFailure(lines, 'E1383: Method "IsEven": type mismatch, expected func(number): bool but got func(number, ...list<number>): bool', 9) |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2275 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2276 # access superclass interface members from subclass, mix variable order |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2277 lines =<< trim END |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2278 vim9script |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2279 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2280 interface I1 |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2281 this.mvar1: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2282 this.mvar2: number |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2283 endinterface |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2284 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2285 # NOTE: the order is swapped |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2286 class A implements I1 |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2287 this.mvar2: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2288 this.mvar1: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2289 public static svar2: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2290 public static svar1: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2291 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2292 svar1 = 11 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2293 svar2 = 12 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2294 this.mvar1 = 111 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2295 this.mvar2 = 112 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2296 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2297 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2298 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2299 class B extends A |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2300 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2301 this.mvar1 = 121 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2302 this.mvar2 = 122 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2303 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2304 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2305 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2306 class C extends B |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2307 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2308 this.mvar1 = 131 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2309 this.mvar2 = 132 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2310 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2311 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2312 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2313 def F2(i: I1): list<number> |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2314 return [ i.mvar1, i.mvar2 ] |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2315 enddef |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2316 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2317 var oa = A.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2318 var ob = B.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2319 var oc = C.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2320 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2321 assert_equal([111, 112], F2(oa)) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2322 assert_equal([121, 122], F2(ob)) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2323 assert_equal([131, 132], F2(oc)) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2324 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2325 v9.CheckSourceSuccess(lines) |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2326 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2327 # Access superclass interface members from subclass, mix variable order. |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2328 # Two interfaces, one on A, one on B; each has both kinds of variables |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2329 lines =<< trim END |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2330 vim9script |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2331 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2332 interface I1 |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2333 this.mvar1: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2334 this.mvar2: number |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2335 endinterface |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2336 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2337 interface I2 |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2338 this.mvar3: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2339 this.mvar4: number |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2340 endinterface |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2341 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2342 class A implements I1 |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2343 public static svar1: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2344 public static svar2: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2345 this.mvar1: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2346 this.mvar2: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2347 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2348 svar1 = 11 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2349 svar2 = 12 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2350 this.mvar1 = 111 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2351 this.mvar2 = 112 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2352 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2353 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2354 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2355 class B extends A implements I2 |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2356 static svar3: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2357 static svar4: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2358 this.mvar3: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2359 this.mvar4: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2360 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2361 svar3 = 23 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2362 svar4 = 24 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2363 this.mvar1 = 121 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2364 this.mvar2 = 122 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2365 this.mvar3 = 123 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2366 this.mvar4 = 124 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2367 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2368 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2369 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2370 class C extends B |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2371 public static svar5: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2372 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2373 svar5 = 1001 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2374 this.mvar1 = 131 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2375 this.mvar2 = 132 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2376 this.mvar3 = 133 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2377 this.mvar4 = 134 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2378 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2379 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2380 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2381 def F2(i: I1): list<number> |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2382 return [ i.mvar1, i.mvar2 ] |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2383 enddef |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2384 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2385 def F4(i: I2): list<number> |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2386 return [ i.mvar3, i.mvar4 ] |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2387 enddef |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2388 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2389 var oa = A.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2390 var ob = B.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2391 var oc = C.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2392 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2393 assert_equal([[111, 112]], [F2(oa)]) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2394 assert_equal([[121, 122], [123, 124]], [F2(ob), F4(ob)]) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2395 assert_equal([[131, 132], [133, 134]], [F2(oc), F4(oc)]) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
2396 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2397 v9.CheckSourceSuccess(lines) |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2398 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2399 # Using two interface names without a space after the "," |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2400 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2401 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2402 interface A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2403 endinterface |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2404 interface B |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2405 endinterface |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2406 class C implements A,B |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2407 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2408 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2409 v9.CheckSourceFailure(lines, 'E1315: White space required after name: A,B', 6) |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2410 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2411 # No interface name after a comma |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2412 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2413 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2414 interface A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2415 endinterface |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2416 class B implements A, |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2417 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2418 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2419 v9.CheckSourceFailure(lines, 'E1389: Missing name after implements', 4) |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2420 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2421 # No interface name after implements |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2422 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2423 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2424 class A implements |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2425 endclass |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2426 END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
2427 v9.CheckSourceFailure(lines, 'E1389: Missing name after implements', 2) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2428 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2429 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2430 def Test_call_interface_method() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2431 var lines =<< trim END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2432 vim9script |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2433 interface Base |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2434 def Enter(): void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2435 endinterface |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2436 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2437 class Child implements Base |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2438 def Enter(): void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2439 g:result ..= 'child' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2440 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2441 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2442 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2443 def F(obj: Base) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2444 obj.Enter() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2445 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2446 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2447 g:result = '' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2448 F(Child.new()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2449 assert_equal('child', g:result) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2450 unlet g:result |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2451 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2452 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2453 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2454 lines =<< trim END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2455 vim9script |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2456 class Base |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2457 def Enter(): void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2458 g:result ..= 'base' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2459 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2460 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2461 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2462 class Child extends Base |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2463 def Enter(): void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2464 g:result ..= 'child' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2465 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2466 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2467 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2468 def F(obj: Base) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2469 obj.Enter() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2470 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2471 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2472 g:result = '' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2473 F(Child.new()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2474 assert_equal('child', g:result) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2475 unlet g:result |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2476 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2477 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2478 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2479 # method of interface returns a value |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2480 lines =<< trim END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2481 vim9script |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2482 interface Base |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2483 def Enter(): string |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2484 endinterface |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2485 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2486 class Child implements Base |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2487 def Enter(): string |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2488 g:result ..= 'child' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2489 return "/resource" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2490 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2491 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2492 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2493 def F(obj: Base) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2494 var r = obj.Enter() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2495 g:result ..= r |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2496 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2497 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2498 g:result = '' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2499 F(Child.new()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2500 assert_equal('child/resource', g:result) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2501 unlet g:result |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2502 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2503 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2504 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2505 lines =<< trim END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2506 vim9script |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2507 class Base |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2508 def Enter(): string |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2509 return null_string |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2510 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2511 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2512 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2513 class Child extends Base |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2514 def Enter(): string |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2515 g:result ..= 'child' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2516 return "/resource" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2517 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2518 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2519 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2520 def F(obj: Base) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2521 var r = obj.Enter() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2522 g:result ..= r |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2523 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2524 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2525 g:result = '' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2526 F(Child.new()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2527 assert_equal('child/resource', g:result) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2528 unlet g:result |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2529 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2530 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2531 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2532 # No class that implements the interface. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2533 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2534 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2535 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2536 interface IWithEE |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2537 def Enter(): any |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2538 def Exit(): void |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2539 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2540 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2541 def With1(ee: IWithEE, F: func) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2542 var r = ee.Enter() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2543 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2544 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2545 defcompile |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2546 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2547 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2548 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2549 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2550 def Test_class_used_as_type() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2551 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2552 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2553 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2554 class Point |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2555 this.x = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2556 this.y = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2557 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2558 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2559 var p: Point |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2560 p = Point.new(2, 33) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2561 assert_equal(2, p.x) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2562 assert_equal(33, p.y) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2563 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2564 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2565 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2566 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2567 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2568 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2569 interface HasX |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2570 this.x: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2571 endinterface |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2572 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2573 class Point implements HasX |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2574 this.x = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2575 this.y = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2576 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2577 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2578 var p: Point |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2579 p = Point.new(2, 33) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2580 var hx = p |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2581 assert_equal(2, hx.x) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2582 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2583 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2584 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2585 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2586 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2587 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2588 class Point |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2589 this.x = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2590 this.y = 0 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2591 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2592 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2593 var p: Point |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2594 p = 'text' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2595 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2596 v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected object<Point> but got string', 9) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2597 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2598 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2599 def Test_class_extends() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2600 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2601 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2602 class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2603 this.one = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2604 def GetOne(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2605 return this.one |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2606 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2607 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2608 class Child extends Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2609 this.two = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2610 def GetTotal(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2611 return this.one + this.two |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2612 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2613 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2614 var o = Child.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2615 assert_equal(1, o.one) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2616 assert_equal(2, o.two) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2617 assert_equal(1, o.GetOne()) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2618 assert_equal(3, o.GetTotal()) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2619 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2620 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2621 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2622 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2623 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2624 class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2625 this.one = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2626 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2627 class Child extends Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2628 this.two = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2629 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2630 var o = Child.new(3, 44) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2631 assert_equal(3, o.one) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2632 assert_equal(44, o.two) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2633 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2634 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2635 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2636 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2637 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2638 class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2639 this.one = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2640 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2641 class Child extends Base extends Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2642 this.two = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2643 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2644 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2645 v9.CheckSourceFailure(lines, 'E1352: Duplicate "extends"', 5) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2646 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2647 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2648 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2649 class Child extends BaseClass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2650 this.two = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2651 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2652 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2653 v9.CheckSourceFailure(lines, 'E1353: Class name not found: BaseClass', 4) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2654 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2655 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2656 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2657 var SomeVar = 99 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2658 class Child extends SomeVar |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2659 this.two = 2 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2660 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2661 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2662 v9.CheckSourceFailure(lines, 'E1354: Cannot extend SomeVar', 5) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2663 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2664 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2665 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2666 class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2667 this.name: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2668 def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2669 return this.name |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2670 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2671 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2672 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2673 class Child extends Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2674 this.age: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2675 def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2676 return super.ToString() .. ': ' .. this.age |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2677 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2678 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2679 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2680 var o = Child.new('John', 42) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2681 assert_equal('John: 42', o.ToString()) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2682 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2683 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2684 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2685 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2686 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2687 class Child |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2688 this.age: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2689 def ToString(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2690 return this.age |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2691 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2692 def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2693 return this.age |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2694 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2695 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2696 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2697 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: ToString', 9) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2698 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2699 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2700 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2701 class Child |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2702 this.age: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2703 def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2704 return super .ToString() .. ': ' .. this.age |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2705 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2706 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2707 var o = Child.new(42) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2708 echo o.ToString() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2709 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2710 v9.CheckSourceFailure(lines, 'E1356: "super" must be followed by a dot', 1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2711 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2712 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2713 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2714 class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2715 this.name: string |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2716 def ToString(): string |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2717 return this.name |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2718 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2719 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2720 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2721 var age = 42 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2722 def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2723 return super.ToString() .. ': ' .. age |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2724 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2725 echo ToString() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2726 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2727 v9.CheckSourceFailure(lines, 'E1357: Using "super" not in a class method', 1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2728 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2729 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2730 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2731 class Child |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2732 this.age: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2733 def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2734 return super.ToString() .. ': ' .. this.age |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2735 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2736 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2737 var o = Child.new(42) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2738 echo o.ToString() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2739 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2740 v9.CheckSourceFailure(lines, 'E1358: Using "super" not in a child class', 1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2741 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2742 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2743 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2744 class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2745 this.name: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2746 static def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2747 return 'Base class' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2748 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2749 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2750 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2751 class Child extends Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2752 this.age: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2753 def ToString(): string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2754 return Base.ToString() .. ': ' .. this.age |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2755 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2756 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2757 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2758 var o = Child.new('John', 42) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2759 assert_equal('Base class: 42', o.ToString()) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2760 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2761 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2762 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2763 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2764 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2765 class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2766 this.value = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2767 def new(init: number) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2768 this.value = number + 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2769 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2770 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2771 class Child extends Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2772 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2773 this.new(3) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2774 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2775 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2776 var c = Child.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2777 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2778 v9.CheckSourceFailure(lines, 'E1385: Class method "new" accessible only using class "Child"', 1) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2779 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2780 # base class with more than one object member |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2781 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2782 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2783 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2784 class Result |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2785 this.success: bool |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2786 this.value: any = null |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2787 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2788 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2789 class Success extends Result |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2790 def new(this.value = v:none) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2791 this.success = true |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2792 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2793 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2794 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2795 var v = Success.new('asdf') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2796 assert_equal("object of Success {success: true, value: 'asdf'}", string(v)) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2797 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2798 v9.CheckSourceSuccess(lines) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2799 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2800 # class name after "extends" doesn't end in a space or NUL character |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2801 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2802 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2803 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2804 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2805 class B extends A" |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2806 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2807 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2808 v9.CheckSourceFailure(lines, 'E1315: White space required after name: A"', 4) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2809 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2810 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2811 def Test_using_base_class() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2812 var lines =<< trim END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2813 vim9script |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2814 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2815 class BaseEE |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2816 def Enter(): any |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2817 return null |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2818 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2819 def Exit(resource: any): void |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2820 enddef |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2821 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2822 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2823 class ChildEE extends BaseEE |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2824 def Enter(): any |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2825 return 42 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2826 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2827 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2828 def Exit(resource: number): void |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2829 g:result ..= '/exit' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2830 enddef |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2831 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2832 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2833 def With(ee: BaseEE) |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2834 var r = ee.Enter() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2835 try |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2836 g:result ..= r |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2837 finally |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2838 g:result ..= '/finally' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2839 ee.Exit(r) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2840 endtry |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2841 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2842 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2843 g:result = '' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2844 With(ChildEE.new()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2845 assert_equal('42/finally/exit', g:result) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2846 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2847 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2848 unlet g:result |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2849 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2850 # Using super, Child invokes Base method which has optional arg. #12471 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2851 lines =<< trim END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2852 vim9script |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2853 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2854 class Base |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2855 this.success: bool = false |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2856 def Method(arg = 0) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2857 this.success = true |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2858 enddef |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2859 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2860 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2861 class Child extends Base |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2862 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2863 super.Method() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2864 enddef |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2865 endclass |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2866 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2867 var obj = Child.new() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2868 assert_equal(true, obj.success) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2869 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2870 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2871 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2872 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2873 def Test_class_import() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2874 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2875 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2876 export class Animal |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2877 this.kind: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2878 this.name: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2879 endclass |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2880 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2881 writefile(lines, 'Xanimal.vim', 'D') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2882 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2883 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2884 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2885 import './Xanimal.vim' as animal |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2886 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2887 var a: animal.Animal |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2888 a = animal.Animal.new('fish', 'Eric') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2889 assert_equal('fish', a.kind) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2890 assert_equal('Eric', a.name) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2891 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2892 var b: animal.Animal = animal.Animal.new('cat', 'Garfield') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2893 assert_equal('cat', b.kind) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2894 assert_equal('Garfield', b.name) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2895 END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2896 v9.CheckScriptSuccess(lines) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2897 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2898 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2899 def Test_abstract_class() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2900 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2901 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2902 abstract class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2903 this.name: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2904 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2905 class Person extends Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2906 this.age: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2907 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2908 var p: Base = Person.new('Peter', 42) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2909 assert_equal('Peter', p.name) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2910 assert_equal(42, p.age) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2911 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2912 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2913 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2914 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2915 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2916 abstract class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2917 this.name: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2918 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2919 class Person extends Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2920 this.age: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2921 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2922 var p = Base.new('Peter') |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2923 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2924 v9.CheckSourceFailure(lines, 'E1325: Method not found on class "Base": new', 8) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2925 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2926 lines =<< trim END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2927 abstract class Base |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2928 this.name: string |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2929 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2930 END |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2931 v9.CheckSourceFailure(lines, 'E1316: Class can only be defined in Vim9 script', 1) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2932 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2933 # Abstract class cannot have a "new" function |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2934 lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2935 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2936 abstract class Base |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2937 def new() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2938 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2939 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
2940 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2941 v9.CheckSourceFailure(lines, 'E1359: Cannot define a "new" method in an abstract class', 4) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2942 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2943 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2944 def Test_closure_in_class() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2945 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2946 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2947 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2948 class Foo |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2949 this.y: list<string> = ['B'] |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2950 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2951 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2952 g:result = filter(['A', 'B'], (_, v) => index(this.y, v) == -1) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2953 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2954 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2955 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2956 Foo.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2957 assert_equal(['A'], g:result) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2958 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2959 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2960 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2961 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2962 def Test_call_constructor_from_legacy() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2963 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2964 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2965 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2966 var newCalled = 'false' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2967 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2968 class A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2969 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2970 newCalled = 'true' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2971 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2972 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2973 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2974 export def F(options = {}): any |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2975 return A |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2976 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2977 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2978 g:p = F() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2979 legacy call p.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2980 assert_equal('true', newCalled) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2981 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
2982 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2983 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2984 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2985 def Test_defer_with_object() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2986 var lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2987 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2988 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2989 class CWithEE |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2990 def Enter() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2991 g:result ..= "entered/" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2992 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2993 def Exit() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2994 g:result ..= "exited" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2995 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2996 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2997 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2998 def With(ee: CWithEE, F: func) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
2999 ee.Enter() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3000 defer ee.Exit() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3001 F() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3002 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3003 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3004 g:result = '' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3005 var obj = CWithEE.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3006 obj->With(() => { |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3007 g:result ..= "called/" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3008 }) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3009 assert_equal('entered/called/exited', g:result) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3010 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3011 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3012 unlet g:result |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3013 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3014 lines =<< trim END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3015 vim9script |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3016 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3017 class BaseWithEE |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3018 def Enter() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3019 g:result ..= "entered-base/" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3020 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3021 def Exit() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3022 g:result ..= "exited-base" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3023 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3024 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3025 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3026 class CWithEE extends BaseWithEE |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3027 def Enter() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3028 g:result ..= "entered-child/" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3029 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3030 def Exit() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3031 g:result ..= "exited-child" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3032 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3033 endclass |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3034 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3035 def With(ee: BaseWithEE, F: func) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3036 ee.Enter() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3037 defer ee.Exit() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3038 F() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3039 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3040 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3041 g:result = '' |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3042 var obj = CWithEE.new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3043 obj->With(() => { |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3044 g:result ..= "called/" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3045 }) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3046 assert_equal('entered-child/called/exited-child', g:result) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3047 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3048 v9.CheckSourceSuccess(lines) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3049 unlet g:result |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3050 enddef |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3051 |
32764
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3052 " The following test used to crash Vim (Github issue #12676) |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3053 def Test_extends_method_crashes_vim() |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3054 var lines =<< trim END |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3055 vim9script |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3056 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3057 class Observer |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3058 endclass |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3059 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3060 class Property |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3061 this.value: any |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3062 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3063 def Set(v: any) |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3064 if v != this.value |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3065 this.value = v |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3066 endif |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3067 enddef |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3068 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3069 def Register(observer: Observer) |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3070 enddef |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3071 endclass |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3072 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3073 class Bool extends Property |
33070
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
3074 this.value2: bool |
32764
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3075 endclass |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3076 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3077 def Observe(obj: Property, who: Observer) |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3078 obj.Register(who) |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3079 enddef |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3080 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3081 var p = Bool.new(false) |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3082 var myObserver = Observer.new() |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3083 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3084 Observe(p, myObserver) |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3085 |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3086 p.Set(true) |
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3087 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3088 v9.CheckSourceSuccess(lines) |
32764
d35204b890af
patch 9.0.1701: vim9 crash when class member overridden
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
3089 enddef |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3090 |
32772
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3091 " Test for calling a method in a class that is extended |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3092 def Test_call_method_in_extended_class() |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3093 var lines =<< trim END |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3094 vim9script |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3095 |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3096 var prop_init_called = false |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3097 var prop_register_called = false |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3098 |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3099 class Property |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3100 def Init() |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3101 prop_init_called = true |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3102 enddef |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3103 |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3104 def Register() |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3105 prop_register_called = true |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3106 enddef |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3107 endclass |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3108 |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3109 class Bool extends Property |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3110 endclass |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3111 |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3112 def Observe(obj: Property) |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3113 obj.Register() |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3114 enddef |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3115 |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3116 var p = Property.new() |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3117 Observe(p) |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3118 |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3119 p.Init() |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3120 assert_true(prop_init_called) |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3121 assert_true(prop_register_called) |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3122 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3123 v9.CheckSourceSuccess(lines) |
32772
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3124 enddef |
0dc750a24875
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32764
diff
changeset
|
3125 |
32972
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3126 def Test_instanceof() |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3127 var lines =<< trim END |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3128 vim9script |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3129 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3130 class Base1 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3131 endclass |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3132 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3133 class Base2 extends Base1 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3134 endclass |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3135 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3136 interface Intf1 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3137 endinterface |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3138 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3139 class Mix1 implements Intf1 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3140 endclass |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3141 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3142 class Base3 extends Mix1 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3143 endclass |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3144 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3145 var b1 = Base1.new() |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3146 var b2 = Base2.new() |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3147 var b3 = Base3.new() |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3148 |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3149 assert_true(instanceof(b1, Base1)) |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3150 assert_true(instanceof(b2, Base1)) |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3151 assert_false(instanceof(b1, Base2)) |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3152 assert_true(instanceof(b3, Mix1)) |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3153 assert_false(instanceof(b3, [])) |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3154 assert_true(instanceof(b3, [Base1, Base2, Intf1])) |
33019
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3155 |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3156 def Foo() |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3157 var a1 = Base1.new() |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3158 var a2 = Base2.new() |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3159 var a3 = Base3.new() |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3160 |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3161 assert_true(instanceof(a1, Base1)) |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3162 assert_true(instanceof(a2, Base1)) |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3163 assert_false(instanceof(a1, Base2)) |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3164 assert_true(instanceof(a3, Mix1)) |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3165 assert_false(instanceof(a3, [])) |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3166 assert_true(instanceof(a3, [Base1, Base2, Intf1])) |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3167 enddef |
04c75e67ca30
patch 9.0.1801: Vim9 instanceof() fails in a def func
Christian Brabandt <cb@256bit.org>
parents:
33008
diff
changeset
|
3168 Foo() |
33291
4cb421ba3385
patch 9.0.1911: Vim9: segfault with null object and instanceof()
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
3169 |
4cb421ba3385
patch 9.0.1911: Vim9: segfault with null object and instanceof()
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
3170 var o_null: Base1 |
4cb421ba3385
patch 9.0.1911: Vim9: segfault with null object and instanceof()
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
3171 assert_false(instanceof(o_null, Base1)) |
4cb421ba3385
patch 9.0.1911: Vim9: segfault with null object and instanceof()
Christian Brabandt <cb@256bit.org>
parents:
33286
diff
changeset
|
3172 |
32972
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3173 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3174 v9.CheckSourceSuccess(lines) |
32972
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3175 enddef |
e4851934751a
patch 9.0.1786: Vim9: need instanceof() function
Christian Brabandt <cb@256bit.org>
parents:
32960
diff
changeset
|
3176 |
32812
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3177 " Test for calling a method in the parent class that is extended partially. |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3178 " This used to fail with the 'E118: Too many arguments for function: Text' error |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3179 " message (Github issue #12524). |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3180 def Test_call_method_in_parent_class() |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3181 var lines =<< trim END |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3182 vim9script |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3183 |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3184 class Widget |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3185 this._lnum: number = 1 |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3186 |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3187 def SetY(lnum: number) |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3188 this._lnum = lnum |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3189 enddef |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3190 |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3191 def Text(): string |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3192 return '' |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3193 enddef |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3194 endclass |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3195 |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3196 class Foo extends Widget |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3197 def Text(): string |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3198 return '<Foo>' |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3199 enddef |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3200 endclass |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3201 |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3202 def Stack(w1: Widget, w2: Widget): list<Widget> |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3203 w1.SetY(1) |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3204 w2.SetY(2) |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3205 return [w1, w2] |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3206 enddef |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3207 |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3208 var foo1 = Foo.new() |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3209 var foo2 = Foo.new() |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3210 var l = Stack(foo1, foo2) |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3211 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3212 v9.CheckSourceSuccess(lines) |
32812
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3213 enddef |
57282f1d9e0f
patch 9.0.1720: Vim9 class using wrong index for overridden method
Christian Brabandt <cb@256bit.org>
parents:
32772
diff
changeset
|
3214 |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3215 " Test for calling methods from three levels of classes |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3216 def Test_multi_level_method_call() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3217 var lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3218 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3219 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3220 var A_func1: number = 0 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3221 var A_func2: number = 0 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3222 var A_func3: number = 0 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3223 var B_func2: number = 0 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3224 var B_func3: number = 0 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3225 var C_func3: number = 0 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3226 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3227 class A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3228 def Func1() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3229 A_func1 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3230 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3231 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3232 def Func2() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3233 A_func2 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3234 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3235 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3236 def Func3() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3237 A_func3 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3238 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3239 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3240 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3241 class B extends A |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3242 def Func2() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3243 B_func2 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3244 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3245 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3246 def Func3() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3247 B_func3 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3248 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3249 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3250 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3251 class C extends B |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3252 def Func3() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3253 C_func3 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3254 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3255 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3256 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3257 def A_CallFuncs(a: A) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3258 a.Func1() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3259 a.Func2() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3260 a.Func3() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3261 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3262 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3263 def B_CallFuncs(b: B) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3264 b.Func1() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3265 b.Func2() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3266 b.Func3() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3267 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3268 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3269 def C_CallFuncs(c: C) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3270 c.Func1() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3271 c.Func2() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3272 c.Func3() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3273 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3274 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3275 var cobj = C.new() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3276 A_CallFuncs(cobj) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3277 B_CallFuncs(cobj) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3278 C_CallFuncs(cobj) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3279 assert_equal(3, A_func1) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3280 assert_equal(0, A_func2) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3281 assert_equal(0, A_func3) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3282 assert_equal(3, B_func2) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3283 assert_equal(0, B_func3) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3284 assert_equal(3, C_func3) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3285 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3286 v9.CheckSourceSuccess(lines) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3287 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3288 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3289 " Test for using members from three levels of classes |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3290 def Test_multi_level_member_access() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3291 var lines =<< trim END |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3292 vim9script |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3293 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3294 class A |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
3295 public this.val1: number = 0 |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3296 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3297 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3298 class B extends A |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
3299 public this.val2: number = 0 |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3300 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3301 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3302 class C extends B |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
3303 public this.val3: number = 0 |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3304 endclass |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3305 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3306 def A_members(a: A) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3307 a.val1 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3308 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3309 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3310 def B_members(b: B) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3311 b.val1 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3312 b.val2 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3313 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3314 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3315 def C_members(c: C) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3316 c.val1 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3317 c.val2 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3318 c.val3 += 1 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3319 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3320 |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3321 var cobj = C.new() |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3322 A_members(cobj) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3323 B_members(cobj) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3324 C_members(cobj) |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3325 assert_equal(3, cobj.val1) |
33070
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
3326 assert_equal(2, cobj.val2) |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
3327 assert_equal(1, cobj.val3) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3328 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3329 v9.CheckSourceSuccess(lines) |
32854
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3330 enddef |
5fd9fe58c791
patch 9.0.1737: Calling a base class method through an extended class fails
Christian Brabandt <cb@256bit.org>
parents:
32822
diff
changeset
|
3331 |
32898
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3332 " Test expansion of <stack> with class methods. |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3333 def Test_stack_expansion_with_methods() |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3334 var lines =<< trim END |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3335 vim9script |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3336 |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3337 class C |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3338 def M1() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3339 F0() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3340 enddef |
32898
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3341 endclass |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3342 |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3343 def F0() |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3344 assert_match('<SNR>\d\+_F\[1\]\.\.C\.M1\[1\]\.\.<SNR>\d\+_F0\[1\]$', expand('<stack>')) |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3345 enddef |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3346 |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3347 def F() |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3348 C.new().M1() |
32898
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3349 enddef |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3350 |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3351 F() |
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3352 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3353 v9.CheckSourceSuccess(lines) |
32898
cbb5a593c92a
patch 9.0.1758: vim9 no class identifiers in stack dumps
Christian Brabandt <cb@256bit.org>
parents:
32863
diff
changeset
|
3354 enddef |
32903
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3355 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3356 " Test the return type of the new() constructor |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3357 def Test_new_return_type() |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3358 # new() uses the default return type and there is no return statement |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3359 var lines =<< trim END |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3360 vim9script |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3361 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3362 class C |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3363 this._bufnr: number |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3364 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3365 def new(this._bufnr) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3366 if !bufexists(this._bufnr) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3367 this._bufnr = -1 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3368 endif |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3369 enddef |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3370 endclass |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3371 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3372 var c = C.new(12345) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3373 assert_equal('object<C>', typename(c)) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3374 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3375 var v1: C |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3376 v1 = C.new(12345) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3377 assert_equal('object<C>', typename(v1)) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3378 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3379 def F() |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3380 var v2: C |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3381 v2 = C.new(12345) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3382 assert_equal('object<C>', typename(v2)) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3383 enddef |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3384 F() |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3385 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3386 v9.CheckSourceSuccess(lines) |
32903
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3387 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3388 # new() uses the default return type and an empty 'return' statement |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3389 lines =<< trim END |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3390 vim9script |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3391 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3392 class C |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3393 this._bufnr: number |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3394 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3395 def new(this._bufnr) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3396 if !bufexists(this._bufnr) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3397 this._bufnr = -1 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3398 return |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3399 endif |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3400 enddef |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3401 endclass |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3402 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3403 var c = C.new(12345) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3404 assert_equal('object<C>', typename(c)) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3405 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3406 var v1: C |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3407 v1 = C.new(12345) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3408 assert_equal('object<C>', typename(v1)) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3409 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3410 def F() |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3411 var v2: C |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3412 v2 = C.new(12345) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3413 assert_equal('object<C>', typename(v2)) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3414 enddef |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3415 F() |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3416 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3417 v9.CheckSourceSuccess(lines) |
32903
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3418 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3419 # new() uses "any" return type and returns "this" |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3420 lines =<< trim END |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3421 vim9script |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3422 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3423 class C |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3424 this._bufnr: number |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3425 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3426 def new(this._bufnr): any |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3427 if !bufexists(this._bufnr) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3428 this._bufnr = -1 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3429 return this |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3430 endif |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3431 enddef |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3432 endclass |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3433 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3434 v9.CheckSourceFailure(lines, 'E1365: Cannot use a return type with the "new" method', 11) |
32903
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3435 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3436 # new() uses 'Dict' return type and returns a Dict |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3437 lines =<< trim END |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3438 vim9script |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3439 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3440 class C |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3441 this._state: dict<any> |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3442 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3443 def new(): dict<any> |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3444 this._state = {} |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3445 return this._state |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3446 enddef |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3447 endclass |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3448 |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3449 var c = C.new() |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3450 assert_equal('object<C>', typename(c)) |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3451 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3452 v9.CheckSourceFailure(lines, 'E1365: Cannot use a return type with the "new" method', 9) |
32903
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3453 enddef |
54c01bb98b8e
patch 9.0.1760: vim9 class problem with new() constructor
Christian Brabandt <cb@256bit.org>
parents:
32898
diff
changeset
|
3454 |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3455 " Test for checking a member initialization type at run time. |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3456 def Test_runtime_type_check_for_member_init() |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3457 var lines =<< trim END |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3458 vim9script |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3459 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3460 var retnum: bool = false |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3461 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3462 def F(): any |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3463 retnum = !retnum |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3464 if retnum |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3465 return 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3466 else |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3467 return "hello" |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3468 endif |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3469 enddef |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3470 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3471 class C |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3472 this._foo: bool = F() |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3473 endclass |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3474 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3475 var c1 = C.new() |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3476 var c2 = C.new() |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3477 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3478 v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected bool but got string', 0) |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3479 enddef |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3480 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3481 " Test for locking a variable referring to an object and reassigning to another |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3482 " object. |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3483 def Test_object_lockvar() |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3484 var lines =<< trim END |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3485 vim9script |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3486 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3487 class C |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3488 this.val: number |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3489 def new(this.val) |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3490 enddef |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3491 endclass |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3492 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3493 var some_dict: dict<C> = { a: C.new(1), b: C.new(2), c: C.new(3), } |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3494 lockvar 2 some_dict |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3495 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3496 var current: C |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3497 current = some_dict['c'] |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3498 assert_equal(3, current.val) |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3499 current = some_dict['b'] |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3500 assert_equal(2, current.val) |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3501 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3502 def F() |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3503 current = some_dict['c'] |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3504 enddef |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3505 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3506 def G() |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3507 current = some_dict['b'] |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3508 enddef |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3509 |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3510 F() |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3511 assert_equal(3, current.val) |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3512 G() |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3513 assert_equal(2, current.val) |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3514 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3515 v9.CheckSourceSuccess(lines) |
32960
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3516 enddef |
d5c05e15cf81
patch 9.0.1780: Vim9 type not defined during object creation
Christian Brabandt <cb@256bit.org>
parents:
32903
diff
changeset
|
3517 |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3518 " Test for a private object method |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3519 def Test_private_object_method() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3520 # Try calling a private method using an object (at the script level) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3521 var lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3522 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3523 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3524 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3525 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3526 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3527 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3528 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3529 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3530 a._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3531 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3532 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 9) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3533 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3534 # Try calling a private method using an object (from a def function) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3535 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3536 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3537 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3538 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3539 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3540 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3541 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3542 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3543 def T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3544 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3545 a._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3546 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3547 T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3548 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3549 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 2) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3550 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3551 # Use a private method from another object method (in script context) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3552 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3553 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3554 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3555 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3556 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3557 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3558 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3559 def Bar(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3560 return this._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3561 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3562 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3563 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3564 assert_equal(1234, a.Bar()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3565 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3566 v9.CheckSourceSuccess(lines) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3567 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3568 # Use a private method from another object method (def function context) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3569 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3570 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3571 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3572 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3573 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3574 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3575 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3576 def Bar(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3577 return this._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3578 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3579 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3580 def T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3581 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3582 assert_equal(1234, a.Bar()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3583 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3584 T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3585 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3586 v9.CheckSourceSuccess(lines) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3587 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3588 # Try calling a private method without the "this" prefix |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3589 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3590 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3591 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3592 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3593 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3594 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3595 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3596 def Bar(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3597 return _Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3598 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3599 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3600 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3601 a.Bar() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3602 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3603 v9.CheckSourceFailure(lines, 'E117: Unknown function: _Foo', 1) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3604 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3605 # Try calling a private method using the class name |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3606 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3607 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3608 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3609 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3610 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3611 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3612 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3613 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3614 A._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3615 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3616 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 8) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3617 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3618 # Define two private methods with the same name |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3619 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3620 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3621 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3622 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3623 def _Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3624 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3625 def _Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3626 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3627 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3628 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3629 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3630 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: _Foo', 7) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3631 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3632 # Define a private method and a object method with the same name |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3633 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3634 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3635 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3636 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3637 def _Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3638 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3639 def Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3640 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3641 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3642 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3643 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3644 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: Foo', 7) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3645 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3646 # Define an object method and a private method with the same name |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3647 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3648 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3649 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3650 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3651 def Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3652 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3653 def _Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3654 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3655 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3656 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3657 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3658 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: _Foo', 7) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3659 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3660 # Call a public method and a private method from a private method |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3661 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3662 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3663 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3664 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3665 def Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3666 return 100 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3667 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3668 def _Bar(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3669 return 200 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3670 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3671 def _Baz() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3672 assert_equal(100, this.Foo()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3673 assert_equal(200, this._Bar()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3674 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3675 def T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3676 this._Baz() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3677 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3678 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3679 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3680 a.T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3681 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3682 v9.CheckSourceSuccess(lines) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3683 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3684 # Try calling a private method from another class |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3685 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3686 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3687 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3688 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3689 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3690 return 100 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3691 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3692 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3693 class B |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3694 def Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3695 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3696 a._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3697 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3698 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3699 var b = B.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3700 b.Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3701 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3702 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 2) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3703 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3704 # Call a private object method from a child class object method |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3705 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3706 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3707 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3708 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3709 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3710 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3711 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3712 class B extends A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3713 def Bar() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3714 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3715 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3716 class C extends B |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3717 def Baz(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3718 return this._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3719 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3720 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3721 var c = C.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3722 assert_equal(1234, c.Baz()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3723 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3724 v9.CheckSourceSuccess(lines) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3725 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3726 # Call a private object method from a child class object |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3727 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3728 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3729 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3730 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3731 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3732 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3733 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3734 class B extends A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3735 def Bar() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3736 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3737 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3738 class C extends B |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3739 def Baz(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3740 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3741 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3742 var c = C.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3743 assert_equal(1234, c._Foo()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3744 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3745 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 16) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3746 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3747 # Using "_" prefix in a method name should fail outside of a class |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3748 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3749 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3750 def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3751 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3752 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3753 var a = _Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3754 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3755 v9.CheckSourceFailure(lines, 'E1267: Function name must start with a capital: _Foo(): number', 2) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3756 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3757 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3758 " Test for an private class method |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3759 def Test_private_class_method() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3760 # Try calling a class private method (at the script level) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3761 var lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3762 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3763 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3764 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3765 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3766 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3767 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3768 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3769 A._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3770 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3771 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 8) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3772 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3773 # Try calling a class private method (from a def function) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3774 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3775 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3776 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3777 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3778 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3779 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3780 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3781 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3782 def T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3783 A._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3784 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3785 T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3786 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3787 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 1) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3788 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3789 # Try calling a class private method using an object (at the script level) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3790 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3791 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3792 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3793 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3794 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3795 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3796 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3797 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3798 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3799 a._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3800 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3801 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 9) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3802 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3803 # Try calling a class private method using an object (from a def function) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3804 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3805 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3806 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3807 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3808 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3809 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3810 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3811 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3812 def T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3813 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3814 a._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3815 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3816 T() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3817 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3818 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 2) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3819 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3820 # Use a class private method from an object method |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3821 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3822 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3823 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3824 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3825 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3826 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3827 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3828 def Bar() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
3829 assert_equal(1234, _Foo()) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3830 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3831 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3832 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3833 a.Bar() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3834 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3835 v9.CheckSourceSuccess(lines) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3836 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
3837 # Use a class private method from another class private method without the |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
3838 # class name prefix. |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3839 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3840 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3841 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3842 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3843 static def _Foo1(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3844 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3845 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3846 static def _Foo2() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
3847 assert_equal(1234, _Foo1()) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3848 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3849 def Bar() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
3850 _Foo2() |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3851 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3852 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3853 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3854 a.Bar() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3855 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3856 v9.CheckSourceSuccess(lines) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3857 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3858 # Declare a class method and a class private method with the same name |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3859 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3860 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3861 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3862 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3863 static def _Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3864 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3865 static def Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3866 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3867 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3868 var a = A.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3869 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3870 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: Foo', 7) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3871 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3872 # Try calling a class private method from another class |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3873 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3874 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3875 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3876 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3877 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3878 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3879 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3880 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3881 class B |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3882 def Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3883 return A._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3884 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3885 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3886 var b = B.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3887 assert_equal(1234, b.Foo()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3888 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3889 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 1) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3890 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3891 # Call a private class method from a child class object method |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3892 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3893 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3894 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3895 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3896 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3897 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3898 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3899 class B extends A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3900 def Bar() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3901 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3902 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3903 class C extends B |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3904 def Baz(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3905 return A._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3906 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3907 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3908 var c = C.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3909 assert_equal(1234, c.Baz()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3910 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3911 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 1) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3912 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3913 # Call a private class method from a child class private class method |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3914 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3915 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3916 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3917 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3918 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3919 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3920 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3921 class B extends A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3922 def Bar() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3923 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3924 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3925 class C extends B |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3926 static def Baz(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3927 return A._Foo() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3928 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3929 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3930 assert_equal(1234, C.Baz()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3931 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3932 v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 1) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3933 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3934 # Call a private class method from a child class object |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3935 lines =<< trim END |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3936 vim9script |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3937 class A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3938 static def _Foo(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3939 return 1234 |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3940 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3941 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3942 class B extends A |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3943 def Bar() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3944 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3945 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3946 class C extends B |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3947 def Baz(): number |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3948 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3949 endclass |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3950 var c = C.new() |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3951 assert_equal(1234, C._Foo()) |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3952 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
3953 v9.CheckSourceFailure(lines, 'E1325: Method not found on class "C": _Foo', 16) |
33025
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3954 enddef |
1d18c7fe609f
patch 9.0.1804: Vim9: no support for private object methods
Christian Brabandt <cb@256bit.org>
parents:
33019
diff
changeset
|
3955 |
33027
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3956 " Test for using the return value of a class/object method as a function |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3957 " argument. |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3958 def Test_objmethod_funcarg() |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3959 var lines =<< trim END |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3960 vim9script |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3961 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3962 class C |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3963 def Foo(): string |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3964 return 'foo' |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3965 enddef |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3966 endclass |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3967 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3968 def Bar(a: number, s: string): string |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3969 return s |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3970 enddef |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3971 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3972 def Baz(c: C) |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3973 assert_equal('foo', Bar(10, c.Foo())) |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3974 enddef |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3975 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3976 var t = C.new() |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3977 Baz(t) |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3978 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
3979 v9.CheckSourceSuccess(lines) |
33027
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3980 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3981 lines =<< trim END |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3982 vim9script |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3983 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3984 class C |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3985 static def Foo(): string |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3986 return 'foo' |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3987 enddef |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3988 endclass |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3989 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3990 def Bar(a: number, s: string): string |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3991 return s |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3992 enddef |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3993 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3994 def Baz() |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3995 assert_equal('foo', Bar(10, C.Foo())) |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3996 enddef |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3997 |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3998 Baz() |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
3999 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4000 v9.CheckSourceSuccess(lines) |
33027
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
4001 enddef |
669898c9a6c3
patch 9.0.1805: Vim9: problem compiling object method as function call arg
Christian Brabandt <cb@256bit.org>
parents:
33025
diff
changeset
|
4002 |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4003 def Test_static_inheritence() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4004 # subclasses get their own static copy |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4005 var lines =<< trim END |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4006 vim9script |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4007 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4008 class A |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4009 static _svar: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4010 this._mvar: number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4011 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4012 _svar = 1 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4013 this._mvar = 101 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4014 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4015 def AccessObject(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4016 return this._mvar |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4017 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4018 def AccessStaticThroughObject(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4019 return _svar |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4020 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4021 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4022 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4023 class B extends A |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4024 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4025 this._mvar = 102 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4026 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4027 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4028 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4029 class C extends B |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4030 def new() |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4031 this._mvar = 103 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4032 enddef |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4033 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4034 def AccessPrivateStaticThroughClassName(): number |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4035 assert_equal(1, A._svar) |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4036 return 444 |
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4037 enddef |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4038 endclass |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4039 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4040 var oa = A.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4041 var ob = B.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4042 var oc = C.new() |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4043 assert_equal(101, oa.AccessObject()) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4044 assert_equal(102, ob.AccessObject()) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4045 assert_equal(103, oc.AccessObject()) |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4046 |
33343
41b50abddeea
patch 9.0.1935: Vim9: not consistent error messages
Christian Brabandt <cb@256bit.org>
parents:
33337
diff
changeset
|
4047 assert_fails('echo oc.AccessPrivateStaticThroughClassName()', 'E1333: Cannot access private variable: _svar') |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4048 |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4049 # verify object properly resolves to correct static |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4050 assert_equal(1, oa.AccessStaticThroughObject()) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4051 assert_equal(1, ob.AccessStaticThroughObject()) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4052 assert_equal(1, oc.AccessStaticThroughObject()) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4053 END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4054 v9.CheckSourceSuccess(lines) |
33204
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4055 enddef |
36aebbf8389f
patch 9.0.1880: Vim9: Need more tests for inheritance
Christian Brabandt <cb@256bit.org>
parents:
33201
diff
changeset
|
4056 |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4057 " Test for declaring duplicate object and class members |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4058 def Test_dup_member_variable() |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4059 # Duplicate member variable |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4060 var lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4061 vim9script |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4062 class C |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4063 this.val = 10 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4064 this.val = 20 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4065 endclass |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4066 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4067 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 4) |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4068 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4069 # Duplicate private member variable |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4070 lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4071 vim9script |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4072 class C |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4073 this._val = 10 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4074 this._val = 20 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4075 endclass |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4076 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4077 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _val', 4) |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4078 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4079 # Duplicate public member variable |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4080 lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4081 vim9script |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4082 class C |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4083 public this.val = 10 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4084 public this.val = 20 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4085 endclass |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4086 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4087 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 4) |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4088 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4089 # Duplicate private member variable |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4090 lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4091 vim9script |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4092 class C |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4093 this.val = 10 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4094 this._val = 20 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4095 endclass |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4096 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4097 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _val', 4) |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4098 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4099 # Duplicate public and private member variable |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4100 lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4101 vim9script |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4102 class C |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4103 this._val = 20 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4104 public this.val = 10 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4105 endclass |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4106 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4107 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 4) |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4108 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4109 # Duplicate class member variable |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4110 lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4111 vim9script |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4112 class C |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4113 static s: string = "abc" |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4114 static _s: string = "def" |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4115 endclass |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4116 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4117 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _s', 4) |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4118 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4119 # Duplicate public and private class member variable |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4120 lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4121 vim9script |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4122 class C |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4123 public static s: string = "abc" |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4124 static _s: string = "def" |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4125 endclass |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4126 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4127 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _s', 4) |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4128 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4129 # Duplicate class and object member variable |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4130 lines =<< trim END |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4131 vim9script |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4132 class C |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4133 static val = 10 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4134 this.val = 20 |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4135 def new() |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4136 enddef |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4137 endclass |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4138 var c = C.new() |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4139 assert_equal(10, C.val) |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4140 assert_equal(20, c.val) |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4141 END |
33381
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
4142 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 4) |
33070
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4143 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4144 # Duplicate object member variable in a derived class |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4145 lines =<< trim END |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4146 vim9script |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4147 class A |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4148 this.val = 10 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4149 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4150 class B extends A |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4151 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4152 class C extends B |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4153 this.val = 20 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4154 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4155 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4156 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 9) |
33070
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4157 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4158 # Duplicate object private member variable in a derived class |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4159 lines =<< trim END |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4160 vim9script |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4161 class A |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4162 this._val = 10 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4163 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4164 class B extends A |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4165 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4166 class C extends B |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4167 this._val = 20 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4168 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4169 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4170 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _val', 9) |
33070
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4171 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4172 # Duplicate object private member variable in a derived class |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4173 lines =<< trim END |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4174 vim9script |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4175 class A |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4176 this.val = 10 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4177 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4178 class B extends A |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4179 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4180 class C extends B |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4181 this._val = 20 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4182 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4183 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4184 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _val', 9) |
33070
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4185 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4186 # Duplicate object member variable in a derived class |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4187 lines =<< trim END |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4188 vim9script |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4189 class A |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4190 this._val = 10 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4191 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4192 class B extends A |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4193 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4194 class C extends B |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4195 this.val = 20 |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4196 endclass |
8362975375a4
patch 9.0.1822: Vim9: no check for duplicate members in extended classes
Christian Brabandt <cb@256bit.org>
parents:
33068
diff
changeset
|
4197 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4198 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 9) |
33201
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4199 |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4200 # Two member variables with a common prefix |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4201 lines =<< trim END |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4202 vim9script |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4203 class A |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4204 public static svar2: number |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4205 public static svar: number |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4206 endclass |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4207 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4208 v9.CheckSourceSuccess(lines) |
33047
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4209 enddef |
9ef43d02dd8f
patch 9.0.1814: Vim9 no error on duplicate object member var
Christian Brabandt <cb@256bit.org>
parents:
33027
diff
changeset
|
4210 |
33075
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4211 " Test for accessing a private member outside a class in a def function |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4212 def Test_private_member_access_outside_class() |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4213 # private object member variable |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4214 var lines =<< trim END |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4215 vim9script |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4216 class A |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4217 this._val = 10 |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4218 def GetVal(): number |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4219 return this._val |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4220 enddef |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4221 endclass |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4222 def T() |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4223 var a = A.new() |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4224 a._val = 20 |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4225 enddef |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4226 T() |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4227 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4228 v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable: _val', 2) |
33075
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4229 |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4230 # access a non-existing private object member variable |
33075
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4231 lines =<< trim END |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4232 vim9script |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4233 class A |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4234 this._val = 10 |
33075
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4235 endclass |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4236 def T() |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4237 var a = A.new() |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4238 a._a = 1 |
33075
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4239 enddef |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4240 T() |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4241 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4242 v9.CheckSourceFailure(lines, 'E1326: Variable not found on object "A": _a', 2) |
33173
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4243 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4244 # private static member variable |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4245 lines =<< trim END |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4246 vim9script |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4247 class A |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4248 static _val = 10 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4249 endclass |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4250 def T() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4251 var a = A.new() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4252 var x = a._val |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4253 enddef |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4254 T() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4255 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4256 v9.CheckSourceFailure(lines, 'E1375: Class variable "_val" accessible only using class "A"', 2) |
33173
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4257 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4258 # private static member variable |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4259 lines =<< trim END |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4260 vim9script |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4261 class A |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4262 static _val = 10 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4263 endclass |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4264 def T() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4265 var a = A.new() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4266 a._val = 3 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4267 enddef |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4268 T() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4269 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4270 v9.CheckSourceFailure(lines, 'E1375: Class variable "_val" accessible only using class "A"', 2) |
33173
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4271 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4272 # private static class variable |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4273 lines =<< trim END |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4274 vim9script |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4275 class A |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4276 static _val = 10 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4277 endclass |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4278 def T() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4279 var x = A._val |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4280 enddef |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4281 T() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4282 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4283 v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable: _val', 1) |
33173
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4284 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4285 # private static class variable |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4286 lines =<< trim END |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4287 vim9script |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4288 class A |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4289 static _val = 10 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4290 endclass |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4291 def T() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4292 A._val = 3 |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4293 enddef |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4294 T() |
9efd99a717c1
patch 9.0.1867: Vim9: access to interface statics possible
Christian Brabandt <cb@256bit.org>
parents:
33167
diff
changeset
|
4295 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4296 v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable: _val', 1) |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4297 enddef |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4298 |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4299 " Test for changing the member access of an interface in a implementation class |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4300 def Test_change_interface_member_access() |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4301 var lines =<< trim END |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4302 vim9script |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4303 interface A |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
4304 this.val: number |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4305 endinterface |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4306 class B implements A |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
4307 public this.val = 10 |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4308 endclass |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4309 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4310 v9.CheckSourceFailure(lines, 'E1367: Access level of variable "val" of interface "A" is different', 7) |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4311 |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4312 lines =<< trim END |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4313 vim9script |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4314 interface A |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4315 this.val: number |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4316 endinterface |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4317 class B implements A |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4318 public this.val = 10 |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4319 endclass |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4320 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4321 v9.CheckSourceFailure(lines, 'E1367: Access level of variable "val" of interface "A" is different', 7) |
33088
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4322 enddef |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4323 |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4324 " Test for trying to change a readonly member from a def function |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4325 def Test_readonly_member_change_in_def_func() |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4326 var lines =<< trim END |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4327 vim9script |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4328 class A |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4329 this.val: number |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4330 endclass |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4331 def T() |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4332 var a = A.new() |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4333 a.val = 20 |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4334 enddef |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4335 T() |
667a17904f64
patch 9.0.1829: Vim9 missing access-checks for private vars
Christian Brabandt <cb@256bit.org>
parents:
33075
diff
changeset
|
4336 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4337 v9.CheckSourceFailure(lines, 'E1335: Variable "val" in class "A" is not writable', 2) |
33075
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4338 enddef |
0346ff4c3ee7
patch 9.0.1824: Vim9: private members may be modifiable
Christian Brabandt <cb@256bit.org>
parents:
33070
diff
changeset
|
4339 |
33109
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4340 " Test for reading and writing a class member from a def function |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4341 def Test_modify_class_member_from_def_function() |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4342 var lines =<< trim END |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4343 vim9script |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4344 class A |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4345 this.var1: number = 10 |
33160
4ecf54d709b3
patch 9.0.1862: Vim9 Garbage Collection issues
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
4346 public static var2: list<number> = [1, 2] |
4ecf54d709b3
patch 9.0.1862: Vim9 Garbage Collection issues
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
4347 public static var3: dict<number> = {a: 1, b: 2} |
33109
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4348 static _priv_var4: number = 40 |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4349 endclass |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4350 def T() |
33160
4ecf54d709b3
patch 9.0.1862: Vim9 Garbage Collection issues
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
4351 assert_equal([1, 2], A.var2) |
4ecf54d709b3
patch 9.0.1862: Vim9 Garbage Collection issues
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
4352 assert_equal({a: 1, b: 2}, A.var3) |
4ecf54d709b3
patch 9.0.1862: Vim9 Garbage Collection issues
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
4353 A.var2 = [3, 4] |
4ecf54d709b3
patch 9.0.1862: Vim9 Garbage Collection issues
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
4354 A.var3 = {c: 3, d: 4} |
4ecf54d709b3
patch 9.0.1862: Vim9 Garbage Collection issues
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
4355 assert_equal([3, 4], A.var2) |
4ecf54d709b3
patch 9.0.1862: Vim9 Garbage Collection issues
Christian Brabandt <cb@256bit.org>
parents:
33109
diff
changeset
|
4356 assert_equal({c: 3, d: 4}, A.var3) |
33343
41b50abddeea
patch 9.0.1935: Vim9: not consistent error messages
Christian Brabandt <cb@256bit.org>
parents:
33337
diff
changeset
|
4357 assert_fails('echo A._priv_var4', 'E1333: Cannot access private variable: _priv_var4') |
33109
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4358 enddef |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4359 T() |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4360 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4361 v9.CheckSourceSuccess(lines) |
33109
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4362 enddef |
2b5cc29b0a0e
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Christian Brabandt <cb@256bit.org>
parents:
33092
diff
changeset
|
4363 |
33201
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4364 " Test for accessing a class member variable using an object |
33225
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4365 def Test_class_variable_access_using_object() |
33201
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4366 var lines =<< trim END |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4367 vim9script |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4368 class A |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4369 public static svar1: list<number> = [1] |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4370 public static svar2: list<number> = [2] |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4371 endclass |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4372 |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4373 A.svar1->add(3) |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4374 A.svar2->add(4) |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4375 assert_equal([1, 3], A.svar1) |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4376 assert_equal([2, 4], A.svar2) |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4377 |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4378 def Foo() |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4379 A.svar1->add(7) |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4380 A.svar2->add(8) |
33225
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4381 assert_equal([1, 3, 7], A.svar1) |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4382 assert_equal([2, 4, 8], A.svar2) |
33201
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4383 enddef |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4384 Foo() |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4385 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4386 v9.CheckSourceSuccess(lines) |
33225
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4387 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4388 # Cannot read from a class variable using an object in script context |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4389 lines =<< trim END |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4390 vim9script |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4391 class A |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4392 public this.var1: number |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4393 public static svar2: list<number> = [1] |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4394 endclass |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4395 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4396 var a = A.new() |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4397 echo a.svar2 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4398 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4399 v9.CheckSourceFailure(lines, 'E1375: Class variable "svar2" accessible only using class "A"', 8) |
33225
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4400 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4401 # Cannot write to a class variable using an object in script context |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4402 lines =<< trim END |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4403 vim9script |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4404 class A |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4405 public this.var1: number |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4406 public static svar2: list<number> = [1] |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4407 endclass |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4408 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4409 var a = A.new() |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4410 a.svar2 = [2] |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4411 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4412 v9.CheckSourceFailure(lines, 'E1375: Class variable "svar2" accessible only using class "A"', 8) |
33225
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4413 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4414 # Cannot read from a class variable using an object in def method context |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4415 lines =<< trim END |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4416 vim9script |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4417 class A |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4418 public this.var1: number |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4419 public static svar2: list<number> = [1] |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4420 endclass |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4421 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4422 def T() |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4423 var a = A.new() |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4424 echo a.svar2 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4425 enddef |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4426 T() |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4427 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4428 v9.CheckSourceFailure(lines, 'E1375: Class variable "svar2" accessible only using class "A"', 2) |
33225
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4429 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4430 # Cannot write to a class variable using an object in def method context |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4431 lines =<< trim END |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4432 vim9script |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4433 class A |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4434 public this.var1: number |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4435 public static svar2: list<number> = [1] |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4436 endclass |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4437 |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4438 def T() |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4439 var a = A.new() |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4440 a.svar2 = [2] |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4441 enddef |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4442 T() |
52b121d4feb5
patch 9.0.1887: Vim9: class members are accessible via object
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
4443 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4444 v9.CheckSourceFailure(lines, 'E1375: Class variable "svar2" accessible only using class "A"', 2) |
33201
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4445 enddef |
36c13b964eb3
patch 9.0.1879: Vim9: incorrect duplicate class member detection
Christian Brabandt <cb@256bit.org>
parents:
33173
diff
changeset
|
4446 |
33211
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4447 " Test for using a interface method using a child object |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4448 def Test_interface_method_from_child() |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4449 var lines =<< trim END |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4450 vim9script |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4451 |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4452 interface A |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4453 def Foo(): string |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4454 endinterface |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4455 |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4456 class B implements A |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4457 def Foo(): string |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4458 return 'foo' |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4459 enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4460 endclass |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4461 |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4462 class C extends B |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4463 def Bar(): string |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4464 return 'bar' |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4465 enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4466 endclass |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4467 |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4468 def T1(a: A) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4469 assert_equal('foo', a.Foo()) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4470 enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4471 |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4472 def T2(b: B) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4473 assert_equal('foo', b.Foo()) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4474 enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4475 |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4476 var c = C.new() |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4477 T1(c) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4478 T2(c) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4479 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4480 v9.CheckSourceSuccess(lines) |
33211
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4481 enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4482 |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4483 " Test for using an interface method using a child object when it is overridden |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4484 " by the child class. |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4485 " FIXME: This test fails. |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4486 " def Test_interface_overridden_method_from_child() |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4487 " var lines =<< trim END |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4488 " vim9script |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4489 " |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4490 " interface A |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4491 " def Foo(): string |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4492 " endinterface |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4493 " |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4494 " class B implements A |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4495 " def Foo(): string |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4496 " return 'b-foo' |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4497 " enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4498 " endclass |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4499 " |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4500 " class C extends B |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4501 " def Bar(): string |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4502 " return 'bar' |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4503 " enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4504 " def Foo(): string |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4505 " return 'c-foo' |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4506 " enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4507 " endclass |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4508 " |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4509 " def T1(a: A) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4510 " assert_equal('c-foo', a.Foo()) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4511 " enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4512 " |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4513 " def T2(b: B) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4514 " assert_equal('c-foo', b.Foo()) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4515 " enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4516 " |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4517 " var c = C.new() |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4518 " T1(c) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4519 " T2(c) |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4520 " END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4521 " v9.CheckSourceSuccess(lines) |
33211
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4522 " enddef |
71a097aab64d
patch 9.0.1883: Vim9: Calling an interface method using a child object fails
Christian Brabandt <cb@256bit.org>
parents:
33204
diff
changeset
|
4523 |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4524 " Test for abstract methods |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4525 def Test_abstract_method() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4526 # Use two abstract methods |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4527 var lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4528 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4529 abstract class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4530 def M1(): number |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4531 return 10 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4532 enddef |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4533 abstract def M2(): number |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4534 abstract def M3(): number |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4535 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4536 class B extends A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4537 def M2(): number |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4538 return 20 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4539 enddef |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4540 def M3(): number |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4541 return 30 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4542 enddef |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4543 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4544 var b = B.new() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4545 assert_equal([10, 20, 30], [b.M1(), b.M2(), b.M3()]) |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4546 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4547 v9.CheckSourceSuccess(lines) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4548 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4549 # Don't define an abstract method |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4550 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4551 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4552 abstract class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4553 abstract def Foo() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4554 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4555 class B extends A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4556 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4557 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4558 v9.CheckSourceFailure(lines, 'E1373: Abstract method "Foo" is not implemented', 6) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4559 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4560 # Use abstract method in a concrete class |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4561 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4562 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4563 class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4564 abstract def Foo() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4565 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4566 class B extends A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4567 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4568 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4569 v9.CheckSourceFailure(lines, 'E1372: Abstract method "abstract def Foo()" cannot be defined in a concrete class', 3) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4570 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4571 # Use abstract method in an interface |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4572 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4573 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4574 interface A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4575 abstract def Foo() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4576 endinterface |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4577 class B implements A |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
4578 def Foo() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
4579 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
4580 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
4581 END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
4582 v9.CheckSourceSuccess(lines) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4583 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4584 # Abbreviate the "abstract" keyword |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4585 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4586 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4587 class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4588 abs def Foo() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4589 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4590 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4591 v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: abs def Foo()', 3) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4592 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4593 # Use "abstract" with a member variable |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4594 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4595 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4596 abstract class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4597 abstract this.val = 10 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4598 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4599 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4600 v9.CheckSourceFailure(lines, 'E1371: Abstract must be followed by "def" or "static"', 3) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4601 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4602 # Use a static abstract method |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4603 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4604 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4605 abstract class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4606 abstract static def Foo(): number |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4607 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4608 class B extends A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4609 static def Foo(): number |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4610 return 4 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4611 enddef |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4612 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4613 assert_equal(4, B.Foo()) |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4614 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4615 v9.CheckSourceSuccess(lines) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4616 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4617 # Type mismatch between abstract method and concrete method |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4618 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4619 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4620 abstract class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4621 abstract def Foo(a: string, b: number): list<number> |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4622 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4623 class B extends A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4624 def Foo(a: number, b: string): list<string> |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4625 return [] |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4626 enddef |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4627 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4628 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4629 v9.CheckSourceFailure(lines, 'E1383: Method "Foo": type mismatch, expected func(string, number): list<number> but got func(number, string): list<string>', 9) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4630 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4631 # Use an abstract class to invoke an abstract method |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4632 # FIXME: This should fail |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4633 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4634 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4635 abstract class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4636 abstract static def Foo() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4637 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4638 A.Foo() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4639 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4640 v9.CheckSourceSuccess(lines) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4641 |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4642 # Invoke an abstract method from a def function |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4643 lines =<< trim END |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4644 vim9script |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4645 abstract class A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4646 abstract def Foo(): list<number> |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4647 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4648 class B extends A |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4649 def Foo(): list<number> |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4650 return [3, 5] |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4651 enddef |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4652 endclass |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4653 def Bar(c: B) |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4654 assert_equal([3, 5], c.Foo()) |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4655 enddef |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4656 var b = B.new() |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4657 Bar(b) |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4658 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4659 v9.CheckSourceSuccess(lines) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4660 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4661 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4662 " Test for calling a class method from a subclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4663 def Test_class_method_call_from_subclass() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4664 # class method call from a subclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4665 var lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4666 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4667 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4668 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4669 static def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4670 echo "foo" |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4671 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4672 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4673 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4674 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4675 def Bar() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4676 Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4677 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4678 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4679 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4680 var b = B.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4681 b.Bar() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4682 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4683 v9.CheckSourceFailure(lines, 'E1384: Class method "Foo" accessible only inside class "A"', 1) |
33217
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4684 enddef |
499ba27ba0f6
patch 9.0.1885: Vim9: no support for abstract methods
Christian Brabandt <cb@256bit.org>
parents:
33211
diff
changeset
|
4685 |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4686 " Test for calling a class method using an object in a def function context and |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4687 " script context. |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4688 def Test_class_method_call_using_object() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4689 # script context |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4690 var lines =<< trim END |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4691 vim9script |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4692 class A |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4693 static def Foo(): list<string> |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4694 return ['a', 'b'] |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4695 enddef |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4696 def Bar() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4697 assert_equal(['a', 'b'], A.Foo()) |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4698 assert_equal(['a', 'b'], Foo()) |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4699 enddef |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4700 endclass |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4701 |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4702 def T() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4703 assert_equal(['a', 'b'], A.Foo()) |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4704 var t_a = A.new() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4705 t_a.Bar() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4706 enddef |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4707 |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4708 assert_equal(['a', 'b'], A.Foo()) |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4709 var a = A.new() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4710 a.Bar() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4711 T() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4712 END |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4713 v9.CheckSourceSuccess(lines) |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4714 |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4715 # script context |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4716 lines =<< trim END |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4717 vim9script |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4718 class A |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4719 static def Foo(): string |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4720 return 'foo' |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4721 enddef |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4722 endclass |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4723 |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4724 var a = A.new() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4725 assert_equal('foo', a.Foo()) |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4726 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4727 v9.CheckSourceFailure(lines, 'E1385: Class method "Foo" accessible only using class "A"', 9) |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4728 |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4729 # def function context |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4730 lines =<< trim END |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4731 vim9script |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4732 class A |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4733 static def Foo(): string |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4734 return 'foo' |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4735 enddef |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4736 endclass |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4737 |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4738 def T() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4739 var a = A.new() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4740 assert_equal('foo', a.Foo()) |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4741 enddef |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4742 T() |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
4743 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4744 v9.CheckSourceFailure(lines, 'E1385: Class method "Foo" accessible only using class "A"', 2) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4745 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4746 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4747 def Test_class_variable() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4748 var lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4749 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4750 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4751 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4752 public static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4753 static def ClassFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4754 assert_equal(10, val) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4755 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4756 def ObjFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4757 assert_equal(10, val) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4758 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4759 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4760 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4761 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4762 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4763 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4764 assert_equal(10, A.val) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4765 A.ClassFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4766 var a = A.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4767 a.ObjFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4768 var b = B.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4769 b.ObjFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4770 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4771 def T1(a1: A) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4772 a1.ObjFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4773 A.ClassFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4774 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4775 T1(b) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4776 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4777 A.val = 20 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4778 assert_equal(20, A.val) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4779 END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4780 v9.CheckSourceSuccess(lines) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4781 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4782 # Modifying a parent class variable from a child class method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4783 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4784 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4785 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4786 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4787 static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4788 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4789 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4790 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4791 static def ClassFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4792 val = 20 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4793 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4794 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4795 B.ClassFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4796 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4797 v9.CheckSourceFailure(lines, 'E1374: Class variable "val" accessible only inside class "A"', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4798 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4799 # Reading a parent class variable from a child class method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4800 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4801 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4802 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4803 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4804 static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4805 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4806 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4807 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4808 static def ClassFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4809 var i = val |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4810 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4811 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4812 B.ClassFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4813 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4814 v9.CheckSourceFailure(lines, 'E1374: Class variable "val" accessible only inside class "A"', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4815 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4816 # Modifying a parent class variable from a child object method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4817 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4818 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4819 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4820 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4821 static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4822 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4823 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4824 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4825 def ObjFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4826 val = 20 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4827 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4828 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4829 var b = B.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4830 b.ObjFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4831 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4832 v9.CheckSourceFailure(lines, 'E1374: Class variable "val" accessible only inside class "A"', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4833 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4834 # Reading a parent class variable from a child object method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4835 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4836 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4837 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4838 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4839 static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4840 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4841 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4842 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4843 def ObjFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4844 var i = val |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4845 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4846 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4847 var b = B.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4848 b.ObjFunc() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4849 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4850 v9.CheckSourceFailure(lines, 'E1374: Class variable "val" accessible only inside class "A"', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4851 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4852 # Modifying a class variable using an object at script level |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4853 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4854 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4855 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4856 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4857 static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4858 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4859 var a = A.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4860 a.val = 20 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4861 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4862 v9.CheckSourceFailure(lines, 'E1375: Class variable "val" accessible only using class "A"', 7) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4863 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4864 # Reading a class variable using an object at script level |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4865 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4866 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4867 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4868 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4869 static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4870 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4871 var a = A.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4872 var i = a.val |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4873 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4874 v9.CheckSourceFailure(lines, 'E1375: Class variable "val" accessible only using class "A"', 7) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4875 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4876 # Modifying a class variable using an object at function level |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4877 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4878 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4879 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4880 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4881 static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4882 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4883 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4884 def T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4885 var a = A.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4886 a.val = 20 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4887 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4888 T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4889 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4890 v9.CheckSourceFailure(lines, 'E1375: Class variable "val" accessible only using class "A"', 2) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4891 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4892 # Reading a class variable using an object at function level |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4893 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4894 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4895 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4896 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4897 static val: number = 10 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4898 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4899 def T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4900 var a = A.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4901 var i = a.val |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4902 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4903 T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4904 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
4905 v9.CheckSourceFailure(lines, 'E1375: Class variable "val" accessible only using class "A"', 2) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4906 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4907 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4908 " Test for using a duplicate class method and class variable in a child class |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4909 def Test_dup_class_member() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4910 # duplicate class variable, class method and overridden object method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4911 var lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4912 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4913 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4914 static sval = 100 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4915 static def Check() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4916 assert_equal(100, sval) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4917 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4918 def GetVal(): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4919 return sval |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4920 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4921 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4922 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4923 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4924 static sval = 200 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4925 static def Check() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4926 assert_equal(200, sval) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4927 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4928 def GetVal(): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4929 return sval |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4930 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4931 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4932 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4933 def T1(aa: A): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4934 return aa.GetVal() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4935 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4936 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4937 def T2(bb: B): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4938 return bb.GetVal() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4939 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4940 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4941 assert_equal(100, A.sval) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4942 assert_equal(200, B.sval) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4943 var a = A.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4944 assert_equal(100, a.GetVal()) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4945 var b = B.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4946 assert_equal(200, b.GetVal()) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4947 assert_equal(200, T1(b)) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4948 assert_equal(200, T2(b)) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4949 END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4950 v9.CheckSourceSuccess(lines) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4951 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4952 # duplicate class variable and class method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4953 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4954 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4955 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4956 static sval = 100 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4957 static def Check() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4958 assert_equal(100, sval) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4959 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4960 def GetVal(): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4961 return sval |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4962 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4963 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4964 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4965 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4966 static sval = 200 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4967 static def Check() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4968 assert_equal(200, sval) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4969 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4970 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4971 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4972 def T1(aa: A): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4973 return aa.GetVal() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4974 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4975 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4976 def T2(bb: B): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4977 return bb.GetVal() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4978 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4979 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4980 assert_equal(100, A.sval) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4981 assert_equal(200, B.sval) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4982 var a = A.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4983 assert_equal(100, a.GetVal()) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4984 var b = B.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4985 assert_equal(100, b.GetVal()) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4986 assert_equal(100, T1(b)) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4987 assert_equal(100, T2(b)) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4988 END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4989 v9.CheckSourceSuccess(lines) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4990 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4991 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4992 " Test for calling an instance method using the class |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4993 def Test_instance_method_call_using_class() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4994 # Invoke an object method using a class in script context |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4995 var lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4996 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4997 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4998 def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
4999 echo "foo" |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5000 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5001 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5002 A.Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5003 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5004 v9.CheckSourceFailure(lines, 'E1386: Object method "Foo" accessible only using class "A" object', 7) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5005 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5006 # Invoke an object method using a class in def function context |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5007 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5008 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5009 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5010 def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5011 echo "foo" |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5012 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5013 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5014 def T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5015 A.Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5016 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5017 T() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5018 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5019 v9.CheckSourceFailure(lines, 'E1386: Object method "Foo" accessible only using class "A" object', 1) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5020 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5021 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5022 " Test for duplicate class method and instance method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5023 def Test_dup_classmethod_objmethod() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5024 # Duplicate instance method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5025 var lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5026 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5027 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5028 static def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5029 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5030 def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5031 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5032 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5033 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5034 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: Foo', 6) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5035 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5036 # Duplicate private instance method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5037 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5038 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5039 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5040 static def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5041 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5042 def _Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5043 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5044 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5045 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5046 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: _Foo', 6) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5047 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5048 # Duplicate class method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5049 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5050 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5051 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5052 def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5053 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5054 static def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5055 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5056 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5057 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5058 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: Foo', 6) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5059 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5060 # Duplicate private class method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5061 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5062 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5063 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5064 def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5065 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5066 static def _Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5067 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5068 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5069 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5070 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: _Foo', 6) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5071 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5072 # Duplicate private class and object method |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5073 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5074 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5075 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5076 def _Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5077 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5078 static def _Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5079 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5080 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5081 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5082 v9.CheckSourceFailure(lines, 'E1355: Duplicate function: _Foo', 6) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5083 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5084 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5085 " Test for an instance method access level comparison with parent instance |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5086 " methods. |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5087 def Test_instance_method_access_level() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5088 # Private method in subclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5089 var lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5090 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5091 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5092 def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5093 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5094 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5095 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5096 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5097 class C extends B |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5098 def _Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5099 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5100 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5101 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5102 v9.CheckSourceFailure(lines, 'E1377: Access level of method "_Foo" is different in class "A"', 11) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5103 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5104 # Public method in subclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5105 lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5106 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5107 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5108 def _Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5109 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5110 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5111 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5112 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5113 class C extends B |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5114 def Foo() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5115 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5116 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5117 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5118 v9.CheckSourceFailure(lines, 'E1377: Access level of method "Foo" is different in class "A"', 11) |
33260
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5119 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5120 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5121 def Test_extend_empty_class() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5122 var lines =<< trim END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5123 vim9script |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5124 class A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5125 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5126 class B extends A |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5127 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5128 class C extends B |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5129 public static rw_class_var = 1 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5130 public this.rw_obj_var = 2 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5131 static def ClassMethod(): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5132 return 3 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5133 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5134 def ObjMethod(): number |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5135 return 4 |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5136 enddef |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5137 endclass |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5138 assert_equal(1, C.rw_class_var) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5139 assert_equal(3, C.ClassMethod()) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5140 var c = C.new() |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5141 assert_equal(2, c.rw_obj_var) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5142 assert_equal(4, c.ObjMethod()) |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5143 END |
aba1fa2b7d1e
patch 9.0.1898: Vim9: restrict access to static vars
Christian Brabandt <cb@256bit.org>
parents:
33227
diff
changeset
|
5144 v9.CheckSourceSuccess(lines) |
33227
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
5145 enddef |
3672d3d13524
patch 9.0.1888: Vim9: Problem trying to invoke class method
Christian Brabandt <cb@256bit.org>
parents:
33225
diff
changeset
|
5146 |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5147 " A interface cannot have a static variable or a static method or a private |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5148 " variable or a private method or a public variable |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5149 def Test_interface_with_unsupported_members() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5150 var lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5151 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5152 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5153 static num: number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5154 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5155 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5156 v9.CheckSourceFailure(lines, 'E1378: Static member not supported in an interface', 3) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5157 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5158 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5159 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5160 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5161 static _num: number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5162 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5163 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5164 v9.CheckSourceFailure(lines, 'E1378: Static member not supported in an interface', 3) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5165 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5166 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5167 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5168 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5169 public static num: number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5170 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5171 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5172 v9.CheckSourceFailure(lines, 'E1387: Public variable not supported in an interface', 3) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5173 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5174 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5175 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5176 interface A |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5177 public static num: number |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5178 endinterface |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5179 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5180 v9.CheckSourceFailure(lines, 'E1387: Public variable not supported in an interface', 3) |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5181 |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5182 lines =<< trim END |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5183 vim9script |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5184 interface A |
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5185 static _num: number |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5186 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5187 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5188 v9.CheckSourceFailure(lines, 'E1378: Static member not supported in an interface', 3) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5189 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5190 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5191 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5192 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5193 static def Foo(d: dict<any>): list<string> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5194 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5195 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5196 v9.CheckSourceFailure(lines, 'E1378: Static member not supported in an interface', 3) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5197 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5198 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5199 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5200 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5201 static def _Foo(d: dict<any>): list<string> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5202 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5203 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5204 v9.CheckSourceFailure(lines, 'E1378: Static member not supported in an interface', 3) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5205 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5206 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5207 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5208 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5209 this._Foo: list<string> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5210 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5211 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5212 v9.CheckSourceFailure(lines, 'E1379: Private variable not supported in an interface', 3) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5213 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5214 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5215 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5216 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5217 def _Foo(d: dict<any>): list<string> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5218 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5219 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5220 v9.CheckSourceFailure(lines, 'E1380: Private method not supported in an interface', 3) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5221 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5222 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5223 " Test for extending an interface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5224 def Test_extend_interface() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5225 var lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5226 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5227 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5228 this.var1: list<string> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5229 def Foo() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5230 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5231 interface B extends A |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5232 this.var2: dict<string> |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5233 def Bar() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5234 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5235 class C implements A, B |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5236 this.var1 = [1, 2] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5237 def Foo() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5238 enddef |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5239 this.var2 = {a: '1'} |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5240 def Bar() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5241 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5242 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5243 END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5244 v9.CheckSourceSuccess(lines) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5245 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5246 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5247 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5248 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5249 def Foo() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5250 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5251 interface B extends A |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5252 this.var2: dict<string> |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5253 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5254 class C implements A, B |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5255 this.var2 = {a: '1'} |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5256 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5257 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5258 v9.CheckSourceFailure(lines, 'E1349: Method "Foo" of interface "A" is not implemented', 10) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5259 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5260 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5261 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5262 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5263 def Foo() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5264 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5265 interface B extends A |
33372
3e9a91624b40
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Christian Brabandt <cb@256bit.org>
parents:
33343
diff
changeset
|
5266 this.var2: dict<string> |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5267 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5268 class C implements A, B |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5269 def Foo() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5270 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5271 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5272 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5273 v9.CheckSourceFailure(lines, 'E1348: Variable "var2" of interface "B" is not implemented', 11) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5274 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5275 # interface cannot extend a class |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5276 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5277 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5278 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5279 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5280 interface B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5281 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5282 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5283 v9.CheckSourceFailure(lines, 'E1354: Cannot extend A', 5) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5284 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5285 # class cannot extend an interface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5286 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5287 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5288 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5289 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5290 class B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5291 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5292 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5293 v9.CheckSourceFailure(lines, 'E1354: Cannot extend A', 5) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5294 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5295 # interface cannot implement another interface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5296 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5297 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5298 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5299 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5300 interface B implements A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5301 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5302 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5303 v9.CheckSourceFailure(lines, 'E1381: Interface cannot use "implements"', 4) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5304 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5305 # interface cannot extend multiple interfaces |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5306 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5307 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5308 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5309 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5310 interface B |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5311 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5312 interface C extends A, B |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5313 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5314 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5315 v9.CheckSourceFailure(lines, 'E1315: White space required after name: A, B', 6) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5316 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5317 # Variable type in an extended interface is of different type |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5318 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5319 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5320 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5321 this.val1: number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5322 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5323 interface B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5324 this.val2: string |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5325 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5326 interface C extends B |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5327 this.val1: string |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5328 this.val2: number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5329 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5330 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5331 v9.CheckSourceFailure(lines, 'E1382: Variable "val1": type mismatch, expected number but got string', 11) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5332 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5333 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5334 " Test for a child class implementing an interface when some of the methods are |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5335 " defined in the parent class. |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5336 def Test_child_class_implements_interface() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5337 var lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5338 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5339 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5340 interface Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5341 def F1(): list<list<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5342 def F2(): list<list<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5343 def F3(): list<list<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5344 this.var1: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5345 this.var2: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5346 this.var3: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5347 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5348 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5349 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5350 def A1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5351 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5352 def F3(): list<list<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5353 return [[3]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5354 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5355 this.v1: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5356 this.var3 = [{c: 30}] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5357 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5358 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5359 class B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5360 def B1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5361 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5362 def F2(): list<list<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5363 return [[2]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5364 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5365 this.v2: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5366 this.var2 = [{b: 20}] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5367 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5368 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5369 class C extends B implements Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5370 def C1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5371 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5372 def F1(): list<list<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5373 return [[1]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5374 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5375 this.v3: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5376 this.var1 = [{a: 10}] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5377 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5378 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5379 def T(if: Intf) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5380 assert_equal([[1]], if.F1()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5381 assert_equal([[2]], if.F2()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5382 assert_equal([[3]], if.F3()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5383 assert_equal([{a: 10}], if.var1) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5384 assert_equal([{b: 20}], if.var2) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5385 assert_equal([{c: 30}], if.var3) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5386 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5387 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5388 var c = C.new() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5389 T(c) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5390 assert_equal([[1]], c.F1()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5391 assert_equal([[2]], c.F2()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5392 assert_equal([[3]], c.F3()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5393 assert_equal([{a: 10}], c.var1) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5394 assert_equal([{b: 20}], c.var2) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5395 assert_equal([{c: 30}], c.var3) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5396 END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5397 v9.CheckSourceSuccess(lines) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5398 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5399 # One of the interface methods is not found |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5400 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5401 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5402 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5403 interface Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5404 def F1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5405 def F2() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5406 def F3() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5407 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5408 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5409 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5410 def A1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5411 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5412 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5413 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5414 class B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5415 def B1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5416 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5417 def F2() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5418 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5419 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5420 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5421 class C extends B implements Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5422 def C1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5423 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5424 def F1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5425 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5426 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5427 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5428 v9.CheckSourceFailure(lines, 'E1349: Method "F3" of interface "Intf" is not implemented', 26) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5429 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5430 # One of the interface methods is of different type |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5431 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5432 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5433 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5434 interface Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5435 def F1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5436 def F2() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5437 def F3() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5438 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5439 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5440 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5441 def F3(): number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5442 return 0 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5443 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5444 def A1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5445 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5446 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5447 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5448 class B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5449 def B1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5450 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5451 def F2() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5452 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5453 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5454 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5455 class C extends B implements Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5456 def C1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5457 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5458 def F1() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5459 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5460 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5461 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5462 v9.CheckSourceFailure(lines, 'E1383: Method "F3": type mismatch, expected func() but got func(): number', 29) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5463 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5464 # One of the interface variables is not present |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5465 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5466 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5467 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5468 interface Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5469 this.var1: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5470 this.var2: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5471 this.var3: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5472 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5473 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5474 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5475 this.v1: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5476 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5477 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5478 class B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5479 this.v2: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5480 this.var2 = [{b: 20}] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5481 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5482 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5483 class C extends B implements Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5484 this.v3: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5485 this.var1 = [{a: 10}] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5486 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5487 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5488 v9.CheckSourceFailure(lines, 'E1348: Variable "var3" of interface "Intf" is not implemented', 21) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5489 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5490 # One of the interface variables is of different type |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5491 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5492 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5493 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5494 interface Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5495 this.var1: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5496 this.var2: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5497 this.var3: list<dict<number>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5498 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5499 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5500 class A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5501 this.v1: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5502 this.var3: list<dict<string>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5503 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5504 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5505 class B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5506 this.v2: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5507 this.var2 = [{b: 20}] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5508 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5509 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5510 class C extends B implements Intf |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5511 this.v3: list<list<number>> = [[0]] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5512 this.var1 = [{a: 10}] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5513 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5514 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5515 v9.CheckSourceFailure(lines, 'E1382: Variable "var3": type mismatch, expected list<dict<number>> but got list<dict<string>>', 22) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5516 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5517 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5518 " Test for extending an interface with duplicate variables and methods |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5519 def Test_interface_extends_with_dup_members() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5520 var lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5521 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5522 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5523 this.n1: number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5524 def Foo1(): number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5525 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5526 interface B extends A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5527 this.n2: number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5528 this.n1: number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5529 def Foo2(): number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5530 def Foo1(): number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5531 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5532 class C implements B |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5533 this.n1 = 10 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5534 this.n2 = 20 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5535 def Foo1(): number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5536 return 30 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5537 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5538 def Foo2(): number |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5539 return 40 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5540 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5541 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5542 def T1(a: A) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5543 assert_equal(10, a.n1) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5544 assert_equal(30, a.Foo1()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5545 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5546 def T2(b: B) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5547 assert_equal(10, b.n1) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5548 assert_equal(20, b.n2) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5549 assert_equal(30, b.Foo1()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5550 assert_equal(40, b.Foo2()) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5551 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5552 var c = C.new() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5553 T1(c) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5554 T2(c) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5555 END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5556 v9.CheckSourceSuccess(lines) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5557 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5558 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5559 " Test for using "any" type for a variable in a sub-class while it has a |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5560 " concrete type in the interface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5561 def Test_implements_using_var_type_any() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5562 var lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5563 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5564 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5565 this.val: list<dict<string>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5566 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5567 class B implements A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5568 this.val = [{a: '1'}, {b: '2'}] |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5569 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5570 var b = B.new() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5571 assert_equal([{a: '1'}, {b: '2'}], b.val) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5572 END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5573 v9.CheckSourceSuccess(lines) |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5574 |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5575 # initialize instance variable using a different type |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5576 lines =<< trim END |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5577 vim9script |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5578 interface A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5579 this.val: list<dict<string>> |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5580 endinterface |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5581 class B implements A |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5582 this.val = {a: 1, b: 2} |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5583 endclass |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5584 var b = B.new() |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5585 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5586 v9.CheckSourceFailure(lines, 'E1382: Variable "val": type mismatch, expected list<dict<string>> but got dict<number>', 1) |
33278
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5587 enddef |
b5ed566262d3
patch 9.0.1906: Vim9: Interfaces should not support class methods and variables
Christian Brabandt <cb@256bit.org>
parents:
33260
diff
changeset
|
5588 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5589 " Test for assigning to a member variable in a nested class |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5590 def Test_nested_object_assignment() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5591 var lines =<< trim END |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5592 vim9script |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5593 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5594 class A |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5595 this.value: number |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5596 endclass |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5597 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5598 class B |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5599 this.a: A = A.new() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5600 endclass |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5601 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5602 class C |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5603 this.b: B = B.new() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5604 endclass |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5605 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5606 class D |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5607 this.c: C = C.new() |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5608 endclass |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5609 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5610 def T(da: D) |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5611 da.c.b.a.value = 10 |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5612 enddef |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5613 |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5614 var d = D.new() |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5615 T(d) |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5616 END |
33385
b5ad84fdc702
patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI
Christian Brabandt <cb@256bit.org>
parents:
33381
diff
changeset
|
5617 v9.CheckSourceFailure(lines, 'E1335: Variable "value" in class "A" is not writable', 1) |
33286
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5618 enddef |
0c3553cfe22e
patch 9.0.1909: Vim9: problem calling class method from other class
Christian Brabandt <cb@256bit.org>
parents:
33278
diff
changeset
|
5619 |
33297
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5620 " Test for calling methods using a null object |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5621 def Test_null_object_method_call() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5622 # Calling a object method using a null object in script context |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5623 var lines =<< trim END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5624 vim9script |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5625 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5626 class C |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5627 def Foo() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5628 assert_report('This method should not be executed') |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5629 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5630 endclass |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5631 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5632 var o: C |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5633 o.Foo() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5634 END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5635 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 10) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5636 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5637 # Calling a object method using a null object in def function context |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5638 lines =<< trim END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5639 vim9script |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5640 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5641 class C |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5642 def Foo() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5643 assert_report('This method should not be executed') |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5644 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5645 endclass |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5646 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5647 def T() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5648 var o: C |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5649 o.Foo() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5650 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5651 T() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5652 END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5653 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 2) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5654 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5655 # Calling a object method through another class method using a null object in |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5656 # script context |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5657 lines =<< trim END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5658 vim9script |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5659 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5660 class C |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5661 def Foo() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5662 assert_report('This method should not be executed') |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5663 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5664 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5665 static def Bar(o_any: any) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5666 var o_typed: C = o_any |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5667 o_typed.Foo() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5668 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5669 endclass |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5670 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5671 var o: C |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5672 C.Bar(o) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5673 END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5674 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 2) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5675 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5676 # Calling a object method through another class method using a null object in |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5677 # def function context |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5678 lines =<< trim END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5679 vim9script |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5680 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5681 class C |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5682 def Foo() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5683 assert_report('This method should not be executed') |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5684 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5685 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5686 static def Bar(o_any: any) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5687 var o_typed: C = o_any |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5688 o_typed.Foo() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5689 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5690 endclass |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5691 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5692 def T() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5693 var o: C |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5694 C.Bar(o) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5695 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5696 T() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5697 END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5698 v9.CheckSourceFailure(lines, 'E1360: Using a null object', 2) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5699 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5700 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5701 " Test for using a dict as an object member |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5702 def Test_dict_object_member() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5703 var lines =<< trim END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5704 vim9script |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5705 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5706 class Context |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5707 public this.state: dict<number> = {} |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5708 def GetState(): dict<number> |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5709 return this.state |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5710 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5711 endclass |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5712 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5713 var ctx = Context.new() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5714 ctx.state->extend({a: 1}) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5715 ctx.state['b'] = 2 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5716 assert_equal({a: 1, b: 2}, ctx.GetState()) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5717 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5718 def F() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5719 ctx.state['c'] = 3 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5720 assert_equal({a: 1, b: 2, c: 3}, ctx.GetState()) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5721 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5722 F() |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5723 assert_equal(3, ctx.state.c) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5724 ctx.state.c = 4 |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5725 assert_equal(4, ctx.state.c) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5726 END |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5727 v9.CheckSourceSuccess(lines) |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5728 enddef |
6340c608ca54
patch 9.0.1914: Vim9: few issues when accessing object members
Christian Brabandt <cb@256bit.org>
parents:
33291
diff
changeset
|
5729 |
33337
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5730 " The following test was failing after 9.0.1914. This was caused by using a |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5731 " freed object from a previous method call. |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5732 def Test_freed_object_from_previous_method_call() |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5733 var lines =<< trim END |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5734 vim9script |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5735 |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5736 class Context |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5737 endclass |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5738 |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5739 class Result |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5740 endclass |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5741 |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5742 def Failure(): Result |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5743 return Result.new() |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5744 enddef |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5745 |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5746 def GetResult(ctx: Context): Result |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5747 return Failure() |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5748 enddef |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5749 |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5750 def Test_GetResult() |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5751 var ctx = Context.new() |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5752 var result = GetResult(ctx) |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5753 enddef |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5754 |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5755 Test_GetResult() |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5756 END |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5757 v9.CheckSourceSuccess(lines) |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5758 enddef |
19b4f85c2649
patch 9.0.1932: Vim9: error when using null object constructor
Christian Brabandt <cb@256bit.org>
parents:
33326
diff
changeset
|
5759 |
33381
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5760 " Test for duplicate object and class variable |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5761 def Test_duplicate_variable() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5762 # Object variable name is same as the class variable name |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5763 var lines =<< trim END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5764 vim9script |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5765 class A |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5766 public static sval: number |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5767 public this.sval: number |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5768 endclass |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5769 var a = A.new() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5770 END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5771 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: sval', 4) |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5772 |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5773 # Duplicate variable name and calling a class method |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5774 lines =<< trim END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5775 vim9script |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5776 class A |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5777 public static sval: number |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5778 public this.sval: number |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5779 def F1() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5780 echo this.sval |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5781 enddef |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5782 static def F2() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5783 echo sval |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5784 enddef |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5785 endclass |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5786 A.F2() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5787 END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5788 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: sval', 4) |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5789 |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5790 # Duplicate variable with an empty constructor |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5791 lines =<< trim END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5792 vim9script |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5793 class A |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5794 public static sval: number |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5795 public this.sval: number |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5796 def new() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5797 enddef |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5798 endclass |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5799 var a = A.new() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5800 END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5801 v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: sval', 4) |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5802 enddef |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5803 |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5804 " Test for using a reserved keyword as a variable name |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5805 def Test_reserved_varname() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5806 for kword in ['true', 'false', 'null', 'null_blob', 'null_dict', |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5807 'null_function', 'null_list', 'null_partial', 'null_string', |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5808 'null_channel', 'null_job', 'super', 'this'] |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5809 |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5810 var lines =<< trim eval END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5811 vim9script |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5812 class C |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5813 public this.{kword}: list<number> = [1, 2, 3] |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5814 endclass |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5815 var o = C.new() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5816 END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5817 v9.CheckSourceFailure(lines, $'E1034: Cannot use reserved name {kword}', 3) |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5818 |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5819 lines =<< trim eval END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5820 vim9script |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5821 class C |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5822 public this.{kword}: list<number> = [1, 2, 3] |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5823 def new() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5824 enddef |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5825 endclass |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5826 var o = C.new() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5827 END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5828 v9.CheckSourceFailure(lines, $'E1034: Cannot use reserved name {kword}', 3) |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5829 |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5830 lines =<< trim eval END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5831 vim9script |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5832 class C |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5833 public this.{kword}: list<number> = [1, 2, 3] |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5834 def new() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5835 enddef |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5836 def F() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5837 echo this.{kword} |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5838 enddef |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5839 endclass |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5840 var o = C.new() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5841 o.F() |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5842 END |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5843 v9.CheckSourceFailure(lines, $'E1034: Cannot use reserved name {kword}', 3) |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5844 endfor |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5845 enddef |
17301c641749
patch 9.0.1949: Vim9: allows reserved keywords as members
Christian Brabandt <cb@256bit.org>
parents:
33379
diff
changeset
|
5846 |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5847 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |