@@ -323,30 +323,27 @@ def test_single_element_list():
323323 # Verify instance_state result, which checks instance state right after __init__, using codeflash_capture
324324
325325 # Verify function_to_optimize result
326- assert test_results [0 ].id .function_getting_tested == "sorter "
326+ assert test_results [0 ].id .function_getting_tested == "BubbleSorter.__init__ "
327327 assert test_results [0 ].id .test_function_name == "test_single_element_list"
328328 assert test_results [0 ].did_pass
329+ assert test_results [0 ].return_value [0 ] == {"x" : 0 }
330+ assert test_results [0 ].stdout == ""
331+ assert test_results [1 ].id .function_getting_tested == "sorter"
332+ assert test_results [1 ].id .test_function_name == "test_single_element_list"
333+ assert test_results [1 ].did_pass
329334
330335 # Checks input values to the function to see if they have mutated
331336 # assert comparator(test_results[1].return_value[1]["self"], BubbleSorter()) TODO: add self as input
332- assert test_results [0 ].return_value [1 ]["arr" ] == [1 , 2 , 3 ]
337+ assert test_results [1 ].return_value [1 ]["arr" ] == [1 , 2 , 3 ]
333338
334339 # Check function return value
335- assert test_results [0 ].return_value [2 ] == [1 , 2 , 3 ]
336- assert (
337- test_results [0 ].stdout
338- == """codeflash stdout : BubbleSorter.sorter() called
339- """
340- )
341- assert test_results [1 ].id .function_getting_tested == "BubbleSorter.__init__"
342- assert test_results [1 ].id .test_function_name == "test_single_element_list"
343- assert test_results [1 ].did_pass
344- assert test_results [1 ].return_value [0 ] == {"x" : 0 }
340+ assert test_results [1 ].return_value [2 ] == [1 , 2 , 3 ]
345341 assert (
346342 test_results [1 ].stdout
347343 == """codeflash stdout : BubbleSorter.sorter() called
348344"""
349345 )
346+
350347 # Replace with optimized code that mutated instance attribute
351348 optimized_code_mutated_attr = """
352349import sys
@@ -401,10 +398,10 @@ def sorter(self, arr):
401398 testing_time = 0.1 ,
402399 )
403400 # assert test_results_mutated_attr[0].return_value[0]["self"].x == 1 TODO: add self as input
404- assert test_results_mutated_attr [1 ].id .function_getting_tested == "BubbleSorter.__init__"
405- assert test_results_mutated_attr [1 ].return_value [0 ] == {"x" : 1 }
406- assert test_results_mutated_attr [1 ].verification_type == VerificationType .INIT_STATE_FTO
407- assert test_results_mutated_attr [1 ].stdout == "codeflash stdout : BubbleSorter.sorter() called \n "
401+ assert test_results_mutated_attr [0 ].id .function_getting_tested == "BubbleSorter.__init__"
402+ assert test_results_mutated_attr [0 ].return_value [0 ] == {"x" : 1 }
403+ assert test_results_mutated_attr [0 ].verification_type == VerificationType .INIT_STATE_FTO
404+ assert test_results_mutated_attr [0 ].stdout == ""
408405 assert not compare_test_results (
409406 test_results , test_results_mutated_attr
410407 ) # The test should fail because the instance attribute was mutated
@@ -453,10 +450,10 @@ def sorter(self, arr):
453450 pytest_max_loops = 1 ,
454451 testing_time = 0.1 ,
455452 )
456- assert test_results_new_attr [1 ].id .function_getting_tested == "BubbleSorter.__init__"
457- assert test_results_new_attr [1 ].return_value [0 ] == {"x" : 0 , "y" : 2 }
458- assert test_results_new_attr [1 ].verification_type == VerificationType .INIT_STATE_FTO
459- assert test_results_new_attr [1 ].stdout == "codeflash stdout : BubbleSorter.sorter() called \n "
453+ assert test_results_new_attr [0 ].id .function_getting_tested == "BubbleSorter.__init__"
454+ assert test_results_new_attr [0 ].return_value [0 ] == {"x" : 0 , "y" : 2 }
455+ assert test_results_new_attr [0 ].verification_type == VerificationType .INIT_STATE_FTO
456+ assert test_results_new_attr [0 ].stdout == ""
460457 # assert test_results_new_attr[1].return_value[1]["self"].x == 0 TODO: add self as input
461458 # assert test_results_new_attr[1].return_value[1]["self"].y == 2 TODO: add self as input
462459 assert compare_test_results (
0 commit comments