neosnippet.vim/test/functions.vim

92 lines
3.1 KiB
VimL
Raw Normal View History

2015-08-31 20:56:41 +00:00
let s:suite = themis#suite('toml')
let s:assert = themis#helper('assert')
function! s:suite.get_in_paren()
2015-12-26 03:12:08 +00:00
call s:assert.equals(neosnippet#parser#_get_in_paren(
\ '(', ')',
2015-12-12 09:08:13 +00:00
\ '(foobar)'),
2015-08-31 20:56:41 +00:00
\ 'foobar')
2015-12-26 03:12:08 +00:00
call s:assert.equals(neosnippet#parser#_get_in_paren(
\ '(', ')',
2015-12-12 09:08:13 +00:00
\ '(foobar, baz)'),
2015-08-31 20:56:41 +00:00
\ 'foobar, baz')
2015-12-26 03:12:08 +00:00
call s:assert.equals(neosnippet#parser#_get_in_paren(
\ '(', ')',
2015-12-12 09:08:13 +00:00
\ '(foobar, (baz))'),
2015-08-31 20:56:41 +00:00
\ 'foobar, (baz)')
2015-12-26 03:12:08 +00:00
call s:assert.equals(neosnippet#parser#_get_in_paren(
\ '(', ')',
2015-12-12 09:08:13 +00:00
\ 'foobar('),
2015-12-11 16:51:49 +00:00
\ '')
2015-12-26 03:12:08 +00:00
call s:assert.equals(neosnippet#parser#_get_in_paren(
\ '(', ')',
2015-12-12 09:08:13 +00:00
\ 'foobar()'),
\ '')
2015-12-26 03:12:08 +00:00
call s:assert.equals(neosnippet#parser#_get_in_paren(
\ '(', ')',
2015-12-12 09:08:13 +00:00
\ 'foobar(fname)'),
2015-12-11 16:51:49 +00:00
\ 'fname')
2015-12-26 03:12:08 +00:00
call s:assert.equals(neosnippet#parser#_get_in_paren(
\ '(', ')',
2015-12-12 09:08:13 +00:00
\ 'wait() wait(long, int)'),
\ 'long, int')
2015-08-31 20:56:41 +00:00
endfunction
2015-12-26 03:12:08 +00:00
function! s:suite.get_completed_snippet()
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo()',
\ 'menu' : '', 'info' : ''
\ }), ')${1}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo', 'abbr' : 'foo(hoge)',
\ 'menu' : '', 'info' : ''
\ }), '')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge, piyo)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge}, ${2:#:piyo})${3}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge, piyo(foobar))',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge}, ${2:#:piyo()})${3}')
2015-12-30 03:49:24 +00:00
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge[, abc])',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge[, abc]})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(...)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:...})${2}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo(hoge, ...)',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:hoge}${2:#:, ...})${3}')
2015-12-26 03:12:08 +00:00
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo{', 'abbr' : 'foo{}',
\ 'menu' : '', 'info' : ''
\ }), '}${1}')
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo{', 'abbr' : 'foo{piyo}',
\ 'menu' : '', 'info' : ''
\ }), '${1:#:piyo}}${2}')
2015-12-26 03:39:45 +00:00
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'Dictionary(', 'abbr' : 'Dictionary<Key, Value>(foo)',
\ 'menu' : '', 'info' : ''
\ }), '<${1:#:Key}, ${2:#:Value}>${3:#:foo})${4}')
2015-12-26 03:12:08 +00:00
endfunction