robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.1 KiB53 linesraw
1-- Tests for nested function.
2
3local n = require('test.functional.testnvim')()
4local t = require('test.testutil')
5
6local describe, it, setup = t.describe, t.it, t.setup
7local clear, insert = n.clear, n.insert
8local command, expect, source = n.command, n.expect, n.source
9
10describe('test_nested_function', function()
11  setup(clear)
12
13  it('is working', function()
14    insert([[
15      result:]])
16
17    source([[
18      :fu! NestedFunc()
19      :  fu! Func1()
20      :    $put ='Func1'
21      :  endfunction
22      :  call Func1()
23      :  fu! s:func2()
24      :    $put ='s:func2'
25      :  endfunction
26      :  call s:func2()
27      :  fu! s:_func3()
28      :    $put ='s:_func3'
29      :  endfunction
30      :  call s:_func3()
31      :  let fn = 'Func4'
32      :  fu! {fn}()
33      :    $put ='Func4'
34      :  endfunction
35      :  call {fn}()
36      :  let fn = 'func5'
37      :  fu! s:{fn}()
38      :    $put ='s:func5'
39      :  endfunction
40      :  call s:{fn}()
41      :endfunction]])
42    command('call NestedFunc()')
43
44    -- Assert buffer contents.
45    expect([[
46      result:
47      Func1
48      s:func2
49      s:_func3
50      Func4
51      s:func5]])
52  end)
53end)