blob: 4b580acbb70984a54380dc426ba6cf3e2a498b7b [file] [log] [blame]
Bram Moolenaar292eff02017-07-11 21:46:28 +02001" Test whether glob()/globpath() return correct results with certain escaped
2" characters.
3
Bram Moolenaarbfe13cc2020-04-12 17:53:12 +02004func 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\{'))
Bram Moolenaar5d69fdb2019-08-31 19:13:58 +020019 sandbox call assert_equal("", 'Xxx\$'->glob())
Bram Moolenaar8f130ed2019-04-10 22:15:19 +020020 w! Xxx\{
Bram Moolenaar292eff02017-07-11 21:46:28 +020021 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 Moolenaar5d69fdb2019-08-31 19:13:58 +020032 \ 'glob*.vim'->globpath('sautest/autoload', 0, 1))
Bram Moolenaar292eff02017-07-11 21:46:28 +020033endfunction