From e16782c208320138d77b88f2ff359e3e9e059e76 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sat, 11 Jul 2026 19:57:02 +0900 Subject: fix: レビュー指摘事項の修正(エラー戻り値統一、タイ延長、ネストリピート、専用エラーコード) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit High severity: - compose action エラー戻り値の validation キー統一(server.py) - ppmck/pyxel タイ & の duration 延長修正(_tie_pending フラグ導入) - pyxel ネストリピート対応(RepeatFrame + イベントスナップショット方式) Medium severity: - 専用エラーコード追加: VALIDATION_MISSING_PARAMETER, VALIDATION_INVALID_MODE, VALIDATION_INVALID_ACTION - SYSTEM_INTERNAL_ERROR キャッチ範囲拡大(compose/validate全体をtry/except) Low severity: - 設計書 line/column を1始まりに明記、APIレベルエラーコード追記 テスト: 129 passed, ruff: All checks passed --- tests/test_parser_detailed.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/test_parser_detailed.py') diff --git a/tests/test_parser_detailed.py b/tests/test_parser_detailed.py index 88d7095..3752562 100644 --- a/tests/test_parser_detailed.py +++ b/tests/test_parser_detailed.py @@ -143,6 +143,28 @@ def test_pyxel_repeat_count3(): assert len(notes) == 6 +def test_pyxel_nested_repeat(): + source = "0: T120 L4 O4\n[ [ C D ]2 E ]2" + tokens = tokenize(source, "pyxel") + ns, errors = parse_pyxel(source, tokens) + assert not any(e.severity == "error" for e in errors) + notes = [e for e in ns.channels["Pulse1"].events if isinstance(e, NoteEvent)] + # Inner: [C D]2 -> C D C D (4 notes) + # Outer: [ ... E ]2 -> (C D C D E) * 2 = 10 notes + assert len(notes) == 10 + + +def test_pyxel_nested_repeat_count3(): + source = "0: T120 L4 O4\n[ [ C D ]2 E ]3" + tokens = tokenize(source, "pyxel") + ns, errors = parse_pyxel(source, tokens) + assert not any(e.severity == "error" for e in errors) + notes = [e for e in ns.channels["Pulse1"].events if isinstance(e, NoteEvent)] + # Inner: [C D]2 -> C D C D (4 notes) + # Outer: [ ... E ]3 -> (C D C D E) * 3 = 15 notes + assert len(notes) == 15 + + # --- Tie --- @@ -152,6 +174,21 @@ def test_ppmck_tie_note(): ns, errors = parse_ppmck(source, tokens) # Tie should merge notes; check no error assert not any(e.severity == "error" for e in errors) + notes = [e for e in ns.channels["Pulse1"].events if isinstance(e, NoteEvent)] + # c4 & c4 should produce a single note with doubled duration (192*2=384) + assert len(notes) == 1 + assert notes[0].duration == 384 + + +def test_pyxel_tie_note(): + source = "0: T120 L4 O4\n C4 & C4" + tokens = tokenize(source, "pyxel") + ns, errors = parse_pyxel(source, tokens) + assert not any(e.severity == "error" for e in errors) + notes = [e for e in ns.channels["Pulse1"].events if isinstance(e, NoteEvent)] + # C4 & C4 should produce a single note with doubled duration (192*2=384) + assert len(notes) == 1 + assert notes[0].duration == 384 def test_pyxel_tie_length(): -- cgit v1.2.3