Example #1
0
def test_composite_state_body_2():
    print('composite_state_body 2:')

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

    test.composite_state_body()
Example #2
0
def test_composite_state_body_2():
    print('composite_state_body 2:')

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

    test.composite_state_body()
Example #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
Example #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
Example #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()
Example #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()
Example #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()
Example #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()
Example #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()
Example #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()
Example #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')
Example #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()
Example #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()
Example #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')
Example #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))
Example #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))
Example #17
0
def test_minus():
    ''' Test the parsing of numbers '''
    test = parser_init(string='''1-1''')
    test.expression()