thp-web/lexer/number_lexer.test.ts

20 lines
558 B
TypeScript
Raw Normal View History

2024-03-26 23:05:58 +00:00
import { expect, test, describe } from "bun:test";
2024-03-27 13:12:32 +00:00
import { scan_number } from "./number_lexer";
2024-03-26 23:05:58 +00:00
describe("Number Lexer", () => {
test("should return a whole number token", () => {
const code = "1";
2024-03-27 13:12:32 +00:00
const token = scan_number(code, 0);
2024-03-26 23:05:58 +00:00
expect(token).toEqual([{ v: "1", token_type: "number" }, 1]);
2024-03-26 23:05:58 +00:00
});
test("should return a whole number token pt 2", () => {
const code = "12345";
2024-03-27 13:12:32 +00:00
const token = scan_number(code, 0);
2024-03-26 23:05:58 +00:00
expect(token).toEqual([{ v: "12345", token_type: "number" }, 5]);
2024-03-26 23:05:58 +00:00
});
});