| 1 |
# |
| 2 |
# Copyright (c) 2011-2018 EditorConfig Team |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# Redistribution and use in source and binary forms, with or without |
| 6 |
# modification, are permitted provided that the following conditions are met: |
| 7 |
# |
| 8 |
# 1. Redistributions of source code must retain the above copyright notice, |
| 9 |
# this list of conditions and the following disclaimer. |
| 10 |
# 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 |
# this list of conditions and the following disclaimer in the documentation |
| 12 |
# and/or other materials provided with the distribution. |
| 13 |
# |
| 14 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 15 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 17 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 18 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 19 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 20 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 21 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 22 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 23 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 24 |
# POSSIBILITY OF SUCH DAMAGE. |
| 25 |
# |
| 26 |
|
| 27 |
# Tests for * |
| 28 |
|
| 29 |
# matches a single characters |
| 30 |
new_ec_test_multiline(star_single_ML star.in ace.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*") |
| 31 |
|
| 32 |
# matches zero characters |
| 33 |
new_ec_test_multiline(star_zero_ML star.in ae.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*") |
| 34 |
|
| 35 |
# matches multiple characters |
| 36 |
new_ec_test_multiline(star_multiple_ML star.in abcde.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*") |
| 37 |
|
| 38 |
# does not match path separator |
| 39 |
new_ec_test(star_over_slash star.in a/e.c "^[ \t\n\r]*keyc=valuec[ \t\n\r]*$") |
| 40 |
|
| 41 |
# star after a slash |
| 42 |
new_ec_test_multiline(star_after_slash_ML star.in Bar/foo.txt "keyb=valueb[ \t\n\r]+keyc=valuec[ \t\n\r]*") |
| 43 |
|
| 44 |
# star matches a dot file after slash |
| 45 |
new_ec_test_multiline(star_matches_dot_file_after_slash_ML star.in Bar/.editorconfig "keyb=valueb[ \t\n\r]+keyc=valuec[ \t\n\r]*") |
| 46 |
|
| 47 |
# star matches a dot file |
| 48 |
new_ec_test(star_matches_dot_file star.in .editorconfig "^keyc=valuec[ \t\n\r]*$") |
| 49 |
|
| 50 |
# Slash makes the pattern not match in subdirectories |
| 51 |
new_ec_test_multiline(star_after_slash_ML_in_subdir star.in |
| 52 |
bat/Bar/foo.txt "^[ \t\n\r]*keyc=valuec[ \t\n\r]*$") |
| 53 |
|
| 54 |
# Slash makes the pattern not match dotfiles in subdirectories |
| 55 |
new_ec_test_multiline(star_matches_dot_file_after_slash_ML_in_subdir star.in |
| 56 |
bat/Bar/.editorconfig "^[ \t\n\r]*keyc=valuec[ \t\n\r]*$") |
| 57 |
|
| 58 |
# Tests for ? |
| 59 |
|
| 60 |
# matches a single character |
| 61 |
new_ec_test(question_single question.in some.c "^key=value[ \t\n\r]*$") |
| 62 |
|
| 63 |
# does not match zero characters |
| 64 |
new_ec_test(question_zero question.in som.c "^[ \t\n\r]*$") |
| 65 |
|
| 66 |
# does not match multiple characters |
| 67 |
new_ec_test(question_multiple question.in something.c "^[ \t\n\r]*$") |
| 68 |
|
| 69 |
# does not match slash |
| 70 |
new_ec_test(question_slash question.in som/.c "^[ \t\n\r]*$") |
| 71 |
|
| 72 |
# Tests for [ and ] |
| 73 |
|
| 74 |
# close bracket inside |
| 75 |
new_ec_test(brackets_close_inside brackets.in ].g "^close_inside=true[ \t\n\r]*$") |
| 76 |
|
| 77 |
# close bracket outside |
| 78 |
new_ec_test(brackets_close_outside brackets.in b].g "^close_outside=true[ \t\n\r]*$") |
| 79 |
|
| 80 |
# negative close bracket inside |
| 81 |
new_ec_test(brackets_nclose_inside brackets.in c.g "^close_inside=false[ \t\n\r]*$") |
| 82 |
|
| 83 |
# negative close bracket outside |
| 84 |
new_ec_test(brackets_nclose_outside brackets.in c].g "^close_outside=false[ \t\n\r]*$") |
| 85 |
|
| 86 |
# character choice |
| 87 |
new_ec_test(brackets_choice brackets.in a.a "^choice=true[ \t\n\r]*$") |
| 88 |
|
| 89 |
# character choice 2 |
| 90 |
new_ec_test(brackets_choice2 brackets.in c.a "^[ \t\n\r]*$") |
| 91 |
|
| 92 |
# negative character choice |
| 93 |
new_ec_test(brackets_nchoice brackets.in c.b "^choice=false[ \t\n\r]*$") |
| 94 |
|
| 95 |
# negative character choice 2 |
| 96 |
new_ec_test(brackets_nchoice2 brackets.in a.b "^[ \t\n\r]*$") |
| 97 |
|
| 98 |
# character range |
| 99 |
new_ec_test(brackets_range brackets.in f.c "^range=true[ \t\n\r]*$") |
| 100 |
|
| 101 |
# character range 2 |
| 102 |
new_ec_test(brackets_range2 brackets.in h.c "^[ \t\n\r]*$") |
| 103 |
|
| 104 |
# negative character range |
| 105 |
new_ec_test(brackets_nrange brackets.in h.d "^range=false[ \t\n\r]*$") |
| 106 |
|
| 107 |
# negative character range 2 |
| 108 |
new_ec_test(brackets_nrange2 brackets.in f.d "^[ \t\n\r]*$") |
| 109 |
|
| 110 |
# range and choice |
| 111 |
new_ec_test(brackets_range_and_choice brackets.in e.e |
| 112 |
"^range_and_choice=true[ \t\n\r]*$") |
| 113 |
|
| 114 |
# character choice with a dash |
| 115 |
new_ec_test(brackets_choice_with_dash brackets.in -.f |
| 116 |
"^choice_with_dash=true[ \t\n\r]*$") |
| 117 |
|
| 118 |
# slash inside brackets |
| 119 |
new_ec_test(brackets_slash_inside1 brackets.in ab/cd.i |
| 120 |
"^[ \t\n\r]*$") |
| 121 |
new_ec_test(brackets_slash_inside2 brackets.in abecd.i |
| 122 |
"^[ \t\n\r]*$") |
| 123 |
new_ec_test(brackets_slash_inside3 brackets.in ab[e/]cd.i |
| 124 |
"^slash_inside=true[ \t\n\r]*$") |
| 125 |
new_ec_test(brackets_slash_inside4 brackets.in ab[/c |
| 126 |
"^slash_half_open=true[ \t\n\r]*$") |
| 127 |
|
| 128 |
# Tests for { and } |
| 129 |
|
| 130 |
# word choice |
| 131 |
new_ec_test(braces_word_choice1 braces.in test.py "^choice=true[ \t\n\r]*$") |
| 132 |
new_ec_test(braces_word_choice2 braces.in test.js "^choice=true[ \t\n\r]*$") |
| 133 |
new_ec_test(braces_word_choice3 braces.in test.html "^choice=true[ \t\n\r]*$") |
| 134 |
new_ec_test(braces_word_choice4 braces.in test.pyc "^[ \t\n\r]*$") |
| 135 |
|
| 136 |
# single choice |
| 137 |
new_ec_test(braces_single_choice braces.in {single}.b "^choice=single[ \t\n\r]*$") |
| 138 |
new_ec_test(braces_single_choice_negative braces.in .b "^[ \t\n\r]*$") |
| 139 |
|
| 140 |
# empty choice |
| 141 |
new_ec_test(braces_empty_choice braces.in {}.c "^empty=all[ \t\n\r]*$") |
| 142 |
new_ec_test(braces_empty_choice_negative braces.in .c "^[ \t\n\r]*$") |
| 143 |
|
| 144 |
# choice with empty word |
| 145 |
new_ec_test(braces_empty_word1 braces.in a.d "^empty=word[ \t\n\r]*$") |
| 146 |
new_ec_test(braces_empty_word2 braces.in ab.d "^empty=word[ \t\n\r]*$") |
| 147 |
new_ec_test(braces_empty_word3 braces.in ac.d "^empty=word[ \t\n\r]*$") |
| 148 |
new_ec_test(braces_empty_word4 braces.in a,.d "^[ \t\n\r]*$") |
| 149 |
|
| 150 |
# choice with empty words |
| 151 |
new_ec_test(braces_empty_words1 braces.in a.e "^empty=words[ \t\n\r]*$") |
| 152 |
new_ec_test(braces_empty_words2 braces.in ab.e "^empty=words[ \t\n\r]*$") |
| 153 |
new_ec_test(braces_empty_words3 braces.in ac.e "^empty=words[ \t\n\r]*$") |
| 154 |
new_ec_test(braces_empty_words4 braces.in a,.e "^[ \t\n\r]*$") |
| 155 |
|
| 156 |
# no closing brace |
| 157 |
new_ec_test(braces_no_closing braces.in {.f "^closing=false[ \t\n\r]*$") |
| 158 |
new_ec_test(braces_no_closing_negative braces.in .f "^[ \t\n\r]*$") |
| 159 |
|
| 160 |
# nested braces |
| 161 |
new_ec_test(braces_nested1 braces.in word,this}.g "^[ \t\n\r]*$") |
| 162 |
new_ec_test(braces_nested2 braces.in {also,this}.g "^[ \t\n\r]*$") |
| 163 |
new_ec_test(braces_nested3 braces.in word.g "^nested=true[ \t\n\r]*$") |
| 164 |
new_ec_test(braces_nested4 braces.in {also}.g "^nested=true[ \t\n\r]*$") |
| 165 |
new_ec_test(braces_nested5 braces.in this.g "^nested=true[ \t\n\r]*$") |
| 166 |
|
| 167 |
# nested braces, adjacent at start |
| 168 |
new_ec_test(braces_nested_start1 braces.in {{a,b},c}.k "^[ \t\n\r]*$") |
| 169 |
new_ec_test(braces_nested_start2 braces.in {a,b}.k "^[ \t\n\r]*$") |
| 170 |
new_ec_test(braces_nested_start3 braces.in a.k "^nested_start=true[ \t\n\r]*$") |
| 171 |
new_ec_test(braces_nested_start4 braces.in b.k "^nested_start=true[ \t\n\r]*$") |
| 172 |
new_ec_test(braces_nested_start5 braces.in c.k "^nested_start=true[ \t\n\r]*$") |
| 173 |
|
| 174 |
# nested braces, adjacent at end |
| 175 |
new_ec_test(braces_nested_end1 braces.in {a,{b,c}}.l "^[ \t\n\r]*$") |
| 176 |
new_ec_test(braces_nested_end2 braces.in {b,c}.l "^[ \t\n\r]*$") |
| 177 |
new_ec_test(braces_nested_end3 braces.in a.l "^nested_end=true[ \t\n\r]*$") |
| 178 |
new_ec_test(braces_nested_end4 braces.in b.l "^nested_end=true[ \t\n\r]*$") |
| 179 |
new_ec_test(braces_nested_end5 braces.in c.l "^nested_end=true[ \t\n\r]*$") |
| 180 |
|
| 181 |
# closing inside beginning |
| 182 |
new_ec_test(braces_closing_in_beginning braces.in {},b}.h "^closing=inside[ \t\n\r]*$") |
| 183 |
|
| 184 |
# missing closing braces |
| 185 |
new_ec_test(braces_unmatched1 braces.in {{,b,c{d}.i "^unmatched=true[ \t\n\r]*$") |
| 186 |
new_ec_test(braces_unmatched2 braces.in {.i "^[ \t\n\r]*$") |
| 187 |
new_ec_test(braces_unmatched3 braces.in b.i "^[ \t\n\r]*$") |
| 188 |
new_ec_test(braces_unmatched4 braces.in c{d.i "^[ \t\n\r]*$") |
| 189 |
new_ec_test(braces_unmatched5 braces.in .i "^[ \t\n\r]*$") |
| 190 |
|
| 191 |
# escaped comma |
| 192 |
new_ec_test(braces_escaped_comma1 braces.in a,b.txt "^comma=yes[ \t\n\r]*$") |
| 193 |
new_ec_test(braces_escaped_comma2 braces.in a.txt "^[ \t\n\r]*$") |
| 194 |
new_ec_test(braces_escaped_comma3 braces.in cd.txt "^comma=yes[ \t\n\r]*$") |
| 195 |
|
| 196 |
# escaped closing brace |
| 197 |
new_ec_test(braces_escaped_brace1 braces.in e.txt "^closing=yes[ \t\n\r]*$") |
| 198 |
new_ec_test(braces_escaped_brace2 braces.in }.txt "^closing=yes[ \t\n\r]*$") |
| 199 |
new_ec_test(braces_escaped_brace3 braces.in f.txt "^closing=yes[ \t\n\r]*$") |
| 200 |
|
| 201 |
# escaped backslash |
| 202 |
new_ec_test(braces_escaped_backslash1 braces.in g.txt "^backslash=yes[ \t\n\r]*$") |
| 203 |
if((NOT WIN32) AND (NOT CYGWIN)) # this case is impossible on Windows. |
| 204 |
new_ec_test(braces_escaped_backslash2 braces.in "\\.txt" "^backslash=yes[ \t\n\r]*$") |
| 205 |
endif() |
| 206 |
new_ec_test(braces_escaped_backslash3 braces.in i.txt "^backslash=yes[ \t\n\r]*$") |
| 207 |
|
| 208 |
# patterns nested in braces |
| 209 |
new_ec_test(braces_patterns_nested1 braces.in some.j "^patterns=nested[ \t\n\r]*$") |
| 210 |
new_ec_test(braces_patterns_nested2 braces.in abe.j "^patterns=nested[ \t\n\r]*$") |
| 211 |
new_ec_test(braces_patterns_nested3 braces.in abf.j "^patterns=nested[ \t\n\r]*$") |
| 212 |
new_ec_test(braces_patterns_nested4 braces.in abg.j "^[ \t\n\r]*$") |
| 213 |
new_ec_test(braces_patterns_nested5 braces.in ace.j "^patterns=nested[ \t\n\r]*$") |
| 214 |
new_ec_test(braces_patterns_nested6 braces.in acf.j "^patterns=nested[ \t\n\r]*$") |
| 215 |
new_ec_test(braces_patterns_nested7 braces.in acg.j "^[ \t\n\r]*$") |
| 216 |
new_ec_test(braces_patterns_nested8 braces.in abce.j "^patterns=nested[ \t\n\r]*$") |
| 217 |
new_ec_test(braces_patterns_nested9 braces.in abcf.j "^patterns=nested[ \t\n\r]*$") |
| 218 |
new_ec_test(braces_patterns_nested10 braces.in abcg.j "^[ \t\n\r]*$") |
| 219 |
new_ec_test(braces_patterns_nested11 braces.in ae.j "^[ \t\n\r]*$") |
| 220 |
new_ec_test(braces_patterns_nested12 braces.in .j "^[ \t\n\r]*$") |
| 221 |
|
| 222 |
# numeric brace range |
| 223 |
new_ec_test(braces_numeric_range1 braces.in 1 "^[ \t\n\r]*$") |
| 224 |
new_ec_test(braces_numeric_range2 braces.in 3 "^number=true[ \t\n\r]*$") |
| 225 |
new_ec_test(braces_numeric_range3 braces.in 15 "^number=true[ \t\n\r]*$") |
| 226 |
new_ec_test(braces_numeric_range4 braces.in 60 "^number=true[ \t\n\r]*$") |
| 227 |
new_ec_test(braces_numeric_range5 braces.in 5a "^[ \t\n\r]*$") |
| 228 |
new_ec_test(braces_numeric_range6 braces.in 120 "^number=true[ \t\n\r]*$") |
| 229 |
new_ec_test(braces_numeric_range7 braces.in 121 "^[ \t\n\r]*$") |
| 230 |
new_ec_test(braces_numeric_range8 braces.in 060 "^[ \t\n\r]*$") |
| 231 |
|
| 232 |
# alphabetical brace range: letters should not be considered for ranges |
| 233 |
new_ec_test(braces_alpha_range1 braces.in {aardvark..antelope} "^words=a[ \t\n\r]*$") |
| 234 |
new_ec_test(braces_alpha_range2 braces.in a "^[ \t\n\r]*$") |
| 235 |
new_ec_test(braces_alpha_range3 braces.in aardvark "^[ \t\n\r]*$") |
| 236 |
new_ec_test(braces_alpha_range4 braces.in agreement "^[ \t\n\r]*$") |
| 237 |
new_ec_test(braces_alpha_range5 braces.in antelope "^[ \t\n\r]*$") |
| 238 |
new_ec_test(braces_alpha_range6 braces.in antimatter "^[ \t\n\r]*$") |
| 239 |
|
| 240 |
|
| 241 |
# Tests for ** |
| 242 |
|
| 243 |
# test EditorConfig files with UTF-8 characters larger than 127 |
| 244 |
new_ec_test(utf_8_char utf8char.in "中文.txt" "^key=value[ \t\n\r]*$") |
| 245 |
|
| 246 |
# matches over path separator |
| 247 |
new_ec_test(star_star_over_separator1 star_star.in a/z.c "^key1=value1[ \t\n\r]*$") |
| 248 |
new_ec_test(star_star_over_separator2 star_star.in amnz.c "^key1=value1[ \t\n\r]*$") |
| 249 |
new_ec_test(star_star_over_separator3 star_star.in am/nz.c "^key1=value1[ \t\n\r]*$") |
| 250 |
new_ec_test(star_star_over_separator4 star_star.in a/mnz.c "^key1=value1[ \t\n\r]*$") |
| 251 |
new_ec_test(star_star_over_separator5 star_star.in amn/z.c "^key1=value1[ \t\n\r]*$") |
| 252 |
new_ec_test(star_star_over_separator6 star_star.in a/mn/z.c "^key1=value1[ \t\n\r]*$") |
| 253 |
|
| 254 |
new_ec_test(star_star_over_separator7 star_star.in b/z.c "^key2=value2[ \t\n\r]*$") |
| 255 |
new_ec_test(star_star_over_separator8 star_star.in b/mnz.c "^key2=value2[ \t\n\r]*$") |
| 256 |
new_ec_test(star_star_over_separator9 star_star.in b/mn/z.c "^key2=value2[ \t\n\r]*$") |
| 257 |
new_ec_test(star_star_over_separator10 star_star.in bmnz.c "^[ \t\n\r]*$") |
| 258 |
new_ec_test(star_star_over_separator11 star_star.in bm/nz.c "^[ \t\n\r]*$") |
| 259 |
new_ec_test(star_star_over_separator12 star_star.in bmn/z.c "^[ \t\n\r]*$") |
| 260 |
|
| 261 |
new_ec_test(star_star_over_separator13 star_star.in c/z.c "^key3=value3[ \t\n\r]*$") |
| 262 |
new_ec_test(star_star_over_separator14 star_star.in cmn/z.c "^key3=value3[ \t\n\r]*$") |
| 263 |
new_ec_test(star_star_over_separator15 star_star.in c/mn/z.c "^key3=value3[ \t\n\r]*$") |
| 264 |
new_ec_test(star_star_over_separator16 star_star.in cmnz.c "^[ \t\n\r]*$") |
| 265 |
new_ec_test(star_star_over_separator17 star_star.in cm/nz.c "^[ \t\n\r]*$") |
| 266 |
new_ec_test(star_star_over_separator18 star_star.in c/mnz.c "^[ \t\n\r]*$") |
| 267 |
|
| 268 |
new_ec_test(star_star_over_separator19 star_star.in d/z.c "^key4=value4[ \t\n\r]*$") |
| 269 |
new_ec_test(star_star_over_separator20 star_star.in d/mn/z.c "^key4=value4[ \t\n\r]*$") |
| 270 |
new_ec_test(star_star_over_separator21 star_star.in dmnz.c "^[ \t\n\r]*$") |
| 271 |
new_ec_test(star_star_over_separator22 star_star.in dm/nz.c "^[ \t\n\r]*$") |
| 272 |
new_ec_test(star_star_over_separator23 star_star.in d/mnz.c "^[ \t\n\r]*$") |
| 273 |
new_ec_test(star_star_over_separator24 star_star.in dmn/z.c "^[ \t\n\r]*$") |