Beispiel #1
0
def test_static_method():
    print("test_static_method")
    o = MyClass(1)
    result = o.static_method(2, 4, 8)
    result = compss_wait_on(result)
    if result == (2 + 4) * 8:
        print("- Static method: OK")
    else:
        print("- Static method: ERROR")
Beispiel #2
0
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)
Beispiel #3
0
def test_instance_method():
    print("test_instance_method")
    val = 1
    o = MyClass(val)

    o.instance_method()
    o.instance_method_nonmodifier()
    o.instance_method()

    o = compss_wait_on(o)
    if o.field == val * 4:
        print("- Object access from MP 2: OK")
    else:
        print("- Object access from MP 2: ERROR")
Beispiel #4
0
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")
Beispiel #5
0
def test_all_class_tasks():
    print("test_instance_method")
    val = 1
    o = MyClass(val)
    o.instance_method(88)  # 1
    o.instance_method_nonmodifier()  # 2
    o.instance_method(88)  # 3
    o = compss_wait_on(o)
    if o.field == val * 4:
        print("- Object access from MP 4: OK")
    else:
        print("- Object access from MP 4: ERROR")

    print("test_class_method")
    MyClass.class_method()  # 4

    print("test_instance_method_with_parameter_and_return")

    o = MyClass('HolaMundo')
    b = o.return_value_square(99)  # 5
    b1 = compss_wait_on(b)
    o1 = compss_wait_on(o)
    # print('result1: ', b1
    # print('accum  : ', o1.v
    if b1 == 9801 and o1.v == 99:
        print("- Object access from MP (Round 1): OK")
    else:
        print("- Object access from MP (Round 1): ERROR")

    b = o.return_value_square(199)  # 5
    b2 = compss_wait_on(b)
    # print('result2: ', b2)
    if b2 == 39601:
        print("- Object access from MP (Round 2): OK")
    else:
        print("- Object access from MP (Round 2): ERROR")

    b = o.return_value_square(299)  # 5
    b3 = compss_wait_on(b)
    o3 = compss_wait_on(o)
    # print('result3: ', b3)
    # print('accum  : ', o3.v)
    if b3 == 89401 and o3.v == 597:
        print("- Object access from MP (Round 3): OK")
    else:
        print("- Object access from MP (Round 3): ERROR")
Beispiel #6
0
def test_class_method():
    print("test_class_method")
    MyClass.class_method()