blob: 5da2a790d8b796035fcf9a660711dd51b63474e9 [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 Moolenaar6d91bcb2020-08-12 18:50:36 +020010 " This test fails on Windows because of the special characters in the
11 " filenames. Disable the test on non-Unix systems for now.
12 CheckUnix
Bram Moolenaara2aad022018-10-14 22:03:56 +020013
14 " Execute these commands in the sandbox, so that using the shell fails.
15 " Setting 'shell' to an invalid name causes a memory leak.
16 sandbox call assert_equal("", glob('Xxx\{'))
Bram Moolenaar5d69fdb2019-08-31 19:13:58 +020017 sandbox call assert_equal("", 'Xxx\$'->glob())
Bram Moolenaar8f130ed2019-04-10 22:15:19 +020018 w! Xxx\{
Bram Moolenaar292eff02017-07-11 21:46:28 +020019 w! Xxx\$
Bram Moolenaara2aad022018-10-14 22:03:56 +020020 sandbox call assert_equal("Xxx{", glob('Xxx\{'))
21 sandbox call assert_equal("Xxx$", glob('Xxx\$'))
Bram Moolenaar6e77df22017-11-21 11:43:08 +010022 call delete('Xxx{')
23 call delete('Xxx$')
Bram Moolenaar292eff02017-07-11 21:46:28 +020024endfunction
25
26function Test_globpath()
Bram Moolenaara2aad022018-10-14 22:03:56 +020027 sandbox call assert_equal("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim",
Bram Moolenaar6e65d592017-12-07 22:11:27 +010028 \ globpath('sautest/autoload', 'glob*.vim'))
Bram Moolenaara2aad022018-10-14 22:03:56 +020029 sandbox call assert_equal(['sautest/autoload/globone.vim', 'sautest/autoload/globtwo.vim'],
Bram Moolenaar5d69fdb2019-08-31 19:13:58 +020030 \ 'glob*.vim'->globpath('sautest/autoload', 0, 1))
Bram Moolenaar292eff02017-07-11 21:46:28 +020031endfunction
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020032
33" vim: shiftwidth=2 sts=2 expandtab