2014-10-27 09:45:52 -07:00
|
|
|
-- vim: set foldmethod=marker foldmarker=[[,]] :
|
|
|
|
-- Test whether glob()/globpath() return correct results with certain escaped
|
|
|
|
-- characters.
|
|
|
|
|
2024-04-09 04:26:16 -07:00
|
|
|
local t = require('test.functional.testutil')()
|
2024-04-08 02:03:20 -07:00
|
|
|
local clear = t.clear
|
|
|
|
local command, expect = t.command, t.expect
|
2014-10-27 09:45:52 -07:00
|
|
|
|
|
|
|
describe('glob() and globpath()', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
setup(function()
|
2024-04-08 02:03:20 -07:00
|
|
|
if t.is_os('win') then
|
2017-10-11 19:56:11 -07:00
|
|
|
os.execute('md sautest\\autoload')
|
|
|
|
os.execute('.>sautest\\autoload\\Test104.vim 2>nul')
|
|
|
|
os.execute('.>sautest\\autoload\\footest.vim 2>nul')
|
|
|
|
else
|
|
|
|
os.execute('mkdir -p sautest/autoload')
|
|
|
|
os.execute('touch sautest/autoload/Test104.vim')
|
|
|
|
os.execute('touch sautest/autoload/footest.vim')
|
|
|
|
end
|
2014-10-27 09:45:52 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
-- Make sure glob() doesn't use the shell
|
2017-04-08 14:12:26 -07:00
|
|
|
command('set shell=doesnotexist')
|
2014-10-27 09:45:52 -07:00
|
|
|
|
|
|
|
-- Consistent sorting of file names
|
2017-04-08 14:12:26 -07:00
|
|
|
command('set nofileignorecase')
|
2014-10-27 09:45:52 -07:00
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
if t.is_os('win') then
|
2017-10-11 19:56:11 -07:00
|
|
|
command([[$put =glob('Xxx{')]])
|
|
|
|
command([[$put =glob('Xxx$')]])
|
|
|
|
|
|
|
|
command('silent w! Xxx{')
|
|
|
|
command([[w! Xxx$]])
|
|
|
|
command([[$put =glob('Xxx{')]])
|
|
|
|
command([[$put =glob('Xxx$')]])
|
|
|
|
|
|
|
|
command([[$put =string(globpath('sautest\autoload', '*.vim'))]])
|
|
|
|
command([[$put =string(globpath('sautest\autoload', '*.vim', 0, 1))]])
|
|
|
|
expect([=[
|
|
|
|
|
|
|
|
|
2014-10-27 09:45:52 -07:00
|
|
|
|
2017-10-11 19:56:11 -07:00
|
|
|
Xxx{
|
|
|
|
Xxx$
|
|
|
|
'sautest\autoload\Test104.vim
|
|
|
|
sautest\autoload\footest.vim'
|
|
|
|
['sautest\autoload\Test104.vim', 'sautest\autoload\footest.vim']]=])
|
|
|
|
else
|
|
|
|
command([[$put =glob('Xxx\{')]])
|
|
|
|
command([[$put =glob('Xxx\$')]])
|
2014-10-27 09:45:52 -07:00
|
|
|
|
2020-01-26 06:17:08 -07:00
|
|
|
command('silent w! Xxx\\{')
|
2017-10-11 19:56:11 -07:00
|
|
|
command([[w! Xxx\$]])
|
|
|
|
command([[$put =glob('Xxx\{')]])
|
|
|
|
command([[$put =glob('Xxx\$')]])
|
2014-10-27 09:45:52 -07:00
|
|
|
|
2017-10-11 19:56:11 -07:00
|
|
|
command("$put =string(globpath('sautest/autoload', '*.vim'))")
|
|
|
|
command("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))")
|
|
|
|
expect([=[
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-11 19:56:11 -07:00
|
|
|
Xxx{
|
|
|
|
Xxx$
|
|
|
|
'sautest/autoload/Test104.vim
|
|
|
|
sautest/autoload/footest.vim'
|
|
|
|
['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']]=])
|
|
|
|
end
|
2014-10-27 09:45:52 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
teardown(function()
|
2024-04-08 02:03:20 -07:00
|
|
|
if t.is_os('win') then
|
2017-10-11 19:56:11 -07:00
|
|
|
os.execute('del /q/f Xxx{ Xxx$')
|
2018-05-20 12:08:55 -07:00
|
|
|
os.execute('rd /q /s sautest')
|
2017-10-11 19:56:11 -07:00
|
|
|
else
|
|
|
|
os.execute('rm -rf sautest Xxx{ Xxx$')
|
|
|
|
end
|
2014-10-27 09:45:52 -07:00
|
|
|
end)
|
|
|
|
end)
|