Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 1 | " Test whether glob()/globpath() return correct results with certain escaped |
| 2 | " characters. |
| 3 | |
| 4 | function SetUp() |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 5 | " consistent sorting of file names |
| 6 | set nofileignorecase |
| 7 | endfunction |
| 8 | |
| 9 | function Test_glob() |
Bram Moolenaar | 6e77df2 | 2017-11-21 11:43:08 +0100 | [diff] [blame] | 10 | if !has('unix') |
| 11 | " This test fails on Windows because of the special characters in the |
| 12 | " filenames. Disable the test on non-Unix systems for now. |
| 13 | return |
| 14 | endif |
Bram Moolenaar | a2aad02 | 2018-10-14 22:03:56 +0200 | [diff] [blame^] | 15 | |
| 16 | " Execute these commands in the sandbox, so that using the shell fails. |
| 17 | " Setting 'shell' to an invalid name causes a memory leak. |
| 18 | sandbox call assert_equal("", glob('Xxx\{')) |
| 19 | sandbox call assert_equal("", glob('Xxx\$')) |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 20 | w! Xxx{ |
| 21 | w! Xxx\$ |
Bram Moolenaar | a2aad02 | 2018-10-14 22:03:56 +0200 | [diff] [blame^] | 22 | sandbox call assert_equal("Xxx{", glob('Xxx\{')) |
| 23 | sandbox call assert_equal("Xxx$", glob('Xxx\$')) |
Bram Moolenaar | 6e77df2 | 2017-11-21 11:43:08 +0100 | [diff] [blame] | 24 | call delete('Xxx{') |
| 25 | call delete('Xxx$') |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 26 | endfunction |
| 27 | |
| 28 | function Test_globpath() |
Bram Moolenaar | a2aad02 | 2018-10-14 22:03:56 +0200 | [diff] [blame^] | 29 | sandbox call assert_equal("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim", |
Bram Moolenaar | 6e65d59 | 2017-12-07 22:11:27 +0100 | [diff] [blame] | 30 | \ globpath('sautest/autoload', 'glob*.vim')) |
Bram Moolenaar | a2aad02 | 2018-10-14 22:03:56 +0200 | [diff] [blame^] | 31 | sandbox call assert_equal(['sautest/autoload/globone.vim', 'sautest/autoload/globtwo.vim'], |
Bram Moolenaar | 6e65d59 | 2017-12-07 22:11:27 +0100 | [diff] [blame] | 32 | \ globpath('sautest/autoload', 'glob*.vim', 0, 1)) |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 33 | endfunction |