Files
Ingo Karkat 2ef7b9973f ingo#regexp#length#Project(): Implement projection of simple patterns without multis or groups
By reusing the ingo#regexp#deconstruct#ToQuasiLiteral() function, we can convert the simple pattern into literal text, and then can do a simple character count.
2018-08-21 15:15:43 +02:00

15 lines
737 B
VimL

" Test estimation of matched characters in simple patterns without multis or groups.
call vimtest#StartTap()
call vimtap#Plan(6)
call vimtap#Is(ingo#regexp#length#Project('\<abc\>'), [3, 3], '3-character keyword')
call vimtap#Is(ingo#regexp#length#Project('^abc$'), [3, 3], '3-character anchored line')
call vimtap#Is(ingo#regexp#length#Project('\%>10l\%<80vword\%$'), [4, 4], '4-character position-anchored word')
call vimtap#Is(ingo#regexp#length#Project('foo\.\.\.'), [6, 6], 'word with ellipsis')
call vimtap#Is(ingo#regexp#length#Project('\tThis is\tit\n'), [12, 12], 'sentence with tabs and newline')
call vimtap#Is(ingo#regexp#length#Project('/\~-\~-\*-\*\\'), [9, 9], 'mix of escaped special characters')
call vimtest#Quit()