Esempio n. 1
0
def test_set_role_recursive_1(): #IGNORE:C01111
    #skip_test('Test set_role_recursive')
    print 'Test set_role_recursive'
    from freeode.interpreter import (InterpreterObject, set_role_recursive)
    from freeode.ast import (RoleConstant, RoleParameter, RoleVariable, 
                             RoleUnkown)
    
    #create a little tree of objects
    c1 = InterpreterObject()
    c1.__siml_role__ = RoleConstant
    p1 = InterpreterObject()
    p1.__siml_role__ = RoleParameter
    v1 = InterpreterObject()
    v1.__siml_role__ = RoleVariable
    u1 = InterpreterObject()
    u1.__siml_role__ = RoleUnkown
    root = InterpreterObject()
    root.__siml_role__ = RoleVariable
    root.c1 = c1 
    root.p1 = p1 
    root.v1 = v1 
    root.u1 = u1 
    #set the roles in the whole tree
    ########## This line varies ############
    set_role_recursive(root, RoleVariable) 
    #test the new roles
    assert root.__siml_role__ == RoleVariable
    assert c1.__siml_role__ == RoleConstant
    assert p1.__siml_role__ == RoleParameter
    assert v1.__siml_role__ == RoleVariable
    assert u1.__siml_role__ == RoleVariable
    
    #create a little tree of objects
    c1 = InterpreterObject()
    c1.__siml_role__ = RoleConstant
    p1 = InterpreterObject()
    p1.__siml_role__ = RoleParameter
    v1 = InterpreterObject()
    v1.__siml_role__ = RoleVariable
    u1 = InterpreterObject()
    u1.__siml_role__ = RoleUnkown
    root = InterpreterObject()
    root.__siml_role__ = RoleVariable
    root.c1 = c1 
    root.p1 = p1 
    root.v1 = v1 
    root.u1 = u1 
    #set the roles in the whole tree
    ########## This line varies ############
    set_role_recursive(root, RoleParameter) 
    #test the new roles
    assert root.__siml_role__ == RoleParameter
    assert c1.__siml_role__ == RoleConstant
    assert p1.__siml_role__ == RoleParameter
    assert v1.__siml_role__ == RoleParameter
    assert u1.__siml_role__ == RoleParameter
    
    #create a little tree of objects
    c1 = InterpreterObject()
    c1.__siml_role__ = RoleConstant
    p1 = InterpreterObject()
    p1.__siml_role__ = RoleParameter
    v1 = InterpreterObject()
    v1.__siml_role__ = RoleVariable
    u1 = InterpreterObject()
    u1.__siml_role__ = RoleUnkown
    root = InterpreterObject()
    root.__siml_role__ = RoleVariable
    root.c1 = c1 
    root.p1 = p1 
    root.v1 = v1 
    root.u1 = u1 
    #set the roles in the whole tree
    ########## This line varies ############
    set_role_recursive(root, RoleConstant) 
    #test the new roles
    assert root.__siml_role__ == RoleConstant
    assert c1.__siml_role__ == RoleConstant
    assert p1.__siml_role__ == RoleConstant
    assert v1.__siml_role__ == RoleConstant
    assert u1.__siml_role__ == RoleConstant