Skip to content

Commit 2e6b168

Browse files
committed
System.Filepath: add expand_home test
1 parent f8faa98 commit 2e6b168

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/System/Filepath.vimspec

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let s:V = vital#vital#new()
22
let s:is_windows = has('win32')
3+
let s:is_mac = has('mac')
34

45
Describe System.Filepath
56
Before all
@@ -121,6 +122,53 @@ Describe System.Filepath
121122
End
122123
End
123124

125+
Describe .expand_home()
126+
if s:is_windows
127+
It [windows] non home path arre no expanded, there are same.
128+
let path = 'C:/Hoge'
129+
let ret = FP.expand_home(path)
130+
Assert Equals(ret, path)
131+
End
132+
else
133+
It [unix] non home path arre no expanded, there are same.
134+
let path = '/Hoge'
135+
let ret = FP.expand_home(path)
136+
Assert Equals(ret, path)
137+
End
138+
endif
139+
It expand head ~ home path
140+
let path = '~/Hoge'
141+
let ret = FP.expand_home(path)
142+
Assert Equals(ret, $HOME . FP.separator() . 'Hoge')
143+
End
144+
It include .. in path no-expand, but head ~ home expanded.
145+
if s:is_windows
146+
" base shellslash not set need
147+
let target = '~\Hoge\..\Fuga'
148+
else
149+
let target = '~/Hoge/../Fuga'
150+
endif
151+
let path = '~' . FP.separator() . target
152+
let ret = FP.expand_home(path)
153+
Assert Equals(ret, $HOME . FP.separator() . target)
154+
End
155+
if s:is_windows
156+
" need completeslash test
157+
else
158+
" need ~user test
159+
It [unix] ~user expand check
160+
let path = '~root/Hoge'
161+
let ret = FP.expand_home(path)
162+
if s:is_mac
163+
let expect = '/var/root/Hoge'
164+
else
165+
let expect = '/root/Hoge'
166+
endif
167+
Assert Equals(ret, expect)
168+
End
169+
endif
170+
End
171+
124172
Describe .winpath()
125173
It should substitute slashes in {path} to backslashes
126174
let path = '/Foo/Bar/Hoge.txt'

0 commit comments

Comments
 (0)