def run_test(): ''' Tests whether Waldo can propagate an application exception back through an endpoint call. Returns true if the test passes and false otherwise. ''' thrower = Waldo.no_partner_create(SingleSide, None) catcher = Waldo.no_partner_create(SingleSide, thrower) return catcher.test_catch()
def run_test(): """ Tests whether Waldo can propagate an application exception back through an endpoint call. Returns true if the test passes and false otherwise. """ thrower = Waldo.no_partner_create(SingleSide, None) catcher = Waldo.no_partner_create(SingleSide, thrower) return catcher.test_catch()
def run_test(): ''' Tests the try...finally statement (without the use of catch). Returns true if an error may be propagated through a try...finally and handled later while having the code in the finally block execute. ''' catcher = Waldo.no_partner_create(Catcher) thrower = Waldo.no_partner_create(Thrower) catcher.addEndpoint(thrower) thrower.addEndpoint(catcher) return catcher.testTryFinally()
def run_test(): id_tester = Waldo.no_partner_create(IdTester) id = id_tester.id() manager = Waldo.no_partner_create(Manager) manager_id = manager.id() manager.add_endpoint(id_tester) if id != id_tester._uuid or manager_id != manager._uuid: return False elif id_tester.get_id() != id_tester.id() or manager.get_id() != manager.id(): return False elif id != manager.get_managed_endpoint_id(): return False else: return True
def run_test(): id_tester = Waldo.no_partner_create(IdTester) id = id_tester.id() manager = Waldo.no_partner_create(Manager) manager_id = manager.id() manager.add_endpoint(id_tester) if id != id_tester._uuid or manager_id != manager._uuid: return False elif id_tester.get_id() != id_tester.id() or manager.get_id( ) != manager.id(): return False elif id != manager.get_managed_endpoint_id(): return False else: return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if (1, 2, 3) != single_side.return_static_nums(): print "\nErr getting static numbers" return False if (1, 2, 3) != single_side.return_func_call_nums(): print "\nErr getting func call numbers" return False if ("a", "b") != single_side.return_variable_texts(): print "\nErr getting variable texts" return False if ("a", "b") != single_side.return_func_call_variable_texts(): print "\nErr getting func call variable texts" return False if ("a", "b", "c") != single_side.return_extended_texts(): print "\nErr getting extended texts" return False for i in range(1, 15): if (i, i) != single_side.return_tuple_endpoint_global(): print "\nErr: incorrect tuple value of mutated state" return False for j in range(i + 1, i + 15): if (j, j, 0) != single_side.wrapped_tuple(): print "\nErr: incorrect tuple value of wrapped mutated state" return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if not test_ext_num(single_side): return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if single_side.get_num() != 0: print '\nGot incorrect initial value for number' return False if single_side.get_txt() != '': print '\nGot incorrect initial value for text' return False for counter in range(0, 100): if single_side.increment_num() != counter + 1: print '\nGot incorrect number when incrementing' return False # just want to append a single a each time. Note: probably # more efficient to just keep track of a shadow text val # myself and append an 'a' to it each time. But I wanted to # play with reduce a bit. expected_str = reduce(lambda x, y: x + y, (['a'] * (counter + 1)), '') if single_side.increment_txt('a') != expected_str: print '\nGot incorrect string back' return False internal_list = single_side.increment_list(counter) expected_internal_list = list(range(0, counter + 1)) if internal_list != expected_internal_list: print '\nNot appending to internal list correctly' return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) num_to_assign = 30 single_side.assign_num_to_number_struct(num_to_assign) if single_side.read_num_from_number_struct() != num_to_assign: print '\nErr: could not write user struct number' return False # tests nesting user structs outer_nested_num = 52 inner_nested_num = 31 single_side.assign_num_to_nested_struct( outer_nested_num,inner_nested_num) if single_side.get_outer_and_inner_nested_nums() != (outer_nested_num,inner_nested_num): print '\nErr with nested user structs' return False # tests passing struct through argument to method new_num = 1 if single_side.get_endpoint_nested_struct_num(new_num) != new_num: print '\nError passing structs through as method args' return False return True
def run_test(): single_side = Waldo.no_partner_create( SingleSide, min_func,max_func,mod_func) # to mod between mod_tuples_list = [ (6,2), (5,3), (100,3), (38, 7)] for mod_tuple in mod_tuples_list: if single_side.test_mod(*mod_tuple) != mod_func(None,*mod_tuple): print '\nErr with mod call' return False # to max max_min_list_list = [ list(range(205,150, -1)), [-1, 52,1,0], [73, 13.25,100,239]] for max_min_list in max_min_list_list: if single_side.test_max(max_min_list) != max_func(None,max_min_list): print '\nErr with max call' return False # to min for max_min_list in max_min_list_list: if single_side.test_min(max_min_list) != min_func(None,max_min_list): print '\nErr with min call' return False return True
def run_test(): math_endpoint = Waldo.math_endpoint_lib() single_side = Waldo.no_partner_create(SingleSide, math_endpoint) # to mod between mod_tuples_list = [(6, 2), (5, 3), (100, 3), (38, 7)] for mod_tuple in mod_tuples_list: lhs = mod_tuple[0] rhs = mod_tuple[1] if single_side.test_mod(lhs, rhs) != (lhs % rhs): print '\nErr with mod call' return False # to max max_min_list_list = [ list(range(205, 150, -1)), [-1, 52, 1, 0], [73, 13.25, 100, 239] ] for max_min_list in max_min_list_list: if single_side.test_max(max_min_list) != max(max_min_list): print '\nErr with max call' return False # to min for max_min_list in max_min_list_list: if single_side.test_min(max_min_list) != min(max_min_list): print '\nErr with min call' return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if not test_maps(single_side): return False if not test_lists(single_side): return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) single_side.do_nothing() single_side.stop() try: single_side.do_nothing() except Waldo.StoppedException as inst: return True return False
def run_server(): ''' Runs the multi-connection chat server. ''' global server server = Waldo.no_partner_create(Server, display_msg) print server Waldo.tcp_accept(ClientHandler, HOSTNAME, PORT, server, display_msg) while True: time.sleep(SLEEP_TIME)
def run_test(): # for single side tests, these values do not really matter. host_uuid = 10 single_side = Waldo.no_partner_create( SingleSide, text_identity,text_len,list_sum,no_return, sum_three_args,return_three_args) test_strings_list = ['hello','wow','my','good','this is it'] # test identity text call for string in test_strings_list: if not single_side.execute_identity_endpoint_func (string): print '\nErr in identity func call' return False # test len text call for string in test_strings_list: if not single_side.execute_len_endpoint_func (string): print '\nErr in len func call' return False test_nums_list = [ list(range(0,13)), list(range(50,500,2)), [1.2,3.9,-1.3]] # test sum list call for num_list in test_nums_list: if not single_side.execute_sum_list_endpoint_func (num_list): print '\nErr in sum list func call' return False # execute no return single_side.execute_no_return_endpoint_func() # test multiple arguments mult_args_array = [ (1,3,5), (38,10,1000), (-1.4,-50,10) ] for arg_tuple in mult_args_array: if not single_side.execute_sum_three_args_endpoint_func(*arg_tuple): print '\nErr: with multiple arguments to functions' return False # test multiple return arguments for arg_tuple in mult_args_array: if single_side.execute_return_three_args_endpoint_func(*arg_tuple) != arg_tuple: print '\nErr could not return tuple' return False return True
def run_test(): ''' Tests Waldo's ability to propagate an ApplicationException back through an endpoint call on the remote partner in a sequence. The exception should be passed back to the root endpoint which initiates the sequence. Returns true if the exception is caught and handled, and false otherwise. ''' thrower = Waldo.no_partner_create(Pong,None) catcher_partner = Waldo.tcp_accept(Pong,HOST,PORT,thrower) catcher = Waldo.tcp_connect(Ping,HOST,PORT) return catcher.testExceptionPropagation()
def run_test(): ''' Returns true on success. ''' firstEndpoint = Waldo.no_partner_create(SelfTester) secondEndpoint = firstEndpoint.get_self() if firstEndpoint != secondEndpoint: return False elif secondEndpoint.test_input_output(NUM) != NUM: return False else: return True
def start_coordinator(): math_endpoint = Waldo.math_endpoint_lib() coordinator_master = Waldo.no_partner_create( CoordinatorMaster, util_funcs.between, util_funcs.rand_uuid, math_endpoint, conf.MAX_NUMBER_FINGER_TABLE_ENTRIES) # begin listening for connections to coordinator master Waldo.tcp_accept(Coordinator, conf.COORDINATOR_HOST_PORT_PAIR.host, conf.COORDINATOR_HOST_PORT_PAIR.port, coordinator_master) return coordinator_master
def run_test(): ''' Tests Waldo's ability to propagate an exception back through a sequence within an endpoint call. Returns true if the exception is caught and handled, and false otherwise. ''' Waldo.tcp_accept(Pong,HOST,PORT) connector = Waldo.tcp_connect(Ping,HOST,PORT) catcher = Waldo.no_partner_create(Catcher) catcher.addEndpoint(connector) return catcher.testCatchApplicationExceptionFromSequence()
def start_coordinator(): math_endpoint = Waldo.math_endpoint_lib() coordinator_master = Waldo.no_partner_create( CoordinatorMaster, util_funcs.between, util_funcs.rand_uuid,math_endpoint, conf.MAX_NUMBER_FINGER_TABLE_ENTRIES) # begin listening for connections to coordinator master Waldo.tcp_accept( Coordinator, conf.COORDINATOR_HOST_PORT_PAIR.host, conf.COORDINATOR_HOST_PORT_PAIR.port, coordinator_master) return coordinator_master
def add_single_dht_node(node_host_port_pair): # first: connect to discovery service requester = Waldo.tcp_connect( Requester, conf.COORDINATOR_HOST_PORT_PAIR.host, conf.COORDINATOR_HOST_PORT_PAIR.port, # the host and port that our new dht node will listen on for # connections to other dht nodes. node_host_port_pair.host, node_host_port_pair.port) # request request addresses of other nodes to contact from # discovery service, plus register self with discovery service. uuid, finger_table, next, prev = requester.register() dht_node = Waldo.no_partner_create(Node, uuid, util_funcs.distance, util_funcs.hashed_uuid, util_funcs.between, util_funcs.debug_print) # listen for connections to my node def on_connected(sidea_endpoint): sidea_endpoint.add_connection_to_node() Waldo.tcp_accept(NodeSideA, node_host_port_pair.host, node_host_port_pair.port, dht_node, node_host_port_pair.host, node_host_port_pair.port, connected_callback=on_connected) # connect to other nodes in my finger table for uuid in finger_table.keys(): # table_entry has form: # host: <text> # port: <number> # valid: <bool> # uuid: <text> table_entry = finger_table[uuid] host_to_connect_to = table_entry['host'] port_to_connect_to = table_entry['port'] connection_to_finger_table_node = Waldo.tcp_connect( NodeSideB, host_to_connect_to, port_to_connect_to, dht_node, node_host_port_pair.host, node_host_port_pair.port) return dht_node
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if not test_to_text(single_side): return False if not test_misc_list(single_side): return False if not test_nested_map(single_side): return False if not test_user_struct_returns(single_side): return False return True
def run_test(): ''' Tests that Waldo can detect a network exception mid-sequence and propagate that exception back through an endpoint call. Returns true if the test passes and false otherwise. ''' Waldo.set_default_heartbeat_period(1) Waldo.set_default_partner_timeout(2) acceptor_process.start() time.sleep(SLEEP_TIME) endpt = Waldo.tcp_connect(Ping, HOST, PORT) endpt.addTerminationFunction(signal_func) catcher = Waldo.no_partner_create(Catcher) catcher.addEndpoint(endpt) return catcher.testPropagateNetworkExceptionOnEndpointCall()
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if not test_range(single_side): return False if not test_while(single_side): return False if not test_for(single_side): return False if not test_break_continue(single_side): return False return True
def add_single_dht_node(node_host_port_pair): # first: connect to discovery service requester = Waldo.tcp_connect( Requester, conf.COORDINATOR_HOST_PORT_PAIR.host, conf.COORDINATOR_HOST_PORT_PAIR.port, # the host and port that our new dht node will listen on for # connections to other dht nodes. node_host_port_pair.host, node_host_port_pair.port) # request request addresses of other nodes to contact from # discovery service, plus register self with discovery service. uuid, finger_table, next, prev = requester.register() dht_node = Waldo.no_partner_create( Node,uuid,util_funcs.distance,util_funcs.hashed_uuid, util_funcs.between, util_funcs.debug_print) # listen for connections to my node def on_connected(sidea_endpoint): sidea_endpoint.add_connection_to_node() Waldo.tcp_accept( NodeSideA, node_host_port_pair.host, node_host_port_pair.port, dht_node, node_host_port_pair.host, node_host_port_pair.port, connected_callback = on_connected) # connect to other nodes in my finger table for uuid in finger_table.keys(): # table_entry has form: # host: <text> # port: <number> # valid: <bool> # uuid: <text> table_entry = finger_table[uuid] host_to_connect_to = table_entry['host'] port_to_connect_to = table_entry['port'] connection_to_finger_table_node = Waldo.tcp_connect( NodeSideB, host_to_connect_to, port_to_connect_to, dht_node,node_host_port_pair.host, node_host_port_pair.port) return dht_node
def run_test(): # for single side tests, these values do not really matter. single_side = Waldo.no_partner_create(SingleSide) if not test_comparisons(single_side): return False if not test_math(single_side): return False if not test_other_plusses(single_side): return False if not test_in(single_side): return False return True
def run_test(): # for single side tests, these values do not really matter. init_num = 50 init_text = 'hello' init_list = [[True, False], [False]] init_map = {2: 'wow', 6: 'this'} host_uuid = 10 single_side = Waldo.no_partner_create(SingleSide, init_num, init_text, init_list, init_map) if (single_side.get_endpoint_values() != (init_num, init_text, init_list, init_map)): print '\nErr when initializing' return False return True
def run_test(): # for single side tests, these values do not really matter. internal_num = 35 index_num = 31 single_side = Waldo.no_partner_create(SingleSide, internal_num, index_num) if single_side.get_external_vals(index_num) != (internal_num, internal_num): print "\nErr: got an incorrect external val" return False internal_num = 22 single_side.change_external_num(internal_num) if single_side.get_external_vals(index_num) != (internal_num, internal_num): print "\nErr: got an incorrect external val after changing" return False return True
def run_test(): # for single side tests, these values do not really matter. host_uuid = 10 wlist = Waldo._waldo_classes['WaldoListVariable']('some list', host_uuid) single_side = Waldo.no_partner_create(SingleSide, wlist) internal_list = wlist.get_val(None) raw_internal_list = internal_list.val.val if len(raw_internal_list) != 1: print '\nErr: did not append self to list' return False if raw_internal_list[0].val.val != single_side: print '\nErr: incorrect endpoint value appended to list' return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) single_side.populate_lists() single_side.change_one() len_a, len_b1, len_b2 = single_side.get_len_lists() if (len_a != 3) or (len_b1 != 3) or (len_b2 != 3): return False ### Now test deep lists single_side.deep_populate_lists() single_side.deep_change_one() deep_len_a, deep_len_b1, deep_len_b2, deep_helper_len = single_side.deep_get_len_lists() if (deep_len_a != 2) or (deep_len_b1 != 2) or (deep_len_b2 != 2) or (deep_helper_len != 2): return False return True
def run_test(): # for single side tests, these values do not really matter. host_uuid = 10 wlist = Waldo._waldo_classes['WaldoListVariable']('some list',host_uuid) single_side = Waldo.no_partner_create(SingleSide, wlist) internal_list = wlist.get_val(None) raw_internal_list = internal_list.val.val if len(raw_internal_list) != 1: print '\nErr: did not append self to list' return False if raw_internal_list[0].val.val != single_side: print '\nErr: incorrect endpoint value appended to list' return False return True
def run_test(): endpt = Waldo.no_partner_create(SingleHost,delay) long_write_long_thread = EndpointThread(endpt,True) write_long_long_thread = EndpointThread(endpt,False) long_write_long_thread.start() time.sleep(.05) write_long_long_thread.start() long_write_long_thread.join() write_long_long_thread.join() if long_write_long_thread.result != 1: return False if write_long_long_thread.result != 2: return False return True
def run_test(): endpt = Waldo.no_partner_create(SingleHost, delay) long_write_long_thread = EndpointThread(endpt, True) write_long_long_thread = EndpointThread(endpt, False) long_write_long_thread.start() time.sleep(.05) write_long_long_thread.start() long_write_long_thread.join() write_long_long_thread.join() global got_retry, got_aborted_retry if not got_retry: return False if not got_aborted_retry: return False return True
def run_test(): endpt = Waldo.no_partner_create(SingleHost, delay) long_write_long_thread = EndpointThread(endpt, True) write_long_long_thread = EndpointThread(endpt, False) long_write_long_thread.start() time.sleep(.05) write_long_long_thread.start() long_write_long_thread.join() write_long_long_thread.join() if long_write_long_thread.result != 1: return False if write_long_long_thread.result != 2: return False return True
def run_test(): endpt = Waldo.no_partner_create(SingleHost,delay) long_write_long_thread = EndpointThread(endpt,True) write_long_long_thread = EndpointThread(endpt,False) long_write_long_thread.start() time.sleep(.05) write_long_long_thread.start() long_write_long_thread.join() write_long_long_thread.join() global got_retry, got_aborted_retry if not got_retry: return False if not got_aborted_retry: return False return True
def run_anagram_server(): anagram_server = Waldo.no_partner_create(AnagramServer) Waldo.tcp_accept(PlayerHelper, HOSTNAME, ANAGRAM_PORT, anagram_server) load_solutions() while True: print 'Waiting for players....' while anagram_server.get_player_count() <= 0: time.sleep(0.1) print 'Player entered. Game will begin in 10 seconds.' set_solutions(anagram_server) anagram_server.broadcastWaitingMessage('Game will begin in %d seconds. Type "/ready" to join.\n' %ANAGRAM_WAITTIME) for i in range(ANAGRAM_WAITTIME): if (i == ANAGRAM_WAITTIME/2): anagram_server.broadcastMessage('Game will begin in %d seconds\n' %i) time.sleep(1) print 'Game has begun!' anagram_server.start_game() time.sleep(20)#Change to GAMETIME after testing anagram_server.end_game() time.sleep(ANAGRAM_WAITTIME/2) anagram_server.restart_server()
def run_test(): # for single side tests, these values do not really matter. internal_num = 35 index_num = 31 single_side = Waldo.no_partner_create(SingleSide, internal_num, index_num) if single_side.get_external_vals(index_num) != (internal_num, internal_num): print '\nErr: got an incorrect external val' return False internal_num = 22 single_side.change_external_num(internal_num) if single_side.get_external_vals(index_num) != (internal_num, internal_num): print '\nErr: got an incorrect external val after changing' return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) expected_txt = 'a' expected_num = 30 expected_tf = False expected_list = [2,4,6] expected_map = { True: 100, False: 93 } expected_other_num = 30 expected_other_list = [2,4,6] if (single_side.return_local_vars() != (expected_txt, expected_num, expected_tf, expected_list, expected_map, expected_other_num, expected_other_list)): print '\nErr getting locally initialized' return False if (single_side.return_global_vars() != (expected_txt, expected_num, expected_tf, expected_list, expected_map, expected_other_num, expected_other_list)): print '\nErr getting globally initialized' return False return True
def run_test(): # for single side tests, these values do not really matter. init_num = 50 init_text = 'hello' init_list = [ [True,False], [False]] init_map = { 2: 'wow', 6: 'this'} host_uuid = 10 single_side = Waldo.no_partner_create( SingleSide, init_num,init_text,init_list,init_map) if (single_side.get_endpoint_values() != (init_num,init_text,init_list,init_map)): print '\nErr when initializing' return False return True
def run_test(): math_endpoint = Waldo.math_endpoint_lib() single_side = Waldo.no_partner_create(SingleSide, math_endpoint) # to mod between mod_tuples_list = [ (6,2), (5,3), (100,3), (38, 7)] for mod_tuple in mod_tuples_list: lhs = mod_tuple[0] rhs = mod_tuple[1] if single_side.test_mod(lhs,rhs) != (lhs % rhs): print '\nErr with mod call' return False # to max max_min_list_list = [ list(range(205,150, -1)), [-1, 52,1,0], [73, 13.25,100,239]] for max_min_list in max_min_list_list: if single_side.test_max(max_min_list) != max(max_min_list): print '\nErr with max call' return False # to min for max_min_list in max_min_list_list: if single_side.test_min(max_min_list) != min(max_min_list): print '\nErr with min call' return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) if single_side.get_num() != 0: print '\nGot incorrect initial value for number' return False if single_side.get_txt() != '': print '\nGot incorrect initial value for text' return False for counter in range(0,100): if single_side.increment_num() != counter + 1: print '\nGot incorrect number when incrementing' return False # just want to append a single a each time. Note: probably # more efficient to just keep track of a shadow text val # myself and append an 'a' to it each time. But I wanted to # play with reduce a bit. expected_str = reduce( lambda x,y: x + y, (['a']*(counter+1)), '') if single_side.increment_txt('a') != expected_str: print '\nGot incorrect string back' return False internal_list = single_side.increment_list(counter) expected_internal_list = list(range(0,counter+1)) if internal_list != expected_internal_list: print '\nNot appending to internal list correctly' return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) expected_txt = 'a' expected_num = 30 expected_tf = False expected_list = [2, 4, 6] expected_map = {True: 100, False: 93} expected_other_num = 30 expected_other_list = [2, 4, 6] if (single_side.return_local_vars() != (expected_txt, expected_num, expected_tf, expected_list, expected_map, expected_other_num, expected_other_list)): print '\nErr getting locally initialized' return False if (single_side.return_global_vars() != (expected_txt, expected_num, expected_tf, expected_list, expected_map, expected_other_num, expected_other_list)): print '\nErr getting globally initialized' return False return True
def run_test(): single_side = Waldo.no_partner_create(SingleSide) # basic if test if single_side.test_if(True,1,2) != 1: print '\nErr: error of conditional of if 1' return False if single_side.test_if(False,1,2) != 2: print '\nErr: error of conditional of if 2' return False # basic if, else, elseIf tests if single_side.test_else_if( True,1, True,-1, True,-1, True,-1, True,-1, True,-1, True,-1, -1,-1) != 1: print '\nErr of if condition of test else if' return False if single_side.test_else_if( False,-1, True,1, True,-1, True,-1, True,-1, True,-1, True,-1, -1,-1) != 1: print '\nErr of elseIf1 condition of test else if' return False if single_side.test_else_if( False,-1, False,-1, True,1, True,-1, True,-1, True,-1, True,-1, -1,-1) != 1: print '\nErr of elseIf2 condition of test else if' return False if single_side.test_else_if( False,-1, False,-1, False,-1, True,1, True,-1, True,-1, True,-1, -1,-1) != 1: print '\nErr of elseIf3 condition of test else if' return False if single_side.test_else_if( False,-1, False,-1, False,-1, False,-1, True,1, True,-1, True,-1, -1,-1) != 1: print '\nErr of elseIf4 condition of test else if' return False if single_side.test_else_if( False,-1, False,-1, False,-1, False,-1, False,-1, True,1, True,-1, -1,-1) != 1: print '\nErr of elseIf5 condition of test else if' return False if single_side.test_else_if( False,-1, False,-1, False,-1, False,-1, False,-1, False,-1, True,1, -1,-1) != 1: print '\nErr of elseIf6 condition of test else if' return False if single_side.test_else_if( False,-1, False,-1, False,-1, False,-1, False,-1, False,-1, False,-1, 1,-1) != 1: print '\nErr of elseIf7 condition of test else if' return False # test if else if single_side.test_if_else(True,1,-1,-1) != 1: print '\nErr of ifElse 1' return False if single_side.test_if_else(False,-1,1,-1) != 1: print '\nErr of ifElse 2' return False # test boolean logic # Public Function test_boolean_logic( # TrueFalse a_or1, TrueFalse a_or2,TrueFalse b_and1, # TrueFalse b_and2, Number return_if, Number return_else) returns Number # { # if ((a_or1 or a_or2) and (b_and1 and b_and2)) # { # return return_if; # } # return return_else; # } if single_side.test_boolean_logic( False, False, True, True, -1, 1) != 1: print '\nErr on test_boolean_logic1' return False if single_side.test_boolean_logic( False, True, True, True, 1, -1) != 1: print '\nErr on test_boolean_logic2' return False if single_side.test_boolean_logic( True, True, True, False, -1, 1) != 1: print '\nErr on test_boolean_logic3' return False # Test many statements if_else_if_else if single_side.many_statements_in_if_else_if_else( True,True,1,-1,-1,-1) != 21: print '\n\n' print single_side.many_statements_in_if_else_if_else( True,True,1,-1,-1,-1) print '\n\n' print '\nErr on many if 1' return False if single_side.many_statements_in_if_else_if_else( False,True,-1,1,-1,-1) != 21: print '\nErr on many if 2' return False if single_side.many_statements_in_if_else_if_else( False,False,-1,-1,1,-1) != 21: print '\nErr on many if 3' return False # Test empty bodies single_side.test_empty_if_body() single_side.test_empty_else_if_body() single_side.test_empty_else_body() return True
def run_test(): testEndpoint = Waldo.no_partner_create(SingleSide) return testEndpoint.testApplicationException()