basic_asterisk.vimspec 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. scriptencoding utf-8
  2. Describe basic_asterisk
  3. Before all
  4. let lines = [
  5. \ '1.asterisk 2.asterisk 3.asterisk'
  6. \ , '4.Asterisk 5.AsteRisK 6.Asterisk'
  7. \ , ''
  8. \ , '7.アスタリスク 8.アスタリスクです 9.アスタリスク?'
  9. \ , '.* .* .*'
  10. \ , '.* asterisk asterisk'
  11. \ ]
  12. call g:Add_lines(lines)
  13. End
  14. Before each
  15. call cursor([1, 1])
  16. normal! 2l
  17. End
  18. After all
  19. :1,$ delete
  20. End
  21. Context *
  22. It search forward with \<\>
  23. let @/ = ''
  24. normal *
  25. Assert Equals(@/, '\<asterisk\>')
  26. End
  27. It search forward the 1th occurrence of the word
  28. normal *
  29. normal! 2h
  30. Assert Equals(g:Get_pos_char(), '2')
  31. End
  32. It search forward the 2th occurrence of the word
  33. normal 2*
  34. normal! 2h
  35. Assert Equals(g:Get_pos_char(), '3')
  36. End
  37. It search forward in the middle of word
  38. normal! l
  39. normal *
  40. normal! 2h
  41. Assert Equals(g:Get_pos_char(), '2')
  42. End
  43. It search forward multibyte word
  44. normal! 3j
  45. normal *
  46. normal! B
  47. Assert Equals(g:Get_pos_char(), '8')
  48. End
  49. It throws the error if there are no <cword>
  50. normal! 2j
  51. Throws /E348: No string under cursor/ :normal *
  52. End
  53. Context regular expression handling
  54. It use regular expression characters under cursor if there are no keyword word after them
  55. normal! 4j0
  56. normal *
  57. Assert Equals(@/, '\.\*')
  58. End
  59. It do not use regular expression characters under cursor if there are keyword words after them
  60. normal! 5j0
  61. normal *
  62. Assert Equals(@/, '\<asterisk\>')
  63. End
  64. End
  65. End
  66. Context g*
  67. It search forward without \<\>
  68. let @/ = ''
  69. normal g*
  70. Assert Equals(@/, 'asterisk')
  71. End
  72. It search forward the 1th occurrence of the word
  73. normal g*
  74. normal! 2h
  75. Assert Equals(g:Get_pos_char(), '2')
  76. End
  77. It search forward the 2th occurrence of the word
  78. normal 2*
  79. normal! 2h
  80. Assert Equals(g:Get_pos_char(), '3')
  81. End
  82. It search forward in the middle of word
  83. normal! l
  84. normal g*
  85. normal! 2h
  86. Assert Equals(g:Get_pos_char(), '2')
  87. End
  88. It throws the error if there are no <cword>
  89. normal! 2j
  90. Throws /E348: No string under cursor/ :normal g*
  91. End
  92. It search forward with the first keyword after the cursor
  93. normal! h
  94. normal *
  95. normal! 2h
  96. Assert Equals(g:Get_pos_char(), '2')
  97. End
  98. It search forward with ignorecase
  99. set ignorecase nosmartcase
  100. normal! j
  101. normal *
  102. normal! 2h
  103. Assert Equals(g:Get_pos_char(), '5')
  104. set ignorecase& smartcase&
  105. End
  106. It search forward with smartcase
  107. set ignorecase smartcase
  108. normal! j
  109. normal *
  110. normal! 2h
  111. Assert Equals(g:Get_pos_char(), '6')
  112. set ignorecase& smartcase&
  113. End
  114. End
  115. Context #
  116. It search backward with \<\>
  117. let @/ = ''
  118. normal #
  119. Assert Equals(@/, '\<asterisk\>')
  120. End
  121. It search backward the 1th occurrence of the word
  122. normal! $b
  123. normal #
  124. normal! 2h
  125. Assert Equals(g:Get_pos_char(), '2')
  126. End
  127. It search backward the 2th occurrence of the word
  128. normal! $b
  129. normal 2#
  130. normal! 2h
  131. Assert Equals(g:Get_pos_char(), '1')
  132. End
  133. It search backward at the end of word
  134. normal! $
  135. normal #
  136. normal! 2h
  137. Assert Equals(g:Get_pos_char(), '2')
  138. End
  139. It search backward in the middle of word
  140. normal! $h
  141. normal #
  142. normal! 2h
  143. Assert Equals(g:Get_pos_char(), '2')
  144. End
  145. It search backward with the first keyword after the cursor
  146. normal! $bh
  147. normal #
  148. normal! 2h
  149. Assert Equals(g:Get_pos_char(), '2')
  150. End
  151. End
  152. Context g#
  153. It search backward with \<\>
  154. let @/ = ''
  155. normal g#
  156. Assert Equals(@/, 'asterisk')
  157. End
  158. End
  159. End