Commit 1eb02871 authored by di68kap's avatar di68kap
Browse files

- Fail tests of unknown parsers are now reported as failure!

parent e43fc882
......@@ -389,6 +389,8 @@ def grammar_unit(test_unit, parser_factory, transformer_factory, report=True, ve
except UnknownParserError as upe:
node = Node(ZOMBIE_PARSER, "").init_pos(0)
cst = RootNode(node).new_error(node, str(upe))
errata.append('Unknown parser {} in fail test {}!'.format(parser_name, test_name))
tests.setdefault('__err__', {})[test_name] = errata[-1]
if not is_error(cst.error_flag):
errata.append('Fail test "%s" for parser "%s" yields match instead of '
'expected failure!' % (test_name, parser_name))
......
......@@ -214,7 +214,7 @@ class TestGrammarTest:
trans_fac = lambda : ARITHMETIC_EBNFTransform
# reset_unit(self.cases)
errata = grammar_unit(self.cases, parser_fac, trans_fac)
assert not errata, str(errata)
assert errata, "Unknown parser, but no error message!?"
report = get_report(self.cases)
assert report.find('### CST') >= 0
errata = grammar_unit(self.failure_cases, parser_fac, trans_fac)
......@@ -231,6 +231,17 @@ class TestGrammarTest:
# report = get_report(self.cases)
# assert report.find('### CST') >= 0
def test_fail_failtest(self):
"""Failure test should not pass if it failed because the parser is unknown."""
fcases = {}
fcases['berm'] = {}
fcases['berm']['fail'] = self.failure_cases['term']['fail']
errata = grammar_unit(fcases,
grammar_provider(ARITHMETIC_EBNF),
lambda : ARITHMETIC_EBNFTransform)
assert errata
class TestSExpr:
"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment