neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

067_augroup_exists_spec.lua (1869B)


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