Add/modify test cases for priority-based clearsnippets.

This commit is contained in:
cwahbong 2014-07-26 16:10:22 +08:00
parent 4784a9e126
commit 63f65ea874
2 changed files with 69 additions and 4 deletions

View File

@ -64,6 +64,8 @@ class ParseSnippets_ClearAll(_VimTest):
class ParseSnippets_ClearOne(_VimTest):
files = { "us/all.snippets": r"""
clearsnippets toclear
snippet testsnip "Test snippet"
This is a test.
endsnippet
@ -71,14 +73,14 @@ class ParseSnippets_ClearOne(_VimTest):
snippet toclear "Snippet to clear"
Do not expand.
endsnippet
clearsnippets toclear
"""}
keys = "toclear" + EX + "\n" + "testsnip" + EX
wanted = "toclear" + EX + "\n" + "This is a test."
class ParseSnippets_ClearTwo(_VimTest):
files = { "us/all.snippets": r"""
clearsnippets testsnip toclear
snippet testsnip "Test snippet"
This is a test.
endsnippet
@ -86,8 +88,6 @@ class ParseSnippets_ClearTwo(_VimTest):
snippet toclear "Snippet to clear"
Do not expand.
endsnippet
clearsnippets testsnip toclear
"""}
keys = "toclear" + EX + "\n" + "testsnip" + EX
wanted = "toclear" + EX + "\n" + "testsnip" + EX

View File

@ -10,6 +10,7 @@ class SnippetPriorities_MultiWordTriggerOverwriteExisting(_VimTest):
)
keys = "test me" + EX
wanted = "We overwrite"
class SnippetPriorities_DoNotCareAboutNonMatchings(_VimTest):
snippets = (
("test1", "Hallo", "Types Hallo"),
@ -17,6 +18,7 @@ class SnippetPriorities_DoNotCareAboutNonMatchings(_VimTest):
)
keys = "test1" + EX
wanted = "Hallo"
class SnippetPriorities_OverwriteExisting(_VimTest):
snippets = (
("test", "${1:Hallo}", "Types Hallo"),
@ -25,6 +27,7 @@ class SnippetPriorities_OverwriteExisting(_VimTest):
)
keys = "test" + EX
wanted = "We overwrite"
class SnippetPriorities_OverwriteTwice_ECR(_VimTest):
snippets = (
("test", "${1:Hallo}", "Types Hallo"),
@ -34,6 +37,7 @@ class SnippetPriorities_OverwriteTwice_ECR(_VimTest):
)
keys = "test" + EX
wanted = "again"
class SnippetPriorities_OverwriteThenChoose_ECR(_VimTest):
snippets = (
("test", "${1:Hallo}", "Types Hallo"),
@ -43,6 +47,7 @@ class SnippetPriorities_OverwriteThenChoose_ECR(_VimTest):
)
keys = "test" + EX + "1\n\n" + "test" + EX + "2\n"
wanted = "We overwrite\nNo overwrite"
class SnippetPriorities_AddedHasHigherThanFile(_VimTest):
files = { "us/all.snippets": r"""
snippet test "Test Snippet" b
@ -54,6 +59,7 @@ class SnippetPriorities_AddedHasHigherThanFile(_VimTest):
)
keys = "test" + EX
wanted = "We overwrite"
class SnippetPriorities_FileHasHigherThanAdded(_VimTest):
files = { "us/all.snippets": r"""
snippet test "Test Snippet" b
@ -65,6 +71,7 @@ class SnippetPriorities_FileHasHigherThanAdded(_VimTest):
)
keys = "test" + EX
wanted = "This is a test snippet"
class SnippetPriorities_FileHasHigherThanAdded(_VimTest):
files = { "us/all.snippets": r"""
priority -3
@ -77,4 +84,62 @@ class SnippetPriorities_FileHasHigherThanAdded(_VimTest):
)
keys = "test" + EX
wanted = "This is a test snippet"
class SnippetPriorities_SimpleClear(_VimTest):
files = {
"us/all.snippets": r"""
priority 1
clearsnippets
priority -1
snippet test "Test Snippet"
Should not expand to this.
endsnippet
"""
}
keys = "test" + EX
wanted = "test" + EX
class SnippetPriorities_SimpleClear2(_VimTest):
files = {
"us/all.snippets": r"""
clearsnippets
snippet test "Test snippet"
Should not expand to this.
endsnippet
"""
}
keys = "test" + EX
wanted = "test" + EX
class SnippetPriorities_ClearedByParent(_VimTest):
files = {
"us/p.snippets": r"""
clearsnippets
""",
"us/c.snippets": r"""
extends p
snippet test "Test snippets"
Should not expand to this.
endsnippet
"""
}
keys = ESC + ":set ft=c\n" + "itest" + EX
wanted = "test" + EX
class SnippetPriorities_ClearedByChild(_VimTest):
files = {
"us/p.snippets": r"""
snippet test "Test snippets"
Should only expand in p.
endsnippet
""",
"us/c.snippets": r"""
extends p
clearsnippets
"""
}
keys = (ESC + ":set ft=p\n" + "itest" + EX + "\n" +
ESC + ":set ft=c\n" + "itest" + EX + ESC + ":set ft=p")
wanted = "Should only expand in p.\ntest" + EX
# End: Snippet Priority #}}}