From 309a286a1a13dc6ebe24f0f17695752a57631332 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Wed, 2 Aug 2023 19:46:06 +0200 Subject: [PATCH] fix tests --- src/__snapshots__/lexer.test.ts.snap | 50 ++++++++++++++++++++++------ src/error.test.ts | 2 +- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/__snapshots__/lexer.test.ts.snap b/src/__snapshots__/lexer.test.ts.snap index e4a93be..54e3f64 100644 --- a/src/__snapshots__/lexer.test.ts.snap +++ b/src/__snapshots__/lexer.test.ts.snap @@ -4,44 +4,62 @@ exports[`should tokenize an emtpy function 1`] = ` [ { "kind": "function", - "span": { + "span": Span { "end": 8, + "file": { + "content": "function hello() = ;", + }, "start": 0, }, }, { "ident": "hello", "kind": "identifier", - "span": { + "span": Span { "end": 14, + "file": { + "content": "function hello() = ;", + }, "start": 9, }, }, { "kind": "(", - "span": { + "span": Span { "end": 15, + "file": { + "content": "function hello() = ;", + }, "start": 14, }, }, { "kind": ")", - "span": { + "span": Span { "end": 16, + "file": { + "content": "function hello() = ;", + }, "start": 15, }, }, { "kind": "=", - "span": { + "span": Span { "end": 18, + "file": { + "content": "function hello() = ;", + }, "start": 17, }, }, { "kind": ";", - "span": { + "span": Span { "end": 20, + "file": { + "content": "function hello() = ;", + }, "start": 19, }, }, @@ -53,30 +71,42 @@ exports[`should tokenize hello world 1`] = ` { "ident": "print", "kind": "identifier", - "span": { + "span": Span { "end": 5, + "file": { + "content": "print("hello world")", + }, "start": 0, }, }, { "kind": "(", - "span": { + "span": Span { "end": 6, + "file": { + "content": "print("hello world")", + }, "start": 5, }, }, { "kind": "lit_string", - "span": { + "span": Span { "end": 19, + "file": { + "content": "print("hello world")", + }, "start": 6, }, "value": "hello world", }, { "kind": ")", - "span": { + "span": Span { "end": 20, + "file": { + "content": "print("hello world")", + }, "start": 19, }, }, diff --git a/src/error.test.ts b/src/error.test.ts index 5b7dc05..161aa56 100644 --- a/src/error.test.ts +++ b/src/error.test.ts @@ -3,7 +3,7 @@ import { lines } from "./error"; it("should extract lines correctly", () => { const input = "AAA\nmeow\n:3\n\n"; - const lineSpans = lines(input); + const lineSpans = lines({ content: input }); const lineContents = lineSpans.map(({ start, end }) => input.slice(start, end) );