tests/misc.py

changeset 78
1970afe52da4
parent 75
3ec747dfbfb9
child 86
b25fc6f7eb70
equal deleted inserted replaced
77:d98502ae1f33 78:1970afe52da4
182 if not has_subfile_after_invertnext(index): 182 if not has_subfile_after_invertnext(index):
183 yield report_problem('bfc-invertnext-not-on-subfile', 183 yield report_problem('bfc-invertnext-not-on-subfile',
184 bad_object = model.body[index], 184 bad_object = model.body[index],
185 ) 185 )
186 186
187 @problem_type('unknown-metacommand',
188 severity = 'hold',
189 message = lambda command_text: str.format(
190 'unknown or deprecated metacommand: {command_text}',
191 command_text = command_text,
192 )
193 )
194 def metacommands_test(model):
195 allowed_metacommand_patterns = [
196 r'^BFC (CLIP|NOCLIP|INVERTNEXT)$',
197 r'^\!TEXMAP (START|NEXT) .+',
198 r'^\!: .+',
199 r'^\!TEXMAP (FALLBACK|END)$',
200 ]
201 import re
202 for element in model.body[model.header_size:]:
203 if isinstance(element, linetypes.MetaCommand):
204 if element.text and not any(
205 re.match(pattern, element.text)
206 for pattern in allowed_metacommand_patterns
207 ):
208 yield report_problem('unknown-metacommand',
209 bad_object = element,
210 command_text = element.text,
211 )
212
187 manifest = { 213 manifest = {
188 'tests': [ 214 'tests': [
189 colours_test, 215 colours_test,
190 syntax_errors, 216 syntax_errors,
191 bad_header, 217 bad_header,
195 header_bfc_test, 221 header_bfc_test,
196 keywords_tests, 222 keywords_tests,
197 colour_24_test, 223 colour_24_test,
198 moved_to_with_extension_test, 224 moved_to_with_extension_test,
199 bfc_invertnext_not_on_subfile_test, 225 bfc_invertnext_not_on_subfile_test,
226 metacommands_test,
200 ], 227 ],
201 } 228 }

mercurial