Versions 102 to 103Comparefrom⇄toCompare+78 −0 in 1 placesrc/engine/test/view.test.ts+78 −0BlameLines 91–172 at 103 (were 91–94 at 102)9191 assert.deepEqual(view.knownPaths(), ["a.txt", "b.txt"]);9292 assert.deepEqual(view.files(), { "a.txt": "a\n" });9393 });94+95+ it("accounts for the membership bitmap before layout and stays observational", () => {96+ const small = Repo.init({ "f.txt": lines("same") });97+ const larger = Repo.init({ "f.txt": lines("same") });98+ for (let i = 0; i < 8; i++)99+ larger.edit({ attrs: [{ file: "f.txt", name: "exec", value: i % 2 === 0 ? "1" : null }] });100+101+ const smallView = new View(small.graph, small.shared);102+ const largerView = new View(larger.graph, larger.shared);103+ const smallBeforeLayout = smallView.weight();104+ const largerBeforeLayout = largerView.weight();105+ assert.ok(smallBeforeLayout >= small.graph.size);106+ assert.ok(largerBeforeLayout >= larger.graph.size);107+ assert.equal(largerBeforeLayout - smallBeforeLayout, larger.graph.size - small.graph.size);108+ assert.equal(largerView.weight(), largerBeforeLayout);109+110+ assert.deepEqual(smallView.files(), largerView.files());111+ const afterLayout = largerView.weight();112+ assert.equal(largerView.weight(), afterLayout);113+ assert.deepEqual(largerView.files(), { "f.txt": "same\n" });114+ });115+116+ it("accounts for lazy view-owned containers and relocation/index growth", () => {117+ const repo = Repo.init({ "a.txt": lines("one", "two"), "b.txt": lines("base") });118+ repo.edit({ move: { file: "a.txt", start: 0, end: 1, to: "b.txt", at: 1 } });119+ const deletion = repo.edit({ edits: [{ file: "b.txt", old: "base\n", new: "" }] });120+ const view = repo.view();121+ let weight = view.weight();122+ assert.equal(view.weight(), weight);123+124+ assert.equal(view.set.size, 3);125+ assert.ok(view.weight() > weight);126+ weight = view.weight();127+ assert.deepEqual(view.knownPaths(), ["a.txt", "b.txt"]);128+ assert.ok(view.weight() > weight);129+ weight = view.weight();130+ assert.equal(view.fileOf("a0.0"), "b.txt");131+ assert.ok(view.weight() > weight);132+133+ const expectedFiles = { "a.txt": "two\n", "b.txt": "one\n" };134+ assert.deepEqual(view.files(), expectedFiles);135+ weight = view.weight();136+ assert.deepEqual(137+ view.sequence("b.txt").map((line) => [line.text, line.visible, line.deletedBy]),138+ [139+ ["base", false, [deletion.id]],140+ ["one", true, []],141+ ],142+ );143+ assert.ok(view.weight() > weight);144+ weight = view.weight();145+ assert.equal(view.sequenceIndex("b.txt", "a0.0"), 1);146+ assert.ok(view.weight() > weight);147+ weight = view.weight();148+ assert.equal(view.lineNumber("b.txt", "a0.0"), 0);149+ assert.ok(view.weight() > weight);150+ weight = view.weight();151+ assert.deepEqual(152+ view.lines("b.txt").map((line) => line.text),153+ ["one"],154+ );155+ assert.ok(view.weight() > weight);156+ const finalWeight = view.weight();157+ assert.equal(view.weight(), finalWeight);158+ assert.deepEqual(view.files(), expectedFiles);159+ });160+161+ it("counts line-cache references without charging Graph-owned text per view", () => {162+ const short = Repo.init({ "f.txt": lines("x") });163+ const long = Repo.init({ "f.txt": lines("x".repeat(10_000)) });164+ const shortView = short.view();165+ const longView = long.view();166+ shortView.lines("f.txt");167+ longView.lines("f.txt");168+ assert.equal(shortView.weight(), longView.weight());169+ const longWeight = longView.weight();170+ assert.equal(longView.weight(), longWeight);171+ });94172});MCPcompare on this site's /mcpCLIabso diff 102 103 src/engine/test/view.test.ts --jsonJSON/christopher/abso-core/compare/102..103?file=src%2Fengine%2Ftest%2Fview.test.ts&format=json