067_augroup_exists_spec.lua 1.9 KB

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