Recognize new-style assertions. All tests pass once again.
Chris Pressey
7 years ago
295 | 295 | line_num=self.line_num, filename=self.filename, lines=lines |
296 | 296 | ) |
297 | 297 | |
298 | def reconstruct(pattern, except_prefixes): | |
298 | def reconstruct(pattern, default_prefix, prefix_map): | |
299 | 299 | new_pattern = [] |
300 | 300 | lines = [] |
301 | 301 | for (candidate_prefix, candidate_lines) in pattern: |
302 | if candidate_prefix in except_prefixes: | |
303 | new_pattern.append((candidate_prefix, candidate_lines)) | |
302 | if candidate_prefix in prefix_map: | |
303 | new_pattern.append((prefix_map[candidate_prefix], candidate_lines)) | |
304 | 304 | else: |
305 | 305 | lines.extend([candidate_prefix + line for line in candidate_lines]) |
306 | return [(u'', lines)] + new_pattern | |
306 | return [(default_prefix, lines)] + new_pattern | |
307 | ||
308 | # This block ends with a new-style expectation. | |
309 | # We interpret this according to the new, not-yet-written rules. | |
310 | if pattern_prefixes[-1] in [u'==> ', u'??> ']: | |
311 | pattern = reconstruct(pattern, u'| ', { | |
312 | u'==> ': u'= ', | |
313 | u'??> ': u'? ', | |
314 | }) | |
315 | pattern_prefixes = [p[0] for p in pattern] | |
307 | 316 | |
308 | 317 | if '' in pattern_prefixes: |
309 | 318 | # There is plain, non-prefixed text embedded somewhere in this Block. |
310 | # We interpret this according to the new, not-yet-written rules. | |
311 | if pattern_prefixes[-1] in [[u'==> ', u'??> ']]: | |
312 | pattern = reconstruct(pattern, [u'==> ', u'??> ']) | |
313 | pattern_prefixes = [p[0] for p in pattern] | |
314 | else: | |
315 | # TODO:issue a warning unless cavalier | |
316 | # For now, assume it is Just Indented Text And That Is OK. | |
317 | return None | |
319 | # TODO:issue a warning unless cavalier | |
320 | # For now, assume it is Just Indented Text And That Is OK. | |
321 | return None | |
318 | 322 | |
319 | 323 | if pattern_prefixes in [[u'= '], [u'? ']]: |
320 | 324 | raise FalderalSyntaxError( |