mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-14 16:35:03 +01:00
adjust tests
This commit is contained in:
parent
8b33910aec
commit
f2a5896b9d
3 changed files with 118 additions and 119 deletions
|
|
@ -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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
`;
|
|
||||||
|
|
@ -7,7 +7,71 @@ it("should tokenize an emtpy function", () => {
|
||||||
const tokens = tokenize(new ErrorHandler(false), { content: input });
|
const tokens = tokenize(new ErrorHandler(false), { content: input });
|
||||||
if (!tokens.ok) unreachable("lexer error");
|
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", () => {
|
it("should tokenize hello world", () => {
|
||||||
|
|
@ -16,5 +80,50 @@ it("should tokenize hello world", () => {
|
||||||
const tokens = tokenize(new ErrorHandler(false), { content: input });
|
const tokens = tokenize(new ErrorHandler(false), { content: input });
|
||||||
if (!tokens.ok) unreachable("lexer error");
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
`);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
error: cannot find list
|
error: expected `=`, found `,`
|
||||||
--> $DIR/module_not_found.nil:2
|
--> $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() = (
|
||||||
|
^
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue