autoclose_matchpairs.vim 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!,,::'
  2. let lines = readfile(expand('<sfile>:t:r').'.txt')
  3. call vimtest#StartTap()
  4. let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
  5. let itemsnumber = len(split(g:delimitMate_matchpairs, '.:.\zs,\ze.:.'))
  6. call vimtap#Plan(testsnumber * itemsnumber)
  7. let tcount = 1
  8. let reload = 1
  9. for item in lines
  10. if item =~ '^#\|^\s*$'
  11. " A comment or empty line.
  12. continue
  13. endif
  14. if item !~ '^"'
  15. " A command.
  16. exec item
  17. call vimtap#Diag(item)
  18. let reload = 1
  19. continue
  20. endif
  21. if reload
  22. DelimitMateReload
  23. call vimtap#Diag('DelimitMateReload')
  24. let reload = 0
  25. endif
  26. let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
  27. for [s:l,s:r] in map(split(g:delimitMate_matchpairs, '.:.\zs,\ze.:.'), 'split(v:val, ''.\zs:\ze.'')')
  28. let input2 = substitute(input, '(', s:l, 'g')
  29. let input2 = substitute(input2, ')', s:r, 'g')
  30. let output2 = substitute(output, '(', s:l, 'g')
  31. let output2 = substitute(output2, ')', s:r, 'g')
  32. %d
  33. exec 'normal i'.eval(input2)."\<Esc>"
  34. let line = getline('.')
  35. let passed = line == eval(output2)
  36. call vimtap#Is(line, eval(output2), input2)
  37. ", input2 . ' => ' . string(line) .
  38. " \ (passed ? ' =' : ' !') . '= ' . string(eval(output2)))
  39. let tcount += 1
  40. endfor
  41. endfor
  42. call vimtest#Quit()