neovim

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

vvars_spec.lua (1221B)


      1 local t = require('test.testutil')
      2 local n = require('test.functional.testnvim')()
      3 
      4 local clear, eval, eq = n.clear, n.eval, t.eq
      5 local command = n.command
      6 
      7 describe('v:event', function()
      8  before_each(clear)
      9  it('is empty before any autocommand', function()
     10    eq({}, eval('v:event'))
     11  end)
     12 
     13  it('is immutable', function()
     14    eq(false, pcall(command, 'let v:event = {}'))
     15    eq(false, pcall(command, 'let v:event.mykey = {}'))
     16  end)
     17 end)
     18 
     19 describe('v:argf', function()
     20  it('is read-only', function()
     21    n.clear()
     22    t.matches('E46', t.pcall_err(command, "let v:argf = ['foo']"))
     23  end)
     24 
     25  it('gets file args, ignores :argadd, handles "--"', function()
     26    local file1, file2, file3 = 'Xargf_sep1', 'Xargf_sep2', 'Xargf_sep3'
     27 
     28    n.clear {
     29      args_rm = { '--cmd', '-c' },
     30      args = {
     31        '--clean',
     32        '--cmd',
     33        'argadd extrafile.txt', -- :argadd should not affect v:argf.
     34        file1,
     35        file2,
     36        '-c',
     37        'let a = 1 + 3',
     38        '--',
     39        file3,
     40      },
     41    }
     42 
     43    local abs1 = n.fn.fnamemodify(file1, ':p')
     44    local abs2 = n.fn.fnamemodify(file2, ':p')
     45    local abs3 = n.fn.fnamemodify(file3, ':p')
     46 
     47    eq({ abs1, abs2, abs3 }, n.eval('v:argf'))
     48  end)
     49 end)