v / cmd / tools / vdoc / document / doc_private_fn_test.v
44 lines · 38 sloc · 1.17 KB · e2e5cf8db56f3562c7baa735061690be936bdf3e
Raw
1module document
2
3import os
4
5fn testsuite_begin() {
6 os.chdir(@VMODROOT) or {}
7 eprintln('>> @VMODROOT: ' + @VMODROOT)
8}
9
10fn test_get_parent_mod_on_root_folder() {
11 // TODO: add an equivalent windows check for c:\
12 $if !windows {
13 assert '---' == get_parent_mod('/') or {
14 assert err.msg() == 'root folder reached'
15 '---'
16 }
17 }
18}
19
20fn test_get_parent_mod_current_folder() {
21 // TODO: this should may be return '' reliably on windows too:
22 // assert '' == get_parent_mod('.') or {
23 // assert err.msg() == 'No V files found.'
24 // '---'
25 // }
26}
27
28fn test_get_parent_mod_on_temp_dir() {
29 // TODO: fix this on windows
30 $if !windows {
31 assert get_parent_mod(os.temp_dir())! == ''
32 }
33}
34
35fn test_get_parent_mod_normal_cases() {
36 assert '---' == get_parent_mod(os.join_path(@VMODROOT, 'vlib/v')) or {
37 assert err.msg() == 'No V files found.'
38 '---'
39 }
40 assert get_parent_mod(os.join_path(@VMODROOT, 'vlib', 'v', 'token'))! == 'v'
41 assert get_parent_mod(os.join_path(@VMODROOT, 'vlib', 'os', 'os.v'))! == 'os'
42 assert get_parent_mod(os.join_path(@VMODROOT, 'cmd'))! == ''
43 assert get_parent_mod(os.join_path(@VMODROOT, 'cmd', 'tools', 'modules', 'testing', 'common.v'))! == 'tools.modules.testing'
44}
45