157 yield report_problem( |
157 yield report_problem( |
158 'moved-to-with-extension', |
158 'moved-to-with-extension', |
159 bad_object = model.body[0], |
159 bad_object = model.body[0], |
160 ) |
160 ) |
161 |
161 |
|
162 @problem_type('bfc-invertnext-not-on-subfile', |
|
163 severity = 'hold', |
|
164 message = '"BFC INVERTNEXT" not followed by a type-1 line', |
|
165 ) |
|
166 def bfc_invertnext_not_on_subfile_test(model): |
|
167 def get_invertnexts(model): |
|
168 yield from [ |
|
169 (index, element) |
|
170 for index, element in enumerate(model.body) |
|
171 if isinstance(element, linetypes.MetaCommand) \ |
|
172 and element.text == 'BFC INVERTNEXT' |
|
173 ] |
|
174 def has_subfile_after_invertnext(index): |
|
175 index_subfile = index + 1 # subfile reference should be on the next line |
|
176 if index_subfile >= len(model.body): |
|
177 return False # past the end... |
|
178 else: |
|
179 element = model.body[index_subfile] |
|
180 return isinstance(element, linetypes.SubfileReference) |
|
181 for index, invertnext in get_invertnexts(model): |
|
182 if not has_subfile_after_invertnext(index): |
|
183 yield report_problem('bfc-invertnext-not-on-subfile', |
|
184 bad_object = model.body[index], |
|
185 ) |
|
186 |
162 manifest = { |
187 manifest = { |
163 'tests': [ |
188 'tests': [ |
164 colours_test, |
189 colours_test, |
165 syntax_errors, |
190 syntax_errors, |
166 bad_header, |
191 bad_header, |