Ejemplo n.º 1
0
def test_composite_state_body_2():
    print('composite_state_body 2:')

    test = parser_init(string='''state ENTRYA;
              endstate;
    ''')

    test.composite_state_body()
Ejemplo n.º 2
0
def test_composite_state_body_2():
    print('composite_state_body 2:')

    test=parser_init(string=
    '''state ENTRYA;
              endstate;
    ''')

    test.composite_state_body()
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
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()
Ejemplo n.º 7
0
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()
Ejemplo n.º 8
0
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()
Ejemplo n.º 9
0
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()
Ejemplo n.º 10
0
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()
Ejemplo n.º 11
0
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')
Ejemplo n.º 12
0
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()
Ejemplo n.º 13
0
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()
Ejemplo n.º 14
0
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')
Ejemplo n.º 15
0
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))
Ejemplo n.º 16
0
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))
Ejemplo n.º 17
0
def test_minus():
    ''' Test the parsing of numbers '''
    test = parser_init(string='''1-1''')
    test.expression()