robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- vim: set foldmethod=marker foldmarker=[[,]] : 2-- Test whether glob()/globpath() return correct results with certain escaped 3-- characters. 4 5local t =require ( 'test.testutil' ) 6local n =require ( 'test.functional.testnvim' )() 7 8local describe , it , setup , teardown =t . describe , t . it , t . setup , t . teardown 9local clear =n . clear 10local command , expect =n . command , n . expect 11 12describe ( 'glob() and globpath()' , function () 13setup ( clear ) 14 15setup ( function () 16if t . is_os ( 'win' ) then 17os . execute ( 'md sautest\\autoload' ) 18os . execute ( '.>sautest\\autoload\\Test104.vim 2>nul' ) 19os . execute ( '.>sautest\\autoload\\footest.vim 2>nul' ) 20else 21os . execute ( 'mkdir -p sautest/autoload' ) 22os . execute ( 'touch sautest/autoload/Test104.vim' ) 23os . execute ( 'touch sautest/autoload/footest.vim' ) 24end 25end ) 26 27it ( 'is working' , function () 28-- Make sure glob() doesn't use the shell 29command ( 'set shell=doesnotexist' ) 30 31-- Consistent sorting of file names 32command ( 'set nofileignorecase' ) 33 34if t . is_os ( 'win' ) then 35command ( [[$put =glob('Xxx{')]] ) 36command ( [[$put =glob('Xxx$')]] ) 37 38command ( 'silent w! Xxx{' ) 39command ( [[w! Xxx$]] ) 40command ( [[$put =glob('Xxx{')]] ) 41command ( [[$put =glob('Xxx$')]] ) 42 43command ( [[$put =string(globpath('sautest\autoload', '*.vim'))]] ) 44command ( [[$put =string(globpath('sautest\autoload', '*.vim', 0, 1))]] ) 45else 46command ( [[$put =glob('Xxx\{')]] ) 47command ( [[$put =glob('Xxx\$')]] ) 48 49command ( 'silent w! Xxx\\{' ) 50command ( [[w! Xxx\$]] ) 51command ( [[$put =glob('Xxx\{')]] ) 52command ( [[$put =glob('Xxx\$')]] ) 53 54command ( "$put =string(globpath('sautest/autoload', '*.vim'))" ) 55command ( "$put =string(globpath('sautest/autoload', '*.vim', 0, 1))" ) 56end 57expect ( [=[ 58 59 60 61Xxx{ 62Xxx$ 63'sautest/autoload/Test104.vim 64sautest/autoload/footest.vim' 65['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']]=] ) 66end ) 67 68teardown ( function () 69if t . is_os ( 'win' ) then 70os . execute ( 'del /q/f Xxx{ Xxx$' ) 71os . execute ( 'rd /q /s sautest' ) 72else 73os . execute ( 'rm -rf sautest Xxx{ Xxx$' ) 74end 75end ) 76end )