diff --git a/src/__snapshots__/lexer.test.ts.snap b/src/__snapshots__/lexer.test.ts.snap deleted file mode 100644 index 54e3f64..0000000 --- a/src/__snapshots__/lexer.test.ts.snap +++ /dev/null @@ -1,114 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should tokenize an emtpy function 1`] = ` -[ - { - "kind": "function", - "span": Span { - "end": 8, - "file": { - "content": "function hello() = ;", - }, - "start": 0, - }, - }, - { - "ident": "hello", - "kind": "identifier", - "span": Span { - "end": 14, - "file": { - "content": "function hello() = ;", - }, - "start": 9, - }, - }, - { - "kind": "(", - "span": Span { - "end": 15, - "file": { - "content": "function hello() = ;", - }, - "start": 14, - }, - }, - { - "kind": ")", - "span": Span { - "end": 16, - "file": { - "content": "function hello() = ;", - }, - "start": 15, - }, - }, - { - "kind": "=", - "span": Span { - "end": 18, - "file": { - "content": "function hello() = ;", - }, - "start": 17, - }, - }, - { - "kind": ";", - "span": Span { - "end": 20, - "file": { - "content": "function hello() = ;", - }, - "start": 19, - }, - }, -] -`; - -exports[`should tokenize hello world 1`] = ` -[ - { - "ident": "print", - "kind": "identifier", - "span": Span { - "end": 5, - "file": { - "content": "print("hello world")", - }, - "start": 0, - }, - }, - { - "kind": "(", - "span": Span { - "end": 6, - "file": { - "content": "print("hello world")", - }, - "start": 5, - }, - }, - { - "kind": "lit_string", - "span": Span { - "end": 19, - "file": { - "content": "print("hello world")", - }, - "start": 6, - }, - "value": "hello world", - }, - { - "kind": ")", - "span": Span { - "end": 20, - "file": { - "content": "print("hello world")", - }, - "start": 19, - }, - }, -] -`; diff --git a/src/lexer.test.ts b/src/lexer.test.ts index cac08d3..3bcedd3 100644 --- a/src/lexer.test.ts +++ b/src/lexer.test.ts @@ -7,7 +7,71 @@ it("should tokenize an emtpy function", () => { const tokens = tokenize(new ErrorHandler(false), { content: input }); if (!tokens.ok) unreachable("lexer error"); - expect(tokens.tokens).toMatchSnapshot(); + expect(tokens.tokens).toMatchInlineSnapshot(` + [ + { + "kind": "function", + "span": Span { + "end": 8, + "file": { + "content": "function hello() = ;", + }, + "start": 0, + }, + }, + { + "ident": "hello", + "kind": "identifier", + "span": Span { + "end": 14, + "file": { + "content": "function hello() = ;", + }, + "start": 9, + }, + }, + { + "kind": "(", + "span": Span { + "end": 15, + "file": { + "content": "function hello() = ;", + }, + "start": 14, + }, + }, + { + "kind": ")", + "span": Span { + "end": 16, + "file": { + "content": "function hello() = ;", + }, + "start": 15, + }, + }, + { + "kind": "=", + "span": Span { + "end": 18, + "file": { + "content": "function hello() = ;", + }, + "start": 17, + }, + }, + { + "kind": ";", + "span": Span { + "end": 20, + "file": { + "content": "function hello() = ;", + }, + "start": 19, + }, + }, + ] + `); }); it("should tokenize hello world", () => { @@ -16,5 +80,50 @@ it("should tokenize hello world", () => { const tokens = tokenize(new ErrorHandler(false), { content: input }); if (!tokens.ok) unreachable("lexer error"); - expect(tokens.tokens).toMatchSnapshot(); + expect(tokens.tokens).toMatchInlineSnapshot(` + [ + { + "ident": "print", + "kind": "identifier", + "span": Span { + "end": 5, + "file": { + "content": "print("hello world")", + }, + "start": 0, + }, + }, + { + "kind": "(", + "span": Span { + "end": 6, + "file": { + "content": "print("hello world")", + }, + "start": 5, + }, + }, + { + "kind": "lit_string", + "span": Span { + "end": 19, + "file": { + "content": "print("hello world")", + }, + "start": 6, + }, + "value": "hello world", + }, + { + "kind": ")", + "span": Span { + "end": 20, + "file": { + "content": "print("hello world")", + }, + "start": 19, + }, + }, + ] + `); }); diff --git a/ui-tests/resolve/module_not_found.stderr b/ui-tests/resolve/module_not_found.stderr index ffe3235..84e444b 100644 --- a/ui-tests/resolve/module_not_found.stderr +++ b/ui-tests/resolve/module_not_found.stderr @@ -1,4 +1,8 @@ -error: cannot find list +error: expected `=`, found `,` --> $DIR/module_not_found.nil:2 -2 | let _l = list.new(); - ^^^^ +2 | let _false, l = list.new(); + ^ +error: `main` function not found + --> $DIR/module_not_found.nil:1 +1 | function main() = ( + ^