This commit is contained in:
Andrew Pimenov 2026-09-04 10:08:11 +03:00 • committed by GitHub
commit 519a64b6b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
import { lexLine } from "./lexer";
import { lexLine, lexPhrase } from "./lexer";
import { Decimal } from "./types";
describe("lexer", () => {
@ -110,4 +110,22 @@ describe("lexer", () => {
]);
});
});
describe("lexPhrase", () => {
it("should split a phrase into raw strings", () => {
expect(lexPhrase("meters per second")).toEqual(["meters", "per", "second"]);
});
it("should handle empty strings", () => {
expect(lexPhrase("")).toEqual([]);
});
it("should ignore extra spaces", () => {
expect(lexPhrase(" meters per second ")).toEqual(["meters", "per", "second"]);
});
it("should handle symbols correctly", () => {
expect(lexPhrase("meters / second")).toEqual(["meters", "/", "second"]);
});
});
});