@@ -3,9 +3,11 @@ import term
33import v.util.diff
44
55const vroot = os.real_path (@VMODROOT)
6+ const tmp_dir = os.real_path (os.temp_dir ())
67
78const text_file_orig = os.join_path (vroot, 'vlib' , 'v' , 'tests' , 'vls' , 'sample_text.vv' )
8- const text_file = os.join_path (os.temp_dir (), 'sample_text.v' )
9+ const text_file = os.join_path (tmp_dir, 'sample_text.v' )
10+ const text_file_result = $if windows { text_file.replace ('\\ ' , '/' ) } $else { text_file }
911
1012fn testsuite_begin () {
1113 eprintln ('testsuite_begin, text_file = ${text_file }' )
@@ -33,6 +35,82 @@ const test_data = [
3335{"kind":21,"label":"public_const1","detail":"","documentation":""}
3436]}'
3537 },
38+ TestData{
39+ cmd: 'v -w -vls-mode -check -json-errors ${os .quoted_path (text_file )}'
40+ output: '[
41+ {
42+ "path":"${text_file }",
43+ "message":"undefined ident: `a`",
44+ "line_nr":14,
45+ "col":4,
46+ "len":0
47+ }
48+ ,
49+ {
50+ "path":"${text_file }",
51+ "message":"operator `+=` not defined on left operand type `void`",
52+ "line_nr":14,
53+ "col":4,
54+ "len":0
55+ }
56+ ,
57+ {
58+ "path":"${text_file }",
59+ "message":"cannot assign to `a`: expected `void`, not `int`",
60+ "line_nr":14,
61+ "col":9,
62+ "len":0
63+ }
64+ ,
65+ {
66+ "path":"${text_file }",
67+ "message":"undefined ident: `s`",
68+ "line_nr":18,
69+ "col":2,
70+ "len":0
71+ }
72+ ]
73+ '
74+ },
75+ TestData{
76+ cmd: 'v -check -nocolor -vls-mode ${os .quoted_path (text_file )}'
77+ output: '${text_file_result }:14:4: error: undefined ident: `a`
78+ 12 | // add add `val` to `a`
79+ 13 | fn (mut m MyS) add(val int) {
80+ 14 | m.a += val
81+ | ^
82+ 15 | }
83+ 16 |
84+ ${text_file_result }:14:4: error: operator `+=` not defined on left operand type `void`
85+ 12 | // add add `val` to `a`
86+ 13 | fn (mut m MyS) add(val int) {
87+ 14 | m.a += val
88+ | ^
89+ 15 | }
90+ 16 |
91+ ${text_file_result }:14:9: error: cannot assign to `a`: expected `void`, not `int`
92+ 12 | // add add `val` to `a`
93+ 13 | fn (mut m MyS) add(val int) {
94+ 14 | m.a += val
95+ | ~~~
96+ 15 | }
97+ 16 |
98+ ${text_file_result }:18:2: error: undefined ident: `s`
99+ 16 |
100+ 17 | fn main() {
101+ 18 | s.
102+ | ^
103+ 19 | //sample_mod2.
104+ 20 | //mut k := MyS{}
105+ ${text_file_result }:5:8: warning: module \' sample_mod2 (v.tests.vls.sample_mod2)\' is imported but never used
106+ 3 |
107+ 4 | import v.tests.vls.sample_mod1 as s
108+ 5 | import v.tests.vls.sample_mod2
109+ | ~~~~~~~~~~~~~~~~~~~~~~~
110+ 6 |
111+ 7 | struct MyS{
112+ '
113+ },
36114]
37115
38116fn test_main () {
0 commit comments