From 63f65ea87421b63617692a29e0dfb4820b264e84 Mon Sep 17 00:00:00 2001 From: cwahbong Date: Sat, 26 Jul 2014 16:10:22 +0800 Subject: [PATCH] Add/modify test cases for priority-based clearsnippets. --- test/test_ParseSnippets.py | 8 ++--- test/test_SnippetPriorities.py | 65 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/test/test_ParseSnippets.py b/test/test_ParseSnippets.py index 072f0e0..4a870a5 100644 --- a/test/test_ParseSnippets.py +++ b/test/test_ParseSnippets.py @@ -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 diff --git a/test/test_SnippetPriorities.py b/test/test_SnippetPriorities.py index ae2ea8c..a43a3ea 100644 --- a/test/test_SnippetPriorities.py +++ b/test/test_SnippetPriorities.py @@ -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 #}}}