From 6561d0478e887b3be4928771162b71c61f561d2a Mon Sep 17 00:00:00 2001 From: isExample Date: Sat, 11 Oct 2025 01:31:06 +0900 Subject: [PATCH] test: add regression test for diff markers in suggestion blocks --- tests/unittest/test_try_fix_yaml.py | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/unittest/test_try_fix_yaml.py b/tests/unittest/test_try_fix_yaml.py index 03823d7b..7e52c11b 100644 --- a/tests/unittest/test_try_fix_yaml.py +++ b/tests/unittest/test_try_fix_yaml.py @@ -244,3 +244,36 @@ int sub(int a, int b) { ''' expected_output = {'code_suggestions': [{'relevant_file': 'a.c\n', 'existing_code': ' int sum(int a, int b) {\n return a + b;\n }\n\n int sub(int a, int b) {\n return a - b;\n }\n'}]} assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='existing_code') == expected_output + + def test_diff_markers_removed_within_list_item(self): + """ + Ensures diff-style '-' markers nested inside list items are normalised so the YAML parses + into the expected structure. + """ + review_text = '''\ +code_suggestions: +- relevant_file: | + example.rb + existing_code: | ++ puts 'hello' ++ puts 'world' +- relevant_file: | +- example.py +- existing_code: | +-+ print('hello') +-+ print('world') +''' + expected_output = { + 'code_suggestions': [ + { + 'relevant_file': 'example.rb\n', + 'existing_code': "puts 'hello'\nputs 'world'\n" + }, + { + 'relevant_file': 'example.py\n', + 'existing_code': "print('hello')\nprint('world')\n" + } + ] + } + + assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='existing_code') == expected_output \ No newline at end of file