robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
715d8887ec
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , before_each , after_each =t . describe , t . it , t . before_each , t . after_each 5local clear , command , eval , eq =n . clear , n . command , n . eval , t . eq 6local mkdir =t . mkdir 7 8describe ( 'glob()' , function () 9before_each ( function () 10clear () 11mkdir ( 'test-glob' ) 12 13-- Long path might cause "Press ENTER" prompt; use :silent to avoid it. 14command ( 'silent cd test-glob' ) 15end ) 16 17after_each ( function () 18vim . uv . fs_rmdir ( 'test-glob' ) 19end ) 20 21it ( "glob('.*') returns . and .. " , function () 22eq ( { '.' , '..' } , eval ( "glob('.*', 0, 1)" )) 23-- Do it again to verify scandir_next_with_dots() internal state. 24eq ( { '.' , '..' } , eval ( "glob('.*', 0, 1)" )) 25end ) 26it ( "glob('*') returns an empty list " , function () 27eq ( {} , eval ( "glob('*', 0, 1)" )) 28-- Do it again to verify scandir_next_with_dots() internal state. 29eq ( {} , eval ( "glob('*', 0, 1)" )) 30end ) 31end ) 32 33describe ( 'glob() with $ and ~ mixed with wildcards' , function () 34before_each ( function () 35clear () 36mkdir ( 'test-wild' ) 37command ( 'silent cd test-wild' ) 38-- Names containing literal '$' and '~'. 39command ( [[call writefile([], 'a$b.txt')]] ) 40command ( [[call writefile([], 'a$c.txt')]] ) 41mkdir ( 'test-wild/d~e' ) 42command ( [[call writefile([], 'd~e/f.txt')]] ) 43end ) 44 45after_each ( function () 46n . rmdir ( 'test-wild' ) 47end ) 48 49it ( '$VAR is expanded before the trailing wildcard is globbed' , function () 50command ( 'let $WILDDIR = "d~e"' ) 51eq ( { 'd~e/f.txt' } , eval ( [[glob('$WILDDIR/*', 0, 1)]] )) 52end ) 53 54it ( "wildcard descends through a component containing '~'" , function () 55eq ( { 'd~e/f.txt' } , eval ( [[glob('d~e/*', 0, 1)]] )) 56end ) 57 58it ( "'~' mid-component combined with a wildcard" , function () 59eq ( { 'd~e' } , eval ( [[glob('d~*', 0, 1)]] )) 60end ) 61end )