robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Test that groups and patterns are tested correctly when calling exists() for 2-- autocommands. 3 4local n =require ( 'test.functional.testnvim' )() 5local t =require ( 'test.testutil' ) 6 7local describe , it , setup =t . describe , t . it , t . setup 8local clear =n . clear 9local command , expect =n . command , n . expect 10 11describe ( 'augroup when calling exists()' , function () 12setup ( clear ) 13 14it ( 'is working' , function () 15command ( 'let results=[]' ) 16command ( 'call add(results, "##BufEnter: " . exists("##BufEnter"))' ) 17command ( 'call add(results, "#BufEnter: " . exists("#BufEnter"))' ) 18command ( 'au BufEnter * let g:entered=1' ) 19command ( 'call add(results, "#BufEnter: " . exists("#BufEnter"))' ) 20command ( 'call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))' ) 21command ( 'augroup auexists' ) 22command ( 'au BufEnter * let g:entered=1' ) 23command ( 'augroup END' ) 24command ( 'call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))' ) 25command ( 'call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))' ) 26command ( 'au BufEnter *.test let g:entered=1' ) 27command ( 'call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))' ) 28command ( 'edit testfile.test' ) 29command ( 'call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))' ) 30command ( 'au BufEnter <buffer> let g:entered=1' ) 31command ( 'call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))' ) 32command ( 'edit testfile2.test' ) 33command ( 'call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))' ) 34command ( 'bf' ) 35command ( 'call append(0, results)' ) 36command ( '$d' ) 37 38-- Assert buffer contents. 39expect ( [[ 40##BufEnter: 1 41#BufEnter: 0 42#BufEnter: 1 43#auexists#BufEnter: 0 44#auexists#BufEnter: 1 45#BufEnter#*.test: 0 46#BufEnter#*.test: 1 47#BufEnter#<buffer>: 0 48#BufEnter#<buffer>: 1 49#BufEnter#<buffer>: 0]] ) 50end ) 51end )