robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
2.6 KiB91 linesraw
1local n = require('test.functional.testnvim')()
2local t = require('test.testutil')
3local Screen = require('test.functional.ui.screen')
4
5local describe, it, before_each = t.describe, t.it, t.before_each
6local clear = n.clear
7local exec = n.exec
8local feed = n.feed
9local api = n.api
10
11before_each(clear)
12
13describe('Vim script', function()
14  -- oldtest: Test_deep_nest()
15  it('Error when if/for/while/try/function is nested too deep', function()
16    local screen = Screen.new(80, 24)
17    api.nvim_set_option_value('laststatus', 2, {})
18    exec([[
19      " Deep nesting of if ... endif
20      func Test1()
21        let @a = join(repeat(['if v:true'], 51), "\n")
22        let @a ..= "\n"
23        let @a ..= join(repeat(['endif'], 51), "\n")
24        @a
25        let @a = ''
26      endfunc
27
28      " Deep nesting of for ... endfor
29      func Test2()
30        let @a = join(repeat(['for i in [1]'], 51), "\n")
31        let @a ..= "\n"
32        let @a ..= join(repeat(['endfor'], 51), "\n")
33        @a
34        let @a = ''
35      endfunc
36
37      " Deep nesting of while ... endwhile
38      func Test3()
39        let @a = join(repeat(['while v:true'], 51), "\n")
40        let @a ..= "\n"
41        let @a ..= join(repeat(['endwhile'], 51), "\n")
42        @a
43        let @a = ''
44      endfunc
45
46      " Deep nesting of try ... endtry
47      func Test4()
48        let @a = join(repeat(['try'], 51), "\n")
49        let @a ..= "\necho v:true\n"
50        let @a ..= join(repeat(['endtry'], 51), "\n")
51        @a
52        let @a = ''
53      endfunc
54
55      " Deep nesting of function ... endfunction
56      func Test5()
57        let @a = join(repeat(['function X()'], 51), "\n")
58        let @a ..= "\necho v:true\n"
59        let @a ..= join(repeat(['endfunction'], 51), "\n")
60        @a
61        let @a = ''
62      endfunc
63    ]])
64    screen:expect({ any = '%[No Name%]' })
65    feed(':call Test1()<CR>')
66    screen:expect({ any = 'E579: ' })
67    feed('<C-C>')
68    screen:expect({ any = '%[No Name%]' })
69    feed(':call Test2()<CR>')
70    screen:expect({ any = 'E585: ' })
71    feed('<C-C>')
72    screen:expect({ any = '%[No Name%]' })
73    feed(':call Test3()<CR>')
74    screen:expect({ any = 'E585: ' })
75    feed('<C-C>')
76    screen:expect({ any = '%[No Name%]' })
77    feed(':call Test4()<CR>')
78    screen:expect({ any = 'E601: ' })
79    feed('<C-C>')
80    screen:expect({ any = '%[No Name%]' })
81    feed(':call Test5()<CR>')
82    screen:expect({ any = 'E1058: ' })
83  end)
84
85  -- oldtest: Test_typed_script_var()
86  it('using s: with a typed command', function()
87    local screen = Screen.new(80, 24)
88    feed(":echo get(s:, 'foo', 'x')\n")
89    screen:expect({ any = 'E116: ' })
90  end)
91end)