예제 #1
0
def test_determine_result_role_1(): #IGNORE:C01111
    msg = 'Test determine_result_role: '
    #skip_test(msg)
    print msg
    
    from freeode.interpreter import IFloat, determine_result_role
    from freeode.ast import RoleConstant, RoleParameter, RoleVariable
    
    #some constants
    c_1 = IFloat()
    c_1.__siml_role__ = RoleConstant
    c_2 = IFloat()
    c_2.__siml_role__ = RoleConstant
    #some parameters
    p_1 = IFloat()
    p_1.__siml_role__ = RoleParameter
    p_2 = IFloat()
    p_2.__siml_role__ = RoleParameter
    #some variables
    v_1 = IFloat()
    v_1.__siml_role__ = RoleVariable
    v_2 = IFloat()
    v_2.__siml_role__ = RoleVariable
    
    #determine the most variable role among the arguments
    assert issubclass(determine_result_role((c_1, p_1, v_1), 
                                            {'a':c_2, 'b':p_2, 'c':v_2, }),  
                      RoleVariable)
    assert determine_result_role((c_1, p_1), 
                                 {'a':c_2, 'b':p_2}) == RoleParameter
    assert determine_result_role((c_1,), 
                                 {'a':c_2}) == RoleConstant
예제 #2
0
 def raise_3(): 
     determine_result_role((c_1, u), {'a':c_2})
예제 #3
0
 def raise_2(): 
     determine_result_role((c_1, p_1), {'a':c_2, 'b':p_2, 'u':u})
예제 #4
0
 def raise_1(): 
     determine_result_role((c_1, p_1, v_1, u), 
                           {'a':c_2, 'b':p_2, 'c':v_2, })