You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

132 lines
4.8 KiB

  1. let s:suite = themis#suite('toml')
  2. let s:assert = themis#helper('assert')
  3. function! s:suite.get_in_paren() abort
  4. call s:assert.equals(neosnippet#parser#_get_in_paren(
  5. \ '(', ')',
  6. \ '(foobar)'),
  7. \ 'foobar')
  8. call s:assert.equals(neosnippet#parser#_get_in_paren(
  9. \ '(', ')',
  10. \ '(foobar, baz)'),
  11. \ 'foobar, baz')
  12. call s:assert.equals(neosnippet#parser#_get_in_paren(
  13. \ '(', ')',
  14. \ '(foobar, (baz))'),
  15. \ 'foobar, (baz)')
  16. call s:assert.equals(neosnippet#parser#_get_in_paren(
  17. \ '(', ')',
  18. \ 'foobar('),
  19. \ '')
  20. call s:assert.equals(neosnippet#parser#_get_in_paren(
  21. \ '(', ')',
  22. \ 'foobar()'),
  23. \ '')
  24. call s:assert.equals(neosnippet#parser#_get_in_paren(
  25. \ '(', ')',
  26. \ 'foobar(fname)'),
  27. \ 'fname')
  28. call s:assert.equals(neosnippet#parser#_get_in_paren(
  29. \ '(', ')',
  30. \ 'wait() wait(long, int)'),
  31. \ 'long, int')
  32. call s:assert.equals(neosnippet#parser#_get_in_paren(
  33. \ '(', ')',
  34. \ 'wait() (long, int)'),
  35. \ '')
  36. endfunction
  37. function! s:suite.get_completed_snippet() abort
  38. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  39. \ 'word' : 'foo(', 'abbr' : 'foo()',
  40. \ 'menu' : '', 'info' : ''
  41. \ }, 'foo(', ''), ')${1}')
  42. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  43. \ 'word' : 'foo(', 'abbr' : 'foo()',
  44. \ 'menu' : '', 'info' : ''
  45. \ }, 'foo)', ''), '')
  46. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  47. \ 'word' : 'foo(', 'abbr' : '',
  48. \ 'menu' : '', 'info' : ''
  49. \ }, 'foo(', ''), '${1})${2}')
  50. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  51. \ 'word' : 'foo(', 'abbr' : 'foo(hoge)',
  52. \ 'menu' : '', 'info' : ''
  53. \ }, 'foo(', ''), '${1:#:hoge})${2}')
  54. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  55. \ 'word' : 'foo', 'abbr' : 'foo(hoge)',
  56. \ 'menu' : '', 'info' : ''
  57. \ }, 'foo', ''), '(${1:#:hoge})${2}')
  58. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  59. \ 'word' : 'foo(', 'abbr' : 'foo(hoge, piyo)',
  60. \ 'menu' : '', 'info' : ''
  61. \ }, 'foo(', ''), '${1:#:hoge}${2:#:, piyo})${3}')
  62. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  63. \ 'word' : 'foo(', 'abbr' : 'foo(hoge, piyo(foobar))',
  64. \ 'menu' : '', 'info' : ''
  65. \ }, 'foo(', ''), '${1:#:hoge}${2:#:, piyo()})${3}')
  66. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  67. \ 'word' : 'foo(', 'abbr' : 'foo(hoge[, abc])',
  68. \ 'menu' : '', 'info' : ''
  69. \ }, 'foo(', ''), '${1:#:hoge[, abc]})${2}')
  70. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  71. \ 'word' : 'foo(', 'abbr' : 'foo(...)',
  72. \ 'menu' : '', 'info' : ''
  73. \ }, 'foo(', ''), '${1:#:...})${2}')
  74. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  75. \ 'word' : 'foo(', 'abbr' : 'foo(hoge, ...)',
  76. \ 'menu' : '', 'info' : ''
  77. \ }, 'foo(', ''), '${1:#:hoge}${2:#:, ...})${3}')
  78. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  79. \ 'word' : 'Dictionary', 'abbr' : 'Dictionary<Key, Value>(foo)',
  80. \ 'menu' : '', 'info' : ''
  81. \ }, 'Dictionary', ''), '<${1:#:Key}${2:#:, Value}>(${3:#:foo})${4}')
  82. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  83. \ 'word' : 'Dictionary(',
  84. \ 'abbr' : 'Dictionary<Key, Value> Dictionary(foo)',
  85. \ 'menu' : '', 'info' : ''
  86. \ }, 'Dictionary(', ''), '${1:#:foo})${2}')
  87. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  88. \ 'word' : 'Dictionary(', 'abbr' : '',
  89. \ 'menu' : '', 'info' : ''
  90. \ }, 'Dictionary(', '('), '')
  91. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  92. \ 'word' : 'Dictionary(', 'abbr' : 'Dictionary(foo)',
  93. \ 'menu' : '', 'info' : ''
  94. \ }, 'Dictionary(', '('), '')
  95. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  96. \ 'word' : 'Dictionary(', 'abbr' : 'Dictionary(foo)',
  97. \ 'menu' : '', 'info' : ''
  98. \ }, 'Dictionary(', ')'), '${1:#:foo})${2}')
  99. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  100. \ 'word' : 'Dictionary', 'abbr' : 'Dictionary(foo)',
  101. \ 'menu' : '', 'info' : ''
  102. \ }, 'Dictionary', ''), '(${1:#:foo})${2}')
  103. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  104. \ 'word' : 'forEach', 'abbr' : 'forEach(BiConsumer<Object, Object>)',
  105. \ 'menu' : '', 'info' : ''
  106. \ }, 'forEach', ''), '(${1:#:BiConsumer<>})${2}')
  107. call s:assert.equals(neosnippet#parser#_get_completed_snippet({
  108. \ 'word' : 'something', 'abbr' : 'something(else)',
  109. \ 'menu' : '', 'info' : 'func()',
  110. \ }, 'something', ''), '(${1:#:else})${2}')
  111. endfunction