mirror of
https://github.com/inkarkat/vim-ingo-library.git
synced 2026-06-10 15:37:43 +02:00
2ef7b9973f
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.
15 lines
737 B
VimL
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()
|