aboutsummaryrefslogtreecommitdiff
path: root/plugins/editorconfig/tests
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/editorconfig/tests')
-rw-r--r--plugins/editorconfig/tests/glob/braces.in71
-rw-r--r--plugins/editorconfig/tests/glob/brackets.in51
-rw-r--r--plugins/editorconfig/tests/glob/init.lua241
-rw-r--r--plugins/editorconfig/tests/glob/question.in7
-rw-r--r--plugins/editorconfig/tests/glob/star.in12
-rw-r--r--plugins/editorconfig/tests/glob/star_star.in15
-rw-r--r--plugins/editorconfig/tests/glob/utf8char.in6
-rw-r--r--plugins/editorconfig/tests/init.lua143
-rw-r--r--plugins/editorconfig/tests/parser/basic.in16
-rw-r--r--plugins/editorconfig/tests/parser/bom.in6
-rw-r--r--plugins/editorconfig/tests/parser/comments.in47
-rw-r--r--plugins/editorconfig/tests/parser/comments_and_newlines.in4
-rw-r--r--plugins/editorconfig/tests/parser/comments_only.in1
-rw-r--r--plugins/editorconfig/tests/parser/crlf.in6
-rw-r--r--plugins/editorconfig/tests/parser/empty.in0
-rw-r--r--plugins/editorconfig/tests/parser/init.lua107
-rw-r--r--plugins/editorconfig/tests/parser/limits.in13
-rw-r--r--plugins/editorconfig/tests/parser/newlines_only.in2
-rw-r--r--plugins/editorconfig/tests/parser/whitespace.in48
-rw-r--r--plugins/editorconfig/tests/properties/indent_size_default.in11
-rw-r--r--plugins/editorconfig/tests/properties/init.lua42
-rw-r--r--plugins/editorconfig/tests/properties/lowercase_names.in6
-rw-r--r--plugins/editorconfig/tests/properties/lowercase_values.in15
-rw-r--r--plugins/editorconfig/tests/properties/tab_width_default.in9
24 files changed, 879 insertions, 0 deletions
diff --git a/plugins/editorconfig/tests/glob/braces.in b/plugins/editorconfig/tests/glob/braces.in
new file mode 100644
index 0000000..0400aeb
--- /dev/null
+++ b/plugins/editorconfig/tests/glob/braces.in
@@ -0,0 +1,71 @@
+; test { and }
+
+root=true
+
+; word choice
+[*.{py,js,html}]
+choice=true
+
+; single choice
+[{single}.b]
+choice=single
+
+; empty choice
+[{}.c]
+empty=all
+
+; choice with empty word
+[a{b,c,}.d]
+empty=word
+
+; choice with empty words
+[a{,b,,c,}.e]
+empty=words
+
+; no closing brace
+[{.f]
+closing=false
+
+; nested braces
+[{word,{also},this}.g]
+nested=true
+
+; nested braces, adjacent at start
+[{{a,b},c}.k]
+nested_start=true
+
+; nested braces, adjacent at end
+[{a,{b,c}}.l]
+nested_end=true
+
+; closing inside beginning
+[{},b}.h]
+closing=inside
+
+; opening inside beginning
+[{{,b,c{d}.i]
+unmatched=true
+
+; escaped comma
+[{a\,b,cd}.txt]
+comma=yes
+
+; escaped closing brace
+[{e,\},f}.txt]
+closing=yes
+
+; escaped backslash
+[{g,\\,i}.txt]
+backslash=yes
+
+; patterns nested in braces
+[{some,a{*c,b}[ef]}.j]
+patterns=nested
+
+; numeric braces
+[{3..120}]
+number=true
+
+; alphabetical
+[{aardvark..antelope}]
+words=a
diff --git a/plugins/editorconfig/tests/glob/brackets.in b/plugins/editorconfig/tests/glob/brackets.in
new file mode 100644
index 0000000..f44def2
--- /dev/null
+++ b/plugins/editorconfig/tests/glob/brackets.in
@@ -0,0 +1,51 @@
+; test [ and ]
+
+root=true
+
+; Character choice
+[[ab].a]
+choice=true
+
+; Negative character choice
+[[!ab].b]
+choice=false
+
+; Character range
+[[d-g].c]
+range=true
+
+; Negative character range
+[[!d-g].d]
+range=false
+
+; Range and choice
+[[abd-g].e]
+range_and_choice=true
+
+; Choice with dash
+[[-ab].f]
+choice_with_dash=true
+
+; Close bracket inside
+[[\]ab].g]
+close_inside=true
+
+; Close bracket outside
+[[ab]].g]
+close_outside=true
+
+; Negative close bracket inside
+[[!\]ab].g]
+close_inside=false
+
+; Negative¬close bracket outside
+[[!ab]].g]
+close_outside=false
+
+; Slash inside brackets
+[ab[e/]cd.i]
+slash_inside=true
+
+; Slash after an half-open bracket
+[ab[/c]
+slash_half_open=true
diff --git a/plugins/editorconfig/tests/glob/init.lua b/plugins/editorconfig/tests/glob/init.lua
new file mode 100644
index 0000000..f1214c3
--- /dev/null
+++ b/plugins/editorconfig/tests/glob/init.lua
@@ -0,0 +1,241 @@
+local tests = require "plugins.editorconfig.tests"
+
+-- Tests for *
+
+-- matches a single characters
+tests.add("star_single_ML", "glob/star.in", "ace.c", "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*")
+
+-- matches zero characters
+tests.add("star_zero_ML", "glob/star.in", "ae.c", "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*")
+
+-- matches multiple characters
+tests.add("star_multiple_ML", "glob/star.in", "abcde.c", "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*")
+
+-- does not match path separator
+tests.add("star_over_slash", "glob/star.in", "a/e.c", "^[ \t\n\r]*keyc=valuec[ \t\n\r]*$")
+
+-- star after a slash
+tests.add("star_after_slash_ML", "glob/star.in", "Bar/foo.txt", "keyb=valueb[ \t\n\r]+keyc=valuec[ \t\n\r]*")
+
+-- star matches a dot file after slash
+tests.add("star_matches_dot_file_after_slash_ML", "glob/star.in", "Bar/.editorconfig", "keyb=valueb[ \t\n\r]+keyc=valuec[ \t\n\r]*")
+
+-- star matches a dot file
+tests.add("star_matches_dot_file", "glob/star.in", ".editorconfig", "^keyc=valuec[ \t\n\r]*$")
+
+-- Tests for ?
+
+-- matches a single character
+tests.add("question_single", "glob/question.in", "some.c", "^key=value[ \t\n\r]*$")
+
+-- does not match zero characters
+tests.add("question_zero", "glob/question.in", "som.c", "^[ \t\n\r]*$")
+
+-- does not match multiple characters
+tests.add("question_multiple", "glob/question.in", "something.c", "^[ \t\n\r]*$")
+
+-- does not match slash
+tests.add("question_slash", "glob/question.in", "som/.c", "^[ \t\n\r]*$")
+
+-- Tests for [ and ]
+
+-- close bracket inside
+tests.add("brackets_close_inside", "glob/brackets.in", "].g", "^close_inside=true[ \t\n\r]*$")
+
+-- close bracket outside
+tests.add("brackets_close_outside", "glob/brackets.in", "b].g", "^close_outside=true[ \t\n\r]*$")
+
+-- negative close bracket inside
+tests.add("brackets_nclose_inside", "glob/brackets.in", "c.g", "^close_inside=false[ \t\n\r]*$")
+
+-- negative close bracket outside
+tests.add("brackets_nclose_outside", "glob/brackets.in", "c].g", "^close_outside=false[ \t\n\r]*$")
+
+-- character choice
+tests.add("brackets_choice", "glob/brackets.in", "a.a", "^choice=true[ \t\n\r]*$")
+
+-- character choice 2
+tests.add("brackets_choice2", "glob/brackets.in", "c.a", "^[ \t\n\r]*$")
+
+-- negative character choice
+tests.add("brackets_nchoice", "glob/brackets.in", "c.b", "^choice=false[ \t\n\r]*$")
+
+-- negative character choice 2
+tests.add("brackets_nchoice2", "glob/brackets.in", "a.b", "^[ \t\n\r]*$")
+
+-- character range
+tests.add("brackets_range", "glob/brackets.in", "f.c", "^range=true[ \t\n\r]*$")
+
+-- character range 2
+tests.add("brackets_range2", "glob/brackets.in", "h.c", "^[ \t\n\r]*$")
+
+-- negative character range
+tests.add("brackets_nrange", "glob/brackets.in", "h.d", "^range=false[ \t\n\r]*$")
+
+-- negative character range 2
+tests.add("brackets_nrange2", "glob/brackets.in", "f.d", "^[ \t\n\r]*$")
+
+-- range and choice
+tests.add("brackets_range_and_choice", "glob/brackets.in", "e.e",
+ "^range_and_choice=true[ \t\n\r]*$")
+
+-- character choice with a dash
+tests.add("brackets_choice_with_dash", "glob/brackets.in", "-.f",
+ "^choice_with_dash=true[ \t\n\r]*$")
+
+-- slash inside brackets
+tests.add("brackets_slash_inside1", "glob/brackets.in", "ab/cd.i",
+ "^[ \t\n\r]*$")
+tests.add("brackets_slash_inside2", "glob/brackets.in", "abecd.i",
+ "^[ \t\n\r]*$")
+tests.add("brackets_slash_inside3", "glob/brackets.in", "ab[e/]cd.i",
+ "^slash_inside=true[ \t\n\r]*$")
+tests.add("brackets_slash_inside4", "glob/brackets.in", "ab[/c",
+ "^slash_half_open=true[ \t\n\r]*$")
+
+-- Tests for { and }
+
+-- word choice
+tests.add("braces_word_choice1", "glob/braces.in", "test.py", "^choice=true[ \t\n\r]*$")
+tests.add("braces_word_choice2", "glob/braces.in", "test.js", "^choice=true[ \t\n\r]*$")
+tests.add("braces_word_choice3", "glob/braces.in", "test.html", "^choice=true[ \t\n\r]*$")
+tests.add("braces_word_choice4", "glob/braces.in", "test.pyc", "^[ \t\n\r]*$")
+
+-- single choice
+tests.add("braces_single_choice", "glob/braces.in", "{single}.b", "^choice=single[ \t\n\r]*$")
+tests.add("braces_single_choice_negative", "glob/braces.in", ".b", "^[ \t\n\r]*$")
+
+-- empty choice
+tests.add("braces_empty_choice", "glob/braces.in", "{}.c", "^empty=all[ \t\n\r]*$")
+tests.add("braces_empty_choice_negative", "glob/braces.in", ".c", "^[ \t\n\r]*$")
+
+-- choice with empty word
+tests.add("braces_empty_word1", "glob/braces.in", "a.d", "^empty=word[ \t\n\r]*$")
+tests.add("braces_empty_word2", "glob/braces.in", "ab.d", "^empty=word[ \t\n\r]*$")
+tests.add("braces_empty_word3", "glob/braces.in", "ac.d", "^empty=word[ \t\n\r]*$")
+tests.add("braces_empty_word4", "glob/braces.in", "a,.d", "^[ \t\n\r]*$")
+
+-- choice with empty words
+tests.add("braces_empty_words1", "glob/braces.in", "a.e", "^empty=words[ \t\n\r]*$")
+tests.add("braces_empty_words2", "glob/braces.in", "ab.e", "^empty=words[ \t\n\r]*$")
+tests.add("braces_empty_words3", "glob/braces.in", "ac.e", "^empty=words[ \t\n\r]*$")
+tests.add("braces_empty_words4", "glob/braces.in", "a,.e", "^[ \t\n\r]*$")
+
+-- no closing brace
+tests.add("braces_no_closing", "glob/braces.in", "{.f", "^closing=false[ \t\n\r]*$")
+tests.add("braces_no_closing_negative", "glob/braces.in", ".f", "^[ \t\n\r]*$")
+
+-- nested braces
+tests.add("braces_nested1", "glob/braces.in", "word,this}.g", "^[ \t\n\r]*$")
+tests.add("braces_nested2", "glob/braces.in", "{also,this}.g", "^[ \t\n\r]*$")
+tests.add("braces_nested3", "glob/braces.in", "word.g", "^nested=true[ \t\n\r]*$")
+tests.add("braces_nested4", "glob/braces.in", "{also}.g", "^nested=true[ \t\n\r]*$")
+tests.add("braces_nested5", "glob/braces.in", "this.g", "^nested=true[ \t\n\r]*$")
+
+-- nested braces, adjacent at start
+tests.add("braces_nested_start1", "glob/braces.in", "{{a,b},c}.k", "^[ \t\n\r]*$")
+tests.add("braces_nested_start2", "glob/braces.in", "{a,b}.k", "^[ \t\n\r]*$")
+tests.add("braces_nested_start3", "glob/braces.in", "a.k", "^nested_start=true[ \t\n\r]*$")
+tests.add("braces_nested_start4", "glob/braces.in", "b.k", "^nested_start=true[ \t\n\r]*$")
+tests.add("braces_nested_start5", "glob/braces.in", "c.k", "^nested_start=true[ \t\n\r]*$")
+
+-- nested braces, adjacent at end
+tests.add("braces_nested_end1", "glob/braces.in", "{a,{b,c}}.l", "^[ \t\n\r]*$")
+tests.add("braces_nested_end2", "glob/braces.in", "{b,c}.l", "^[ \t\n\r]*$")
+tests.add("braces_nested_end3", "glob/braces.in", "a.l", "^nested_end=true[ \t\n\r]*$")
+tests.add("braces_nested_end4", "glob/braces.in", "b.l", "^nested_end=true[ \t\n\r]*$")
+tests.add("braces_nested_end5", "glob/braces.in", "c.l", "^nested_end=true[ \t\n\r]*$")
+
+-- closing inside beginning
+tests.add("braces_closing_in_beginning", "glob/braces.in", "{},b}.h", "^closing=inside[ \t\n\r]*$")
+
+-- missing closing braces
+tests.add("braces_unmatched1", "glob/braces.in", "{{,b,c{d}.i", "^unmatched=true[ \t\n\r]*$")
+tests.add("braces_unmatched2", "glob/braces.in", "{.i", "^[ \t\n\r]*$")
+tests.add("braces_unmatched3", "glob/braces.in", "b.i", "^[ \t\n\r]*$")
+tests.add("braces_unmatched4", "glob/braces.in", "c{d.i", "^[ \t\n\r]*$")
+tests.add("braces_unmatched5", "glob/braces.in", ".i", "^[ \t\n\r]*$")
+
+-- escaped comma
+tests.add("braces_escaped_comma1", "glob/braces.in", "a,b.txt", "^comma=yes[ \t\n\r]*$")
+tests.add("braces_escaped_comma2", "glob/braces.in", "a.txt", "^[ \t\n\r]*$")
+tests.add("braces_escaped_comma3", "glob/braces.in", "cd.txt", "^comma=yes[ \t\n\r]*$")
+
+-- escaped closing brace
+tests.add("braces_escaped_brace1", "glob/braces.in", "e.txt", "^closing=yes[ \t\n\r]*$")
+tests.add("braces_escaped_brace2", "glob/braces.in", "}.txt", "^closing=yes[ \t\n\r]*$")
+tests.add("braces_escaped_brace3", "glob/braces.in", "f.txt", "^closing=yes[ \t\n\r]*$")
+
+-- escaped backslash
+tests.add("braces_escaped_backslash1", "glob/braces.in", "g.txt", "^backslash=yes[ \t\n\r]*$")
+if PLATFORM ~= "Windows" then
+tests.add("braces_escaped_backslash2", "glob/braces.in", "\\.txt", "^backslash=yes[ \t\n\r]*$")
+end
+tests.add("braces_escaped_backslash3", "glob/braces.in", "i.txt", "^backslash=yes[ \t\n\r]*$")
+
+-- patterns nested in braces
+tests.add("braces_patterns_nested1", "glob/braces.in", "some.j", "^patterns=nested[ \t\n\r]*$")
+tests.add("braces_patterns_nested2", "glob/braces.in", "abe.j", "^patterns=nested[ \t\n\r]*$")
+tests.add("braces_patterns_nested3", "glob/braces.in", "abf.j", "^patterns=nested[ \t\n\r]*$")
+tests.add("braces_patterns_nested4", "glob/braces.in", "abg.j", "^[ \t\n\r]*$")
+tests.add("braces_patterns_nested5", "glob/braces.in", "ace.j", "^patterns=nested[ \t\n\r]*$")
+tests.add("braces_patterns_nested6", "glob/braces.in", "acf.j", "^patterns=nested[ \t\n\r]*$")
+tests.add("braces_patterns_nested7", "glob/braces.in", "acg.j", "^[ \t\n\r]*$")
+tests.add("braces_patterns_nested8", "glob/braces.in", "abce.j", "^patterns=nested[ \t\n\r]*$")
+tests.add("braces_patterns_nested9", "glob/braces.in", "abcf.j", "^patterns=nested[ \t\n\r]*$")
+tests.add("braces_patterns_nested10", "glob/braces.in", "abcg.j", "^[ \t\n\r]*$")
+tests.add("braces_patterns_nested11", "glob/braces.in", "ae.j", "^[ \t\n\r]*$")
+tests.add("braces_patterns_nested12", "glob/braces.in", ".j", "^[ \t\n\r]*$")
+
+-- numeric brace range
+tests.add("braces_numeric_range1", "glob/braces.in", "1", "^[ \t\n\r]*$")
+tests.add("braces_numeric_range2", "glob/braces.in", "3", "^number=true[ \t\n\r]*$")
+tests.add("braces_numeric_range3", "glob/braces.in", "15", "^number=true[ \t\n\r]*$")
+tests.add("braces_numeric_range4", "glob/braces.in", "60", "^number=true[ \t\n\r]*$")
+tests.add("braces_numeric_range5", "glob/braces.in", "5a", "^[ \t\n\r]*$")
+tests.add("braces_numeric_range6", "glob/braces.in", "120", "^number=true[ \t\n\r]*$")
+tests.add("braces_numeric_range7", "glob/braces.in", "121", "^[ \t\n\r]*$")
+tests.add("braces_numeric_range8", "glob/braces.in", "060", "^[ \t\n\r]*$")
+
+-- alphabetical brace range: letters should not be considered for ranges
+tests.add("braces_alpha_range1", "glob/braces.in", "{aardvark..antelope}", "^words=a[ \t\n\r]*$")
+tests.add("braces_alpha_range2", "glob/braces.in", "a", "^[ \t\n\r]*$")
+tests.add("braces_alpha_range3", "glob/braces.in", "aardvark", "^[ \t\n\r]*$")
+tests.add("braces_alpha_range4", "glob/braces.in", "agreement", "^[ \t\n\r]*$")
+tests.add("braces_alpha_range5", "glob/braces.in", "antelope", "^[ \t\n\r]*$")
+tests.add("braces_alpha_range6", "glob/braces.in", "antimatter", "^[ \t\n\r]*$")
+
+
+-- Tests for **
+
+-- test EditorConfig files with UTF-8 characters larger than 127
+tests.add("utf_8_char", "glob/utf8char.in", "中文.txt", "^key=value[ \t\n\r]*$")
+
+-- matches over path separator
+tests.add("star_star_over_separator1", "glob/star_star.in", "a/z.c", "^key1=value1[ \t\n\r]*$")
+tests.add("star_star_over_separator2", "glob/star_star.in", "amnz.c", "^key1=value1[ \t\n\r]*$")
+tests.add("star_star_over_separator3", "glob/star_star.in", "am/nz.c", "^key1=value1[ \t\n\r]*$")
+tests.add("star_star_over_separator4", "glob/star_star.in", "a/mnz.c", "^key1=value1[ \t\n\r]*$")
+tests.add("star_star_over_separator5", "glob/star_star.in", "amn/z.c", "^key1=value1[ \t\n\r]*$")
+tests.add("star_star_over_separator6", "glob/star_star.in", "a/mn/z.c", "^key1=value1[ \t\n\r]*$")
+
+tests.add("star_star_over_separator7", "glob/star_star.in", "b/z.c", "^key2=value2[ \t\n\r]*$")
+tests.add("star_star_over_separator8", "glob/star_star.in", "b/mnz.c", "^key2=value2[ \t\n\r]*$")
+tests.add("star_star_over_separator9", "glob/star_star.in", "b/mn/z.c", "^key2=value2[ \t\n\r]*$")
+tests.add("star_star_over_separator10", "glob/star_star.in", "bmnz.c", "^[ \t\n\r]*$")
+tests.add("star_star_over_separator11", "glob/star_star.in", "bm/nz.c", "^[ \t\n\r]*$")
+tests.add("star_star_over_separator12", "glob/star_star.in", "bmn/z.c", "^[ \t\n\r]*$")
+
+tests.add("star_star_over_separator13", "glob/star_star.in", "c/z.c", "^key3=value3[ \t\n\r]*$")
+tests.add("star_star_over_separator14", "glob/star_star.in", "cmn/z.c", "^key3=value3[ \t\n\r]*$")
+tests.add("star_star_over_separator15", "glob/star_star.in", "c/mn/z.c", "^key3=value3[ \t\n\r]*$")
+tests.add("star_star_over_separator16", "glob/star_star.in", "cmnz.c", "^[ \t\n\r]*$")
+tests.add("star_star_over_separator17", "glob/star_star.in", "cm/nz.c", "^[ \t\n\r]*$")
+tests.add("star_star_over_separator18", "glob/star_star.in", "c/mnz.c", "^[ \t\n\r]*$")
+
+tests.add("star_star_over_separator19", "glob/star_star.in", "d/z.c", "^key4=value4[ \t\n\r]*$")
+tests.add("star_star_over_separator20", "glob/star_star.in", "d/mn/z.c", "^key4=value4[ \t\n\r]*$")
+tests.add("star_star_over_separator21", "glob/star_star.in", "dmnz.c", "^[ \t\n\r]*$")
+tests.add("star_star_over_separator22", "glob/star_star.in", "dm/nz.c", "^[ \t\n\r]*$")
+tests.add("star_star_over_separator23", "glob/star_star.in", "d/mnz.c", "^[ \t\n\r]*$")
+tests.add("star_star_over_separator24", "glob/star_star.in", "dmn/z.c", "^[ \t\n\r]*$")
diff --git a/plugins/editorconfig/tests/glob/question.in b/plugins/editorconfig/tests/glob/question.in
new file mode 100644
index 0000000..e2af52a
--- /dev/null
+++ b/plugins/editorconfig/tests/glob/question.in
@@ -0,0 +1,7 @@
+; test ?
+
+root=true
+
+[som?.c]
+key=value
+
diff --git a/plugins/editorconfig/tests/glob/star.in b/plugins/editorconfig/tests/glob/star.in
new file mode 100644
index 0000000..c7d874f
--- /dev/null
+++ b/plugins/editorconfig/tests/glob/star.in
@@ -0,0 +1,12 @@
+; test *
+
+root=true
+
+[a*e.c]
+key=value
+
+[Bar/*]
+keyb=valueb
+
+[*]
+keyc=valuec
diff --git a/plugins/editorconfig/tests/glob/star_star.in b/plugins/editorconfig/tests/glob/star_star.in
new file mode 100644
index 0000000..c8f2c99
--- /dev/null
+++ b/plugins/editorconfig/tests/glob/star_star.in
@@ -0,0 +1,15 @@
+; test **
+
+root=true
+
+[a**z.c]
+key1=value1
+
+[b/**z.c]
+key2=value2
+
+[c**/z.c]
+key3=value3
+
+[d/**/z.c]
+key4=value4
diff --git a/plugins/editorconfig/tests/glob/utf8char.in b/plugins/editorconfig/tests/glob/utf8char.in
new file mode 100644
index 0000000..6fe89b0
--- /dev/null
+++ b/plugins/editorconfig/tests/glob/utf8char.in
@@ -0,0 +1,6 @@
+; test EditorConfig files with UTF-8 characters larger than 127
+
+root = true
+
+[中文.txt]
+key = value
diff --git a/plugins/editorconfig/tests/init.lua b/plugins/editorconfig/tests/init.lua
new file mode 100644
index 0000000..654067b
--- /dev/null
+++ b/plugins/editorconfig/tests/init.lua
@@ -0,0 +1,143 @@
+local Parser = require "plugins.editorconfig.parser"
+
+local tests = {}
+
+---@class tests.test
+---@field name string Name of test
+---@field config string Path to config file
+---@field in_match string A path to test against the config
+---@field out_match string A regex to match against the result
+
+---Registered tests
+---@type tests.test[]
+tests.list = {}
+
+--- parsers cache
+---@type table<string,plugins.editorconfig.parser>
+local parsers = {}
+setmetatable(parsers, {
+ __index = function(t, k)
+ local v = rawget(t, k)
+ if v == nil then
+ v = Parser.new(k)
+ rawset(t, k, v)
+ end
+ return v
+ end
+})
+
+---Adds color to given text on non windows systems.
+---@param text string
+---@param color "red" | "green" | "yellow"
+---@return string colorized_text
+local function colorize(text, color)
+ if PLATFORM ~= "Windows" then
+ if color == "green" then
+ return "\27[92m"..text.."\27[0m"
+ elseif color == "red" then
+ return "\27[91m"..text.."\27[0m"
+ elseif color == "yellow" then
+ return "\27[93m"..text.."\27[0m"
+ end
+ end
+ return text
+end
+
+local PASSED = colorize("PASSED", "green")
+local FAILED = colorize("FAILED", "red")
+
+---Runs an individual test (executed by tests.run())
+---@param name string Test name
+---@param config_path string Relative path to tests diretory for a [config].in
+---@param in_match string Filename to match
+---@param out_match string | table Result to match regex
+function tests.check_config(name, config_path, in_match, out_match, pos, total)
+ if type(out_match) == "string" then
+ out_match = { out_match }
+ end
+ local parser = parsers[USERDIR .. "/plugins/editorconfig/tests/" .. config_path]
+ local config = parser:getConfigString(in_match)
+ local passed = true
+ for _, match in ipairs(out_match) do
+ if not regex.match(match, config) then
+ passed = false
+ break
+ end
+ end
+ if pos then
+ pos = "[" .. pos .. "/" .. total .. "] "
+ else
+ pos = ""
+ end
+ if passed then
+ print(pos .. string.format("%s - %s - '%s': %s", name, in_match, config_path, PASSED))
+ else
+ print(pos .. string.format("%s - %s - '%s': %s", name, in_match, config_path, FAILED))
+ print(config)
+ end
+ return passed
+end
+
+---Register a new test to be run later.
+---@param name string Test name
+---@param config_path string Relative path to tests diretory for a [config].in
+---@param in_match string Filename to match
+---@param out_match string | table Result to match regex
+function tests.add(name, config_path, in_match, out_match)
+ table.insert(tests.list, {
+ name = name,
+ config = config_path,
+ in_match = in_match,
+ out_match = out_match
+ })
+end
+
+---Runs all registered tests and outputs the results to terminal.
+function tests.run()
+ print "========================================================="
+ print "Running Tests"
+ print "========================================================="
+ local failed = 0
+ local passed = 0
+ local total = #tests.list
+ for i, test in ipairs(tests.list) do
+ local res = tests.check_config(
+ test.name, test.config, test.in_match, test.out_match, i, total
+ )
+ if res then passed = passed + 1 else failed = failed + 1 end
+ end
+ print "========================================================="
+ print (
+ string.format(
+ "%s %s %s",
+ colorize("Total tests: " .. #tests.list, "yellow"),
+ colorize("Passed: " .. passed, "green"),
+ colorize("Failed: " .. failed, "red")
+ )
+ )
+ print "========================================================="
+end
+
+function tests.add_parser(config_path)
+ return parsers[config_path]
+end
+
+function tests.run_parsers()
+ print "========================================================="
+ print "Running Parsers"
+ print "========================================================="
+
+ for config, parser in pairs(parsers) do
+ print "---------------------------------------------------------"
+ print(string.format("%s results:", config))
+ for _, section in ipairs(parser.sections) do
+ print(string.format("\nPath expression: %s", section.rule.expression))
+ print(string.format("Regex: %s", section.rule.regex))
+ print(string.format("Negation: %s", section.rule.negation and "true" or "false"))
+ print(string.format("Ranges: %s\n", section.rule.ranges and #section.rule.ranges or "0"))
+ end
+ print "---------------------------------------------------------"
+ end
+end
+
+return tests
diff --git a/plugins/editorconfig/tests/parser/basic.in b/plugins/editorconfig/tests/parser/basic.in
new file mode 100644
index 0000000..3033b9a
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/basic.in
@@ -0,0 +1,16 @@
+[*.a]
+option1=value1
+
+; repeat section
+[*.a]
+option2=value2
+
+[*.b]
+option1 = a
+option2 = a
+
+[b.b]
+option2 = b
+
+[*.b]
+option1 = c
diff --git a/plugins/editorconfig/tests/parser/bom.in b/plugins/editorconfig/tests/parser/bom.in
new file mode 100644
index 0000000..8bde201
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/bom.in
@@ -0,0 +1,6 @@
+; test EditorConfig files with BOM
+
+root = true
+
+[*]
+key = value
diff --git a/plugins/editorconfig/tests/parser/comments.in b/plugins/editorconfig/tests/parser/comments.in
new file mode 100644
index 0000000..c49fba8
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/comments.in
@@ -0,0 +1,47 @@
+; test comments
+
+root = true
+
+[test3.c]
+; Comment before properties ignored
+key=value
+
+[test4.c]
+key1=value1
+; Comment between properties ignored
+key2=value2
+
+; Semicolon or hash at end of value read as part of value
+[test5.c]
+key1=value; not comment
+key2=value # not comment
+
+; Backslash before a semicolon or hash is part of the value
+[test6.c]
+key1=value \; not comment
+key2=value \# not comment
+
+; Escaped semicolon in section name
+[test\;.c]
+key=value
+
+[test9.c]
+# Comment before properties ignored
+key=value
+
+[test10.c]
+key1=value1
+# Comment between properties ignored
+key2=value2
+
+# Octothorpe at end of value read as part of value
+[test11.c]
+key=value# not comment
+
+# Escaped octothorpe in value
+[test12.c]
+key=value \# not comment
+
+# Escaped octothorpe in section name
+[test\#.c]
+key=value
diff --git a/plugins/editorconfig/tests/parser/comments_and_newlines.in b/plugins/editorconfig/tests/parser/comments_and_newlines.in
new file mode 100644
index 0000000..35fc023
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/comments_and_newlines.in
@@ -0,0 +1,4 @@
+
+# Just comments
+
+# ... and newlines
diff --git a/plugins/editorconfig/tests/parser/comments_only.in b/plugins/editorconfig/tests/parser/comments_only.in
new file mode 100644
index 0000000..9592ed2
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/comments_only.in
@@ -0,0 +1 @@
+# Just a comment, nothing else \ No newline at end of file
diff --git a/plugins/editorconfig/tests/parser/crlf.in b/plugins/editorconfig/tests/parser/crlf.in
new file mode 100644
index 0000000..ec582d2
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/crlf.in
@@ -0,0 +1,6 @@
+; test EditorConfig files with CRLF line separators
+
+root = true
+
+[*]
+key = value
diff --git a/plugins/editorconfig/tests/parser/empty.in b/plugins/editorconfig/tests/parser/empty.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/empty.in
diff --git a/plugins/editorconfig/tests/parser/init.lua b/plugins/editorconfig/tests/parser/init.lua
new file mode 100644
index 0000000..cf473e5
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/init.lua
@@ -0,0 +1,107 @@
+local tests = require "plugins.editorconfig.tests"
+
+-- Basic parser tests
+
+-- test repeat sections
+tests.add("repeat_sections_ML", "parser/basic.in", "a.a", "option1=value1[ \t]*[\n\r]+option2=value2[ \t\n\r]*")
+tests.add("basic_cascade_ML", "parser/basic.in", "b.b", "option1=c[ \t]*[\n\r]+option2=b[ \t\n\r]*")
+
+-- Tests for whitespace parsing
+
+-- test no whitespaces in property assignment
+tests.add("no_whitespace", "parser/whitespace.in", "test1.c", "^key=value[ \t\n\r]*$")
+
+-- test single spaces around equals sign
+tests.add("single_spaces_around_equals", "parser/whitespace.in", "test2.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test multiple spaces around equals sign
+tests.add("multiple_spaces_around_equals", "parser/whitespace.in", "test3.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test spaces before property name
+tests.add("spaces_before_property_name", "parser/whitespace.in", "test4.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test spaces before after property value
+tests.add("spaces_after_property_value", "parser/whitespace.in", "test5.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test blank lines between properties
+tests.add("blank_lines_between_properties_ML", "parser/whitespace.in", "test6.c",
+ "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")
+
+-- test spaces in section name
+tests.add("spaces_in_section_name", "parser/whitespace.in", " test 7 ",
+ "^key=value[ \t\n\r]*$")
+
+-- test spaces before section name are ignored
+tests.add("spaces_before_section_name", "parser/whitespace.in", "test8.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test spaces after section name
+tests.add("spaces_after_section_name", "parser/whitespace.in", "test9.c", "^key=value[ \t\n\r]*$")
+
+-- test spaces at beginning of line between properties
+tests.add("spaces_before_middle_property_ML", "parser/whitespace.in", "test10.c",
+ "key1=value1[ \t]*[\n\r]+key2=value2[ \t]*[\n\r]+key3=value3[ \t\n\r]*")
+
+-- Tests for comment parsing
+
+-- test comments ignored before properties
+tests.add("comment_before_props", "parser/comments.in", "test3.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test comments ignored between properties
+tests.add("comment_between_props_ML", "parser/comments.in", "test4.c",
+ "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")
+
+-- test semicolons and hashes at end of property value are included in value
+tests.add("semicolon_or_hash_in_property", "parser/comments.in", "test5.c",
+ "^key1=value; not comment[\n\r]+key2=value # not comment[ \t\n\r]*$")
+
+-- test that backslashes before semicolons and hashes in property values
+-- are included in value.
+-- NOTE: [\\] matches a single literal backslash.
+tests.add("backslashed_semicolon_or_hash_in_property", "parser/comments.in", "test6.c",
+ "^key1=value [\\\\]; not comment[\n\r]+key2=value [\\\\]# not comment[ \t\n\r]*$")
+
+-- test escaped semicolons are included in section names
+tests.add("escaped_semicolon_in_section", "parser/comments.in", "test;.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test octothorpe comments ignored before properties
+tests.add("octothorpe_comment_before_props", "parser/comments.in", "test9.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test octothorpe comments ignored between properties
+tests.add("octothorpe_comment_between_props_ML", "parser/comments.in", "test10.c",
+ "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")
+
+-- test octothorpe at end of property value are included in value
+tests.add("octothorpe_in_value", "parser/comments.in", "test11.c",
+ "^key=value# not comment[ \t\n\r]*$")
+
+-- test escaped octothorpes are included in section names
+tests.add("escaped_octothorpe_in_section", "parser/comments.in", "test#.c",
+ "^key=value[ \t\n\r]*$")
+
+-- test EditorConfig files with BOM at the head
+tests.add("bom_at_head", "parser/bom.in", "a.c", "^key=value[ \t\n\r]*$")
+
+-- test EditorConfig files with CRLF line separators
+tests.add("crlf_linesep", "parser/crlf.in", "a.c", "^key=value[ \t\n\r]*$")
+
+-- Test minimum supported lengths of section name, key and value
+tests.add("min_supported_key_length", "parser/limits.in", "test1",
+ "^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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\r]*$")
+
+-- Empty .editorconfig files
+tests.add("empty_editorconfig_file", "parser/empty.in", "test4", "^[ \t\n\r]*$")
+tests.add("newlines_only_editorconfig_file", "parser/newlines_only.in", "test4", "^[ \t\n\r]*$")
+tests.add("comments_only_editorconfig_file", "parser/comments_only.in", "test4", "^[ \t\n\r]*$")
+tests.add("comments_and_newlines_editorconfig_file", "parser/comments_and_newlines.in", "test4", "^[ \t\n\r]*$")
diff --git a/plugins/editorconfig/tests/parser/limits.in b/plugins/editorconfig/tests/parser/limits.in
new file mode 100644
index 0000000..d768a8c
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/limits.in
@@ -0,0 +1,13 @@
+root = true
+
+; minimum supported key length of 1024 characters
+[test1]
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}]
+k1024=v1024
diff --git a/plugins/editorconfig/tests/parser/newlines_only.in b/plugins/editorconfig/tests/parser/newlines_only.in
new file mode 100644
index 0000000..139597f
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/newlines_only.in
@@ -0,0 +1,2 @@
+
+
diff --git a/plugins/editorconfig/tests/parser/whitespace.in b/plugins/editorconfig/tests/parser/whitespace.in
new file mode 100644
index 0000000..d1f3c5f
--- /dev/null
+++ b/plugins/editorconfig/tests/parser/whitespace.in
@@ -0,0 +1,48 @@
+; test whitespace usage
+
+root = true
+
+; no whitespace
+[test1.c]
+key=value
+
+; spaces around equals
+[test2.c]
+key = value
+
+; lots of space after equals
+[test3.c]
+key = value
+
+; spaces before property name
+[test4.c]
+ key=value
+
+; spaces after property value
+[test5.c]
+key=value
+
+; blank lines between properties
+[test6.c]
+
+key1=value1
+
+key2=value2
+
+; spaces in section name
+[ test 7 ]
+key=value
+
+; spaces before section name
+ [test8.c]
+key=value
+
+; spaces after section name
+[test9.c]
+key=value
+
+; spacing before middle property
+[test10.c]
+key1=value1
+ key2=value2
+key3=value3
diff --git a/plugins/editorconfig/tests/properties/indent_size_default.in b/plugins/editorconfig/tests/properties/indent_size_default.in
new file mode 100644
index 0000000..809fc3f
--- /dev/null
+++ b/plugins/editorconfig/tests/properties/indent_size_default.in
@@ -0,0 +1,11 @@
+root = true
+
+[test.c]
+indent_style = tab
+
+[test2.c]
+indent_style = space
+
+[test3.c]
+indent_style = tab
+tab_width = 2
diff --git a/plugins/editorconfig/tests/properties/init.lua b/plugins/editorconfig/tests/properties/init.lua
new file mode 100644
index 0000000..4ae22d0
--- /dev/null
+++ b/plugins/editorconfig/tests/properties/init.lua
@@ -0,0 +1,42 @@
+local tests = require "plugins.editorconfig.tests"
+
+-- test tab_width default
+tests.add("tab_width_default_ML", "properties/tab_width_default.in", "test.c",
+ "indent_size=4[ \t]*[\n\r]+indent_style=space[ \t]*[\n\r]+tab_width=4[\t\n\r]*")
+
+-- Tab_width should not be set to any value if indent_size is "tab" and
+-- tab_width is not set
+tests.add("tab_width_default_indent_size_tab_ML", "properties/tab_width_default.in",
+ "test2.c", "indent_size=tab[ \t]*[\n\r]+indent_style=tab[ \t\n\r]*")
+
+-- Test indent_size default. When indent_style is "tab", indent_size defaults to
+-- "tab".
+tests.add("indent_size_default_ML", "properties/indent_size_default.in", "test.c",
+ "indent_size=tab[ \t]*[\n\r]+indent_style=tab[ \t\n\r]*")
+
+-- Test indent_size default. When indent_style is "space", indent_size has no
+-- default value.
+tests.add("indent_size_default_space", "properties/indent_size_default.in", "test2.c",
+ "^indent_style=space[ \t\n\r]*$")
+
+-- Test indent_size default. When indent_style is "tab" and tab_width is set,
+-- indent_size should default to tab_width
+tests.add("indent_size_default_with_tab_width_ML",
+ "properties/indent_size_default.in", "test3.c",
+ "indent_size=2[ \t]*[\n\r]+indent_style=tab[ \t]*[\n\r]+tab_width=2[ \t\n\r]*")
+
+-- test that same property values are lowercased (v0.9.0 properties)
+tests.add("lowercase_values1_ML", "properties/lowercase_values.in", "test1.c",
+ "end_of_line=crlf[ \t]*[\n\r]+indent_style=space[ \t\n\r]*")
+
+-- test that same property values are lowercased (v0.9.0 properties)
+tests.add("lowercase_values2_ML", "properties/lowercase_values.in", "test2.c",
+ "charset=utf-8[ \t]*[\n\r]+insert_final_newline=true[ \t]*[\n\r]+trim_trailing_whitespace=false[ \t\n\r]*$")
+
+-- test that same property values are not lowercased
+tests.add("lowercase_values3", "properties/lowercase_values.in", "test3.c",
+ "^test_property=TestValue[ \t\n\r]*$")
+
+-- test that all property names are lowercased
+tests.add("lowercase_names", "properties/lowercase_names.in", "test.c",
+ "^testproperty=testvalue[ \t\n\r]*$")
diff --git a/plugins/editorconfig/tests/properties/lowercase_names.in b/plugins/editorconfig/tests/properties/lowercase_names.in
new file mode 100644
index 0000000..253ea8b
--- /dev/null
+++ b/plugins/editorconfig/tests/properties/lowercase_names.in
@@ -0,0 +1,6 @@
+; test that property names are lowercased
+
+root = true
+
+[test.c]
+TestProperty = testvalue
diff --git a/plugins/editorconfig/tests/properties/lowercase_values.in b/plugins/editorconfig/tests/properties/lowercase_values.in
new file mode 100644
index 0000000..1730bb2
--- /dev/null
+++ b/plugins/editorconfig/tests/properties/lowercase_values.in
@@ -0,0 +1,15 @@
+; test property name lowercasing
+
+root = true
+
+[test1.c]
+indent_style = Space
+end_of_line = CRLF
+
+[test2.c]
+insert_final_newline = TRUE
+trim_trailing_whitespace = False
+charset = UTF-8
+
+[test3.c]
+test_property = TestValue
diff --git a/plugins/editorconfig/tests/properties/tab_width_default.in b/plugins/editorconfig/tests/properties/tab_width_default.in
new file mode 100644
index 0000000..3084607
--- /dev/null
+++ b/plugins/editorconfig/tests/properties/tab_width_default.in
@@ -0,0 +1,9 @@
+root = true
+
+[test.c]
+indent_style = space
+indent_size = 4
+
+[test2.c]
+indent_style = tab
+indent_size = tab