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