@@ -323,30 +323,27 @@ def test_single_element_list():
323
323
# Verify instance_state result, which checks instance state right after __init__, using codeflash_capture
324
324
325
325
# 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__ "
327
327
assert test_results [0 ].id .test_function_name == "test_single_element_list"
328
328
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
329
334
330
335
# Checks input values to the function to see if they have mutated
331
336
# 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 ]
333
338
334
339
# 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 ]
345
341
assert (
346
342
test_results [1 ].stdout
347
343
== """codeflash stdout : BubbleSorter.sorter() called
348
344
"""
349
345
)
346
+
350
347
# Replace with optimized code that mutated instance attribute
351
348
optimized_code_mutated_attr = """
352
349
import sys
@@ -401,10 +398,10 @@ def sorter(self, arr):
401
398
testing_time = 0.1 ,
402
399
)
403
400
# 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 == ""
408
405
assert not compare_test_results (
409
406
test_results , test_results_mutated_attr
410
407
) # The test should fail because the instance attribute was mutated
@@ -453,10 +450,10 @@ def sorter(self, arr):
453
450
pytest_max_loops = 1 ,
454
451
testing_time = 0.1 ,
455
452
)
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 == ""
460
457
# assert test_results_new_attr[1].return_value[1]["self"].x == 0 TODO: add self as input
461
458
# assert test_results_new_attr[1].return_value[1]["self"].y == 2 TODO: add self as input
462
459
assert compare_test_results (
0 commit comments