From 5de47e3df316c0662115ef9890ea5621bbdd2063 Mon Sep 17 00:00:00 2001 From: Agnik47 <140933190+Agnik47@users.noreply.github.com> Date: Sat, 3 Oct 2026 13:18:15 +0530 Subject: [PATCH] fix(extract): end a Svelte script block's trailing comment and report read errors Review follow-ups on #3928: - A `//` comment closing one `\n" + "\n", + ) + result = extract_svelte(component) + assert result.get("parse_errors") is None + labels = _labels(result) + assert labels.get("b()") == "L1" + assert labels.get("c()") == "L2" + + +def test_extract_svelte_comment_after_unterminated_statement(tmp_path): + """A statement with no `;` before the `//` comment still ends at the block.""" + component = _write( + tmp_path / "src/Unterminated.svelte", + "\n", + ) + result = extract_svelte(component) + assert result.get("parse_errors") is None + assert _labels(result).get("b()") == "L1" + + +def test_extract_svelte_unreadable_file_reports_error(tmp_path): + """A file that cannot be read is reported, not returned as an empty result.""" + result = extract_svelte(tmp_path / "missing" / "Gone.svelte") + assert result["nodes"] == [] and result["edges"] == [] + assert "error" in result + + def test_extract_svelte_markup_only_component_does_not_crash(tmp_path): """A `.svelte` file need not have a `