test_preview.vim 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. " Tests for the preview window
  2. source check.vim
  3. CheckFeature quickfix
  4. func Test_Psearch()
  5. " this used to cause ml_get errors
  6. help
  7. let wincount = winnr('$')
  8. 0f
  9. ps.
  10. call assert_equal(wincount + 1, winnr('$'))
  11. pclose
  12. call assert_equal(wincount, winnr('$'))
  13. bwipe
  14. endfunc
  15. func Test_window_preview()
  16. CheckFeature quickfix
  17. " Open a preview window
  18. pedit Xa
  19. call assert_equal(2, winnr('$'))
  20. call assert_equal(0, &previewwindow)
  21. " Go to the preview window
  22. wincmd P
  23. call assert_equal(1, &previewwindow)
  24. call assert_equal('preview', win_gettype())
  25. " Close preview window
  26. wincmd z
  27. call assert_equal(1, winnr('$'))
  28. call assert_equal(0, &previewwindow)
  29. call assert_fails('wincmd P', 'E441:')
  30. endfunc
  31. func Test_window_preview_from_help()
  32. CheckFeature quickfix
  33. filetype on
  34. call writefile(['/* some C code */'], 'Xpreview.c')
  35. help
  36. pedit Xpreview.c
  37. wincmd P
  38. call assert_equal(1, &previewwindow)
  39. call assert_equal('c', &filetype)
  40. wincmd z
  41. filetype off
  42. close
  43. call delete('Xpreview.c')
  44. endfunc
  45. func Test_multiple_preview_windows()
  46. new
  47. set previewwindow
  48. new
  49. call assert_fails('set previewwindow', 'E590:')
  50. %bw!
  51. endfunc
  52. " vim: shiftwidth=2 sts=2 expandtab