@@ -2,25 +2,54 @@ import os
2
2
3
3
const vexe = os.quoted_path (@VEXE)
4
4
const vmodules_tdir = os.join_path (os.vtmp_dir (), 'fmt_vmodules_test' )
5
- const module_tdir = os.join_path (vmodules_tdir, 'foo' )
6
5
7
6
fn testsuite_begin () {
8
- os.mkdir_all (module_tdir ) or {}
7
+ os.mkdir_all (vmodules_tdir ) or {}
9
8
os.setenv ('VMODULES' , vmodules_tdir, true )
10
9
}
11
10
12
11
fn testsuite_end () {
13
12
os.rmdir_all (vmodules_tdir) or {}
14
13
}
15
14
16
- fn test_fmt_vmodules () {
15
+ fn test_fmt_imports () {
16
+ mod_tdir := os.join_path (vmodules_tdir, @FN)
17
+ os.mkdir_all (mod_tdir)!
17
18
tfile_content := [
18
19
'import x.json2 as json' ,
19
20
'import datatypes { Stack }' ,
20
21
'' ,
21
22
'const foo = Stack[string]{}' ,
22
23
'' ,
23
24
].join_lines ()
24
- os.write_file (os.join_path (module_tdir, 'main.v' ), tfile_content)!
25
- os.execute_opt ('${vexe} fmt -c ${module_tdir} ' ) or { assert false , err.msg () }
25
+ os.write_file (os.join_path (mod_tdir, 'main.v' ), tfile_content)!
26
+ os.execute_opt ('${vexe} fmt -c ${mod_tdir} ' ) or { assert false , err.msg () }
27
+ }
28
+
29
+ fn test_fmt_submod_type_alias () {
30
+ mod_tdir := os.join_path (vmodules_tdir, @FN)
31
+ mod_src_tdir := os.join_path (mod_tdir, 'src' )
32
+ submod_tdir := os.join_path (mod_tdir, 'bar' , 'baz' )
33
+ os.mkdir_all (mod_src_tdir)!
34
+ os.mkdir_all (submod_tdir)!
35
+ tfile_content := [
36
+ 'module ${@FN} ' ,
37
+ '' ,
38
+ 'import bar.baz' ,
39
+ '' ,
40
+ 'type MyAlias = baz.Baz' ,
41
+ '' ,
42
+ ].join_lines ()
43
+ submod_tfile_content := [
44
+ 'module baz' ,
45
+ '' ,
46
+ 'enum BarBaz {' ,
47
+ ' bar' ,
48
+ ' baz' ,
49
+ '}' ,
50
+ '' ,
51
+ ].join_lines ()
52
+ os.write_file (os.join_path (mod_src_tdir, 'foo.v' ), tfile_content)!
53
+ os.write_file (os.join_path (submod_tdir, 'baz.v' ), submod_tfile_content)!
54
+ os.execute_opt ('${vexe} fmt -c ${mod_tdir} ' ) or { assert false , err.msg () }
26
55
}
0 commit comments