robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

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