Sun, 23 Jun 2019 00:50:22 +0300
added a test for BFC INVERTNEXT not followed by a type-1 line
tests/misc.py | file | annotate | diff | comparison | revisions |
--- a/tests/misc.py Sun Jun 23 00:42:34 2019 +0300 +++ b/tests/misc.py Sun Jun 23 00:50:22 2019 +0300 @@ -159,6 +159,31 @@ bad_object = model.body[0], ) +@problem_type('bfc-invertnext-not-on-subfile', + severity = 'hold', + message = '"BFC INVERTNEXT" not followed by a type-1 line', +) +def bfc_invertnext_not_on_subfile_test(model): + def get_invertnexts(model): + yield from [ + (index, element) + for index, element in enumerate(model.body) + if isinstance(element, linetypes.MetaCommand) \ + and element.text == 'BFC INVERTNEXT' + ] + def has_subfile_after_invertnext(index): + index_subfile = index + 1 # subfile reference should be on the next line + if index_subfile >= len(model.body): + return False # past the end... + else: + element = model.body[index_subfile] + return isinstance(element, linetypes.SubfileReference) + for index, invertnext in get_invertnexts(model): + if not has_subfile_after_invertnext(index): + yield report_problem('bfc-invertnext-not-on-subfile', + bad_object = model.body[index], + ) + manifest = { 'tests': [ colours_test, @@ -171,5 +196,6 @@ keywords_tests, colour_24_test, moved_to_with_extension_test, + bfc_invertnext_not_on_subfile_test, ], }