def test_composite_state_body_2(): print('composite_state_body 2:') test = parser_init(string='''state ENTRYA; endstate; ''') test.composite_state_body()
def test_composite_state_body_2(): print('composite_state_body 2:') test=parser_init(string= '''state ENTRYA; endstate; ''') test.composite_state_body()
def test_2(): ''' Test the parsing of numbers ''' test = parser_init(string='''provided true priority 5;''') with samnmax.capture_output() as (stdout, stderr): test.continuous_signal() errCount = 0 for each in stderr: print('[ERROR] ' + str(each)) errCount += 1 assert not errCount
def test_composite_state_2(): print('composite_state (should have no error)') test = parser_init(string='''state CHECKING; substructure state ENTRYA; endstate ENTRYA; endsubstructure CHECKING; ''') test.composite_state()
def test_composite_state_2(): print('composite_state (should have no error)') test=parser_init(string= '''state CHECKING; substructure state ENTRYA; endstate ENTRYA; endsubstructure CHECKING; ''') test.composite_state()
def test_composite_state_1(): ''' Detect the syntax error (missing SEMI after "procedure entry") ''' test = parser_init(string='''state CHECKING; substructure state ENTRYA; substructure procedure entry EXTERNAL; endsubstructure ENTRYA; endsubstructure CHECKING; ''') test.composite_state()
def test_composite_state_1(): ''' Detect the syntax error (missing SEMI after "procedure entry") ''' test = parser_init(string= '''state CHECKING; substructure state ENTRYA; substructure procedure entry EXTERNAL; endsubstructure ENTRYA; endsubstructure CHECKING; ''') test.composite_state()
def test_composite_state_3(): print('from rm - reports that start must be before state:') test = parser_init(string=''' STATE AGGREGATION DemoDeviceDACPStates; SUBSTRUCTURE STATE INTERNAL_MAPPINGS; SUBSTRUCTURE STATE STATELESS; ENDSTATE STATELESS; START; NEXTSTATE STATELESS; ENDSUBSTRUCTURE INTERNAL_MAPPINGS; ENDSUBSTRUCTURE DemoDeviceDACPStates; ''') test.composite_state()
def test_composite_state_3(): print('from rm - reports that start must be before state:') test=parser_init(string= ''' STATE AGGREGATION DemoDeviceDACPStates; SUBSTRUCTURE STATE INTERNAL_MAPPINGS; SUBSTRUCTURE STATE STATELESS; ENDSTATE STATELESS; START; NEXTSTATE STATELESS; ENDSUBSTRUCTURE INTERNAL_MAPPINGS; ENDSUBSTRUCTURE DemoDeviceDACPStates; ''') test.composite_state()
def test_composite_state_body_1(): ''' Detect the syntax error (missing SEMI after "procedure entry") ''' test = parser_init(string='''state ENTRYA; substructure procedure entry external; endsubstructure ENTRYA;''') # Parse and then check that the reported error is the expected one res = test.composite_state_body() assert (not isinstance(res.tree, antlr3.tree.CommonErrorNode)) composite = res.tree.children[0] compo_type = token(composite.type) assert (compo_type == 'COMPOSITE_STATE') for each in composite.children: if isinstance(each, antlr3.tree.CommonErrorNode): exception = each.trappedException assert (isinstance(exception, antlr3.NoViableAltException)) assert (token(exception.unexpectedType) == 'EXTERNAL')
def test_composite_state_4(): print('from rm(2) - reports that start must be before state:') test = parser_init(string=''' process hello; STATE AGGREGATION DemoDeviceDACPStates; SUBSTRUCTURE STATE INTERNAL_MAPPINGS; SUBSTRUCTURE STATE STATELESS; ENDSTATE STATELESS; START; NEXTSTATE STATELESS; ENDSUBSTRUCTURE INTERNAL_MAPPINGS; ENDSUBSTRUCTURE DemoDeviceDACPStates; end hello; ''') test.process_definition()
def test_composite_state_4(): print('from rm(2) - reports that start must be before state:') test=parser_init(string= ''' process hello; STATE AGGREGATION DemoDeviceDACPStates; SUBSTRUCTURE STATE INTERNAL_MAPPINGS; SUBSTRUCTURE STATE STATELESS; ENDSTATE STATELESS; START; NEXTSTATE STATELESS; ENDSUBSTRUCTURE INTERNAL_MAPPINGS; ENDSUBSTRUCTURE DemoDeviceDACPStates; end hello; ''') test.process_definition()
def test_composite_state_body_1(): ''' Detect the syntax error (missing SEMI after "procedure entry") ''' test = parser_init(string= '''state ENTRYA; substructure procedure entry external; endsubstructure ENTRYA;''') # Parse and then check that the reported error is the expected one res = test.composite_state_body() assert(not isinstance(res.tree, antlr3.tree.CommonErrorNode)) composite = res.tree.children[0] compo_type = sdl92Parser.tokenNames[composite.type] assert(compo_type == 'COMPOSITE_STATE') for each in composite.children: if isinstance(each, antlr3.tree.CommonErrorNode): exception = each.trappedException assert(isinstance(exception,antlr3.NoViableAltException)) assert(token(exception.unexpectedType) == 'EXTERNAL')
def test_1(): ''' Test the parsing of numbers ''' test = parser_init(string='''provided true=false; priority 5;''') res = test.continuous_signal() assert (not isinstance(res.tree, antlr3.tree.CommonErrorNode))
def test_1(): ''' Test the parsing of numbers ''' test = parser_init(string='''provided true=false; priority 5;''') res = test.continuous_signal() assert(not isinstance(res.tree, antlr3.tree.CommonErrorNode))
def test_minus(): ''' Test the parsing of numbers ''' test = parser_init(string='''1-1''') test.expression()