From 817d4ef97125f78100f84ef76b2de5cb01780496 Mon Sep 17 00:00:00 2001 From: Amruth Pillai Date: Mon, 17 Aug 2026 22:19:52 +0200 Subject: [PATCH] test(stylesheet): correct the malformed declaration offset The expected offset disagreed with its own line and column: line 2 column 17 is offset 28, which is where `red` starts. Offset 31 pointed at `; }`. The sibling UTF-16 case in the same file already used the correct arithmetic. Anchors the offset to the source it must point at so it cannot drift again. --- packages/resume/src/stylesheet/parse.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/resume/src/stylesheet/parse.test.ts b/packages/resume/src/stylesheet/parse.test.ts index 18e935f9a..5e56a52dd 100644 --- a/packages/resume/src/stylesheet/parse.test.ts +++ b/packages/resume/src/stylesheet/parse.test.ts @@ -3,12 +3,16 @@ import { parseStylesheet } from "./parse"; describe("parseStylesheet", () => { it("returns exact ranges for malformed declarations and keeps a recoverable parse tree", () => { - const result = parseStylesheet("@version 1;\nsection { color red; }\nitem { opacity: .5; }"); + const source = "@version 1;\nsection { color red; }\nitem { opacity: .5; }"; + const result = parseStylesheet(source); expect(result.diagnostics[0]?.range).toEqual({ - start: { line: 2, column: 17, offset: 31 }, - end: { line: 2, column: 17, offset: 31 }, + start: { line: 2, column: 17, offset: 28 }, + end: { line: 2, column: 17, offset: 28 }, }); + // Anchor the offset to the source it must point at, so a parser change that shifts it fails + // loudly instead of leaving line/column and offset disagreeing. + expect(source.slice(28, 31)).toBe("red"); expect(result.rules).toHaveLength(2); });