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 | |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 4 | source check.vim |
| 5 | |
Bram Moolenaar | bfe13cc | 2020-04-12 17:53:12 +0200 | [diff] [blame] | 6 | func SetUp() |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 7 | " consistent sorting of file names |
| 8 | set nofileignorecase |
| 9 | endfunction |
| 10 | |
| 11 | function Test_glob() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 12 | " This test fails on Windows because of the special characters in the |
| 13 | " filenames. Disable the test on non-Unix systems for now. |
| 14 | CheckUnix |
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\{')) |
Bram Moolenaar | 5d69fdb | 2019-08-31 19:13:58 +0200 | [diff] [blame] | 19 | sandbox call assert_equal("", 'Xxx\$'->glob()) |
Bram Moolenaar | 8f130ed | 2019-04-10 22:15:19 +0200 | [diff] [blame] | 20 | w! Xxx\{ |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 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 | 5d69fdb | 2019-08-31 19:13:58 +0200 | [diff] [blame] | 32 | \ 'glob*.vim'->globpath('sautest/autoload', 0, 1)) |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 33 | endfunction |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 34 | |
| 35 | " vim: shiftwidth=2 sts=2 expandtab |