Skip to content

Commit

Permalink
test(parser): Added parser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasBoda committed Jan 4, 2024
1 parent e0f75cf commit 69dd62f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/parser.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, test } from "bun:test";
import { getProgram } from "./utils";
import { ObjectDeclaration, VariableDeclaration } from "../src";

describe("Parser", () => {

test("should return empty program on empty source code", () => {
const code = "";
const program = getProgram(code);

expect(program).toEqual({
type: "Program",
body: [],
position: {
line: 0,
character: 0
}
});
});

test("should parse object declaration", () => {
const code = "agent person 10 {}";
const program = getProgram(code);
expect(program.body).toHaveLength(1);
});

test("should parse multiple object declarations", () => {
const code = "agent person 10 {} agent building 5 {}";
const program = getProgram(code);
expect(program.body).toHaveLength(2);
});
});

0 comments on commit 69dd62f

Please sign in to comment.