Commit de0560f0 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib][tests] Expression compiler: Add test for entities starting with keywords...

[lib][tests] Expression compiler: Add test for entities starting with keywords from the biosignal language;
This test will NOT pass in ANTLR3; #2
parent e1244abd
......@@ -119,6 +119,12 @@ class TestExpressionAnalyzer(unittest.TestCase):
self.tab['S2'] = "state", 1
self.tab['S3'] = "state", 1
# identities starting with keywords from the biosignal language
self.tab['orxxx'] = "state", 1
self.tab['andxxx'] = "state", 1
self.tab['notxxx'] = "state", 1
self.tab['conxxx'] = "state", 1
self.err_rep = Reporter()
def tearDown(self):
......@@ -358,3 +364,24 @@ class TestExpressionAnalyzer(unittest.TestCase):
# These types are tested when state_only is True
print(self.err_rep.message)
self.assert_(self.err_rep.error, "reporter HAS NOT captured an error")
def test_special_names(self):
"""Test names of identities starting with keywords from the biosignal
language (and, or, not, constraint).
No parsing errors should occur
"""
reader = ANTLRStringStream("S3 when (orxxx or conxxx and andxxx and notxxx) $")
lexer = sigexpr_lexer(reader)
parser = sigexpr_compiler(CommonTokenStream(lexer))
parser.set_error_reporter(self.err_rep)
#parser.state_only = True
try:
exp_obj = parser.sig_expression(self.tab)
except RecognitionException as exc:
parser.displayExceptionMessage(exc)
self.assert_(False, "Compiler error for when")
# False if no error (display() method is never called)
# Here, res is False because no error should be raised during the parsing
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
Markdown is supported
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