def test_function_objects(): print("test_function_objects") val = 2 o = MyClass(val) li = [1] dic = {'key1': 'value1', 'key2': 'value2'} tup = ('a', 'b', 4) cplx = complex('1+2j') function_objects(o, li, dic, tup, cplx, par_func) function_objects(o, li, dic, tup, cplx, par_func) errors = False o = compss_wait_on(o) if o.field != 8: print("- INOUT (objects): ERROR") errors = True li = compss_wait_on(li) if li != [1, 2, 2]: print("- INOUT (list): ERROR") errors = True dic = compss_wait_on(dic) if dic != { 'key1': 'value1', 'key2': 'value2', 'key3': 'value3', 'key4': 'value4' }: print("- INOUT (dictionary): ERROR") errors = True # Tuples are inmutable... why INOUT? # tup = compss_wait_on(tup) # if tup != ('a', 'b', 'c', 'd', 'd'): # print("- INOUT (tuple): ERROR") # errors = True # Operations with tuples always generate a new object. # They behave like simple types... why INOUT? # cplx = compss_wait_on(cplx) # if cplx != complex('4+8j'): # print("- INOUT (complex): ERROR") # errors = True if not errors: print("- INOUT: OK")
def test_mp_object_access(): print("test_object_mp_access") val = 1 o = MyClass(val) li = [1, 2, 3, 4] dic = {'key1': 'value1', 'key2': 'value2'} tup = ('a', 'b', 'c') cplx = complex('1+2j') function_objects(o, li, dic, tup, cplx, par_func) o = compss_wait_on(o) if o.field == val * 2: print("- Object access from MP 1: OK") else: print("- Object access from MP 1: ERROR") o.field = val * 4 function_objects(o, li, dic, tup, cplx, par_func)