blob: 880f32eca4909fe18a32e1e946418358b364bbeb [file] [log] [blame]
Bram Moolenaar292eff02017-07-11 21:46:28 +02001" Test whether glob()/globpath() return correct results with certain escaped
2" characters.
3
4function SetUp()
Bram Moolenaar292eff02017-07-11 21:46:28 +02005 " consistent sorting of file names
6 set nofileignorecase
7endfunction
8
9function Test_glob()
Bram Moolenaar6e77df22017-11-21 11:43:08 +010010 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 Moolenaara2aad022018-10-14 22:03:56 +020015
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 Moolenaar292eff02017-07-11 21:46:28 +020020 w! Xxx{
21 w! Xxx\$
Bram Moolenaara2aad022018-10-14 22:03:56 +020022 sandbox call assert_equal("Xxx{", glob('Xxx\{'))
23 sandbox call assert_equal("Xxx$", glob('Xxx\$'))
Bram Moolenaar6e77df22017-11-21 11:43:08 +010024 call delete('Xxx{')
25 call delete('Xxx$')
Bram Moolenaar292eff02017-07-11 21:46:28 +020026endfunction
27
28function Test_globpath()
Bram Moolenaara2aad022018-10-14 22:03:56 +020029 sandbox call assert_equal("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim",
Bram Moolenaar6e65d592017-12-07 22:11:27 +010030 \ globpath('sautest/autoload', 'glob*.vim'))
Bram Moolenaara2aad022018-10-14 22:03:56 +020031 sandbox call assert_equal(['sautest/autoload/globone.vim', 'sautest/autoload/globtwo.vim'],
Bram Moolenaar6e65d592017-12-07 22:11:27 +010032 \ globpath('sautest/autoload', 'glob*.vim', 0, 1))
Bram Moolenaar292eff02017-07-11 21:46:28 +020033endfunction