git @ Cat's Eye Technologies Falderal / 3741d3b
Recognize new-style assertions. All tests pass once again. Chris Pressey 6 years ago
2 changed file(s) with 17 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
295295 line_num=self.line_num, filename=self.filename, lines=lines
296296 )
297297
298 def reconstruct(pattern, except_prefixes):
298 def reconstruct(pattern, default_prefix, prefix_map):
299299 new_pattern = []
300300 lines = []
301301 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))
304304 else:
305305 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]
307316
308317 if '' in pattern_prefixes:
309318 # 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
318322
319323 if pattern_prefixes in [[u'= '], [u'? ']]:
320324 raise FalderalSyntaxError(
11
22 Demonstrate error expectation (Intentional fail.)
33
4 Location: test-pass-fail.markdown, line 55
4 Location: test-new-format.markdown, line 55
55 Function: Cat
66 Impl : shell command "python cat.py"
77 Body : meow