xref: /vim-8.2.3635/src/testdir/test_tabline.vim (revision cb03397a)
1function! TablineWithCaughtError()
2  let s:func_in_tabline_called = 1
3  try
4    call eval('unknown expression')
5  catch
6  endtry
7  return ''
8endfunction
9
10function! TablineWithError()
11  let s:func_in_tabline_called = 1
12  call eval('unknown expression')
13  return ''
14endfunction
15
16function! Test_caught_error_in_tabline()
17  if has('gui')
18    set guioptions-=e
19  endif
20  let showtabline_save = &showtabline
21  set showtabline=2
22  let s:func_in_tabline_called = 0
23  let tabline = '%{TablineWithCaughtError()}'
24  let &tabline = tabline
25  redraw!
26  call assert_true(s:func_in_tabline_called)
27  call assert_equal(tabline, &tabline)
28  set tabline=
29  let &showtabline = showtabline_save
30endfunction
31
32function! Test_tabline_will_be_disabled_with_error()
33  if has('gui')
34    set guioptions-=e
35  endif
36  let showtabline_save = &showtabline
37  set showtabline=2
38  let s:func_in_tabline_called = 0
39  let tabline = '%{TablineWithError()}'
40  try
41    let &tabline = tabline
42    redraw!
43  catch
44  endtry
45  call assert_true(s:func_in_tabline_called)
46  call assert_equal('', &tabline)
47  set tabline=
48  let &showtabline = showtabline_save
49endfunction
50