test_close_count.vim 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. " Tests for :[count]close! command
  2. func Test_close_count()
  3. enew! | only
  4. let wids = [win_getid()]
  5. for i in range(5)
  6. new
  7. call add(wids, win_getid())
  8. endfor
  9. 4wincmd w
  10. close!
  11. let ids = []
  12. windo call add(ids, win_getid())
  13. call assert_equal([wids[5], wids[4], wids[3], wids[1], wids[0]], ids)
  14. 1close!
  15. let ids = []
  16. windo call add(ids, win_getid())
  17. call assert_equal([wids[4], wids[3], wids[1], wids[0]], ids)
  18. $close!
  19. let ids = []
  20. windo call add(ids, win_getid())
  21. call assert_equal([wids[4], wids[3], wids[1]], ids)
  22. 1wincmd w
  23. 2close!
  24. let ids = []
  25. windo call add(ids, win_getid())
  26. call assert_equal([wids[4], wids[1]], ids)
  27. 1wincmd w
  28. new
  29. call add(wids, win_getid())
  30. new
  31. call add(wids, win_getid())
  32. 2wincmd w
  33. -1close!
  34. let ids = []
  35. windo call add(ids, win_getid())
  36. call assert_equal([wids[6], wids[4], wids[1]], ids)
  37. 2wincmd w
  38. +1close!
  39. let ids = []
  40. windo call add(ids, win_getid())
  41. call assert_equal([wids[6], wids[4]], ids)
  42. only!
  43. endfunc
  44. " Tests for :[count]hide command
  45. func Test_hide_count()
  46. enew! | only
  47. let wids = [win_getid()]
  48. for i in range(5)
  49. new
  50. call add(wids, win_getid())
  51. endfor
  52. 4wincmd w
  53. .hide
  54. let ids = []
  55. windo call add(ids, win_getid())
  56. call assert_equal([wids[5], wids[4], wids[3], wids[1], wids[0]], ids)
  57. 1hide
  58. let ids = []
  59. windo call add(ids, win_getid())
  60. call assert_equal([wids[4], wids[3], wids[1], wids[0]], ids)
  61. $hide
  62. let ids = []
  63. windo call add(ids, win_getid())
  64. call assert_equal([wids[4], wids[3], wids[1]], ids)
  65. 1wincmd w
  66. 2hide
  67. let ids = []
  68. windo call add(ids, win_getid())
  69. call assert_equal([wids[4], wids[1]], ids)
  70. 1wincmd w
  71. new
  72. call add(wids, win_getid())
  73. new
  74. call add(wids, win_getid())
  75. 3wincmd w
  76. -hide
  77. let ids = []
  78. windo call add(ids, win_getid())
  79. call assert_equal([wids[7], wids[4], wids[1]], ids)
  80. 2wincmd w
  81. +hide
  82. let ids = []
  83. windo call add(ids, win_getid())
  84. call assert_equal([wids[7], wids[4]], ids)
  85. only!
  86. endfunc
  87. " Tests for :[count]close! command with 'hidden'
  88. func Test_hidden_close_count()
  89. enew! | only
  90. let wids = [win_getid()]
  91. for i in range(5)
  92. new
  93. call add(wids, win_getid())
  94. endfor
  95. set hidden
  96. $ hide
  97. let ids = []
  98. windo call add(ids, win_getid())
  99. call assert_equal([wids[5], wids[4], wids[3], wids[2], wids[1]], ids)
  100. $-1 close!
  101. let ids = []
  102. windo call add(ids, win_getid())
  103. call assert_equal([wids[5], wids[4], wids[3], wids[1]], ids)
  104. 1wincmd w
  105. .+close!
  106. let ids = []
  107. windo call add(ids, win_getid())
  108. call assert_equal([wids[5], wids[3], wids[1]], ids)
  109. set nohidden
  110. only!
  111. endfunc
  112. " Tests for 'CTRL-W c' command to close windows.
  113. func Test_winclose_command()
  114. enew! | only
  115. let wids = [win_getid()]
  116. for i in range(5)
  117. new
  118. call add(wids, win_getid())
  119. endfor
  120. set hidden
  121. 4wincmd w
  122. exe "normal \<C-W>c"
  123. let ids = []
  124. windo call add(ids, win_getid())
  125. call assert_equal([wids[5], wids[4], wids[3], wids[1], wids[0]], ids)
  126. exe "normal 1\<C-W>c"
  127. let ids = []
  128. windo call add(ids, win_getid())
  129. call assert_equal([wids[4], wids[3], wids[1], wids[0]], ids)
  130. exe "normal 9\<C-W>c"
  131. let ids = []
  132. windo call add(ids, win_getid())
  133. call assert_equal([wids[4], wids[3], wids[1]], ids)
  134. 1wincmd w
  135. exe "normal 2\<C-W>c"
  136. let ids = []
  137. windo call add(ids, win_getid())
  138. call assert_equal([wids[4], wids[1]], ids)
  139. set nohidden
  140. only!
  141. endfunc