From c0133101d79276ca781ef6c0cc5e3cfae9a2f6cb Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 4 Sep 2026 07:08:07 +0000 Subject: [PATCH] Add tests for lexPhrase utility Added missing unit tests for the lexPhrase utility function in lexer.ts. Covered scenarios for standard phrase splitting, empty strings, strings with extra spaces, and strings containing symbols. Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> --- src/engine/lexer.test.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/engine/lexer.test.ts b/src/engine/lexer.test.ts index 0fbdc80..bac420c 100644 --- a/src/engine/lexer.test.ts +++ b/src/engine/lexer.test.ts @@ -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"]); + }); + }); });