UltiSnips/test/test_SnipMate.py

161 lines
3.9 KiB
Python
Raw Normal View History

# encoding: utf-8
from test.vim_test_case import VimTestCase as _VimTest
from test.constant import *
# snipMate support {{{#
2015-01-20 15:26:03 -05:00
class snipMate_SimpleSnippet(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet hello
\tThis is a test snippet
\t# With a comment"""}
2015-01-20 15:26:03 -05:00
keys = 'hello' + EX
wanted = 'This is a test snippet\n# With a comment'
class snipMate_Disabled(_VimTest):
files = { 'snippets/_.snippets': """
snippet hello
\tThis is a test snippet
\t# With a comment"""}
keys = 'hello' + EX
wanted = 'hello' + EX
def _extra_vim_config(self, vim_config):
vim_config.append("let g:UltiSnipsEnableSnipMate=0");
2015-01-20 15:26:03 -05:00
class snipMate_OtherFiletype(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/blubi.snippets': """
snippet hello
\tworked"""}
2015-01-20 15:26:03 -05:00
keys = 'hello' + EX + ESC + ':set ft=blubi\nohello' + EX
wanted = 'hello' + EX + '\nworked'
class snipMate_MultiMatches(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet hello The first snippet."
\tone
snippet hello The second snippet.
\ttwo"""}
2015-01-20 15:26:03 -05:00
keys = 'hello' + EX + '2\n'
wanted = 'two'
class snipMate_SimpleSnippetSubDirectory(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_/blub.snippets': """
snippet hello
\tThis is a test snippet"""}
2015-01-20 15:26:03 -05:00
keys = 'hello' + EX
wanted = 'This is a test snippet'
class snipMate_SimpleSnippetInSnippetFile(_VimTest):
files = {
2015-01-20 15:26:03 -05:00
'snippets/_/hello.snippet': """This is a stand alone snippet""",
'snippets/_/hello1.snippet': """This is two stand alone snippet""",
'snippets/_/hello2/this_is_my_cool_snippet.snippet': """Three""",
}
2015-01-20 15:26:03 -05:00
keys = 'hello' + EX + '\nhello1' + EX + '\nhello2' + EX
wanted = 'This is a stand alone snippet\nThis is two stand alone snippet\nThree'
class snipMate_Interpolation(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet test
\tla`printf('c%02d', 3)`lu"""}
2015-01-20 15:26:03 -05:00
keys = 'test' + EX
wanted = 'lac03lu'
class snipMate_InterpolationWithSystem(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet test
\tla`system('echo -ne öäü')`lu"""}
2015-01-20 15:26:03 -05:00
keys = 'test' + EX
wanted = 'laöäülu'
class snipMate_TestMirrors(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet for
\tfor (${2:i}; $2 < ${1:count}; $1++) {
\t\t${4}
\t}"""}
2015-01-20 15:26:03 -05:00
keys = 'for' + EX + 'blub' + JF + 'j' + JF + 'hi'
wanted = 'for (j; j < blub; blub++) {\n\thi\n}'
class snipMate_TestMirrorsInPlaceholders(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet opt
\t<option value="${1:option}">${2:$1}</option>"""}
2015-01-20 15:26:03 -05:00
keys = 'opt' + EX + 'some' + JF + JF + 'ende'
wanted = """<option value="some">some</option>ende"""
2015-01-20 15:26:03 -05:00
class snipMate_TestMirrorsInPlaceholders_Overwrite(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet opt
\t<option value="${1:option}">${2:$1}</option>"""}
2015-01-20 15:26:03 -05:00
keys = 'opt' + EX + 'some' + JF + 'not' + JF + 'ende'
wanted = """<option value="some">not</option>ende"""
2015-01-20 15:26:03 -05:00
class snipMate_Visual_Simple(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet v
\th${VISUAL}b"""}
2015-01-20 15:26:03 -05:00
keys = 'blablub' + ESC + '0v6l' + EX + 'v' + EX
wanted = 'hblablubb'
class snipMate_NoNestedTabstops(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet test
\th$${1:${2:blub}}$$"""}
2015-01-20 15:26:03 -05:00
keys = 'test' + EX + JF + 'hi'
wanted = 'h$${2:blub}$$hi'
class snipMate_Extends(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/a.snippets': """
extends b
snippet test
2015-01-20 15:26:03 -05:00
\tblub""", 'snippets/b.snippets': """
snippet test1
\tblah"""
2015-01-20 15:26:03 -05:00
}
keys = ESC + ':set ft=a\n' + 'itest1' + EX
wanted = 'blah'
class snipMate_EmptyLinesContinueSnippets(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet test
\tblub
\tblah
snippet test1
\ta"""
2015-01-20 15:26:03 -05:00
}
keys = 'test' + EX
wanted = 'blub\n\nblah\n'
class snipMate_OverwrittenByRegExpTrigger(_VimTest):
2015-01-20 15:26:03 -05:00
files = { 'snippets/_.snippets': """
snippet def
\tsnipmate
""",
2015-01-20 15:26:03 -05:00
'us/all.snippets': r"""
snippet "(de)?f" "blub" r
ultisnips
endsnippet
""" }
2015-01-20 15:26:03 -05:00
keys = 'def' + EX
wanted = 'ultisnips'
# End: snipMate support #}}}