Files
oh-my-pi/packages/coding-agent/test/tools/render-utils.test.ts
T
can1357 50cd2310dc feat(pi-natives): added language module with 39 languages and tree-sitter bindings
- Added language module with 39 supported languages and tree-sitter parser bindings for ast-grep integration.
- Exported dedupeParseErrors utility function to remove duplicate parse error messages in tool output.
- Fixed duplicate parse error messages when multiple patterns fail on the same file.
- Replaced language alias lookup with O(1) phf::Map and added 30+ new language aliases (golang, julia, toml, zig, etc.).
- Migrated from ast-grep-language to direct tree-sitter language dependencies for improved language support.
2026-03-04 17:02:29 +01:00

33 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { dedupeParseErrors, formatParseErrors } from "@oh-my-pi/pi-coding-agent/tools/render-utils";
describe("parse error formatting", () => {
it("deduplicates parse errors while preserving order", () => {
const errors = [
"foo.ts: parse error (syntax tree contains error nodes)",
"foo.ts: parse error (syntax tree contains error nodes)",
"bar.ts: parse error (syntax tree contains error nodes)",
"foo.ts: parse error (syntax tree contains error nodes)",
];
expect(dedupeParseErrors(errors)).toEqual([
"foo.ts: parse error (syntax tree contains error nodes)",
"bar.ts: parse error (syntax tree contains error nodes)",
]);
});
it("formats deduplicated parse errors", () => {
const formatted = formatParseErrors([
"foo.ts: parse error (syntax tree contains error nodes)",
"foo.ts: parse error (syntax tree contains error nodes)",
"bar.ts: parse error (syntax tree contains error nodes)",
]);
expect(formatted).toEqual([
"Parse issues:",
"- foo.ts: parse error (syntax tree contains error nodes)",
"- bar.ts: parse error (syntax tree contains error nodes)",
]);
});
});