|
1 | 1 | let s:V = vital#vital#new()
|
2 | 2 | let s:is_windows = has('win32')
|
| 3 | +let s:is_mac = has('mac') |
3 | 4 |
|
4 | 5 | Describe System.Filepath
|
5 | 6 | Before all
|
@@ -121,6 +122,82 @@ Describe System.Filepath
|
121 | 122 | End
|
122 | 123 | End
|
123 | 124 |
|
| 125 | + Describe .expand_home() |
| 126 | + if s:is_windows |
| 127 | + It [windows] non home path are 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 are 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 | + if s:is_windows |
| 141 | + let path = '~\Hoge' |
| 142 | + else |
| 143 | + let path = '~/Hoge' |
| 144 | + endif |
| 145 | + let ret = FP.expand_home(path) |
| 146 | + Assert Equals(ret, $HOME . FP.separator() . 'Hoge') |
| 147 | + End |
| 148 | + It include .. in path no-expand, but head ~ home expanded. |
| 149 | + if s:is_windows |
| 150 | + let target = '~\Hoge\..\Fuga' |
| 151 | + else |
| 152 | + let target = '~/Hoge/../Fuga' |
| 153 | + endif |
| 154 | + let path = '~' . FP.separator() . target |
| 155 | + let ret = FP.expand_home(path) |
| 156 | + Assert Equals(ret, $HOME . FP.separator() . target) |
| 157 | + End |
| 158 | + if s:is_windows |
| 159 | + " need completeslash test |
| 160 | + if exists('&completeslash') |
| 161 | + It [windows] completeslash not set home expand test |
| 162 | + let backup_completeslash = &completeslash |
| 163 | + set completeslash& |
| 164 | + let path = '~\Hoge' |
| 165 | + let ret = FP.expand_home(path) |
| 166 | + Assert Equals(ret, $HOME . FP.separator() . 'Hoge') |
| 167 | + let &completeslash = backup_completeslash |
| 168 | + End |
| 169 | + It [windows] completeslash=slash home expand test |
| 170 | + let backup_completeslash = &completeslash |
| 171 | + set completeslash=slash |
| 172 | + let path = '~\Hoge' |
| 173 | + let ret = FP.expand_home(path) |
| 174 | + Assert Equals(ret, $HOME . FP.separator() . 'Hoge') |
| 175 | + let &completeslash = backup_completeslash |
| 176 | + End |
| 177 | + It [windows] completeslash=backslash home expand test |
| 178 | + let backup_completeslash = &completeslash |
| 179 | + set completeslash=backslash |
| 180 | + let path = '~\Hoge' |
| 181 | + let ret = FP.expand_home(path) |
| 182 | + Assert Equals(ret, $HOME . FP.separator() . 'Hoge') |
| 183 | + let &completeslash = backup_completeslash |
| 184 | + End |
| 185 | + endif |
| 186 | + else |
| 187 | + " need ~user test |
| 188 | + It [unix] ~user expand check |
| 189 | + let path = '~root/Hoge' |
| 190 | + let ret = FP.expand_home(path) |
| 191 | + if s:is_mac |
| 192 | + let expect = '/var/root/Hoge' |
| 193 | + else |
| 194 | + let expect = '/root/Hoge' |
| 195 | + endif |
| 196 | + Assert Equals(ret, expect) |
| 197 | + End |
| 198 | + endif |
| 199 | + End |
| 200 | + |
124 | 201 | Describe .winpath()
|
125 | 202 | It should substitute slashes in {path} to backslashes
|
126 | 203 | let path = '/Foo/Bar/Hoge.txt'
|
|
0 commit comments