- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/src/engine/test/graph-line-chunks.test.ts?format=json
41 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 175, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { buildAtom } from "../build.ts";
4import { Graph } from "../graph.ts";
5import { StoredText } from "../stored-text.ts";
6import { diffChunkedLines } from "../text.ts";
7import { View } from "../view.ts";
8import { Repo } from "./helpers.ts";
9import { SqlState } from "./storage-helper.ts";
11test("stored line comparison and atom construction never assemble historical long text", (t) => {
12 const storage = new SqlState();
13 t.after(() => storage.db.close());
14 const line = "x".repeat(100000) + "\ud800\udc00";
15 const repo = Repo.init({ "f.txt": `${line}\nkeep\n` });
16 const graph = new Graph({ storage });
17 graph.add(repo.graph.atom("a0"));
18 t.mock.method(StoredText.prototype, "read", () => {
19 throw Error("whole stored text forbidden");
20 });
21 t.mock.method(graph, "textOf", () => {
22 throw Error("whole line forbidden");
23 });
24 const chunks = [...graph.textChunks(0)];
25 assert.equal(chunks.join(""), line);
26 assert.ok(chunks.every((chunk) => chunk.length <= StoredText.chunkCharacters));
27 const view = new View(graph, ["a0"]);
28 assert.deepEqual(diffChunkedLines(view.lineChunks("f.txt"), [line, "changed"]), [
29 { start: 1, end: 2, lines: ["changed"] },
30 ]);
31 assert.equal(
32 buildAtom(view, {
33 author: "writer",
34 message: "change",
35 edits: [{ file: "f.txt", start: 0, end: 1, lines: ["replacement"] }],
36 }).deletes.length,
37 1,
38 );
39 assert.throws(() => [...graph.textChunks(-1)], /invalid line/);
40 assert.throws(() => [...graph.textChunks(2)], /invalid line/);
41});