From 1091e9c83d65ab4a549aa31ac169016adcce08ed Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:35:49 +0000 Subject: [PATCH] Add array parser error tests Agent-Logs-Url: https://github.com/wesleyel/swiftui-math/sessions/56436444-e15b-4dd0-8a70-c87df1e3dc4e Co-authored-by: wesleyel <48174882+wesleyel@users.noreply.github.com> --- .../Internal/Syntax/ParserTests.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Tests/SwiftUIMathTests/Internal/Syntax/ParserTests.swift b/Tests/SwiftUIMathTests/Internal/Syntax/ParserTests.swift index 7f96821..cb37f17 100644 --- a/Tests/SwiftUIMathTests/Internal/Syntax/ParserTests.swift +++ b/Tests/SwiftUIMathTests/Internal/Syntax/ParserTests.swift @@ -1089,6 +1089,28 @@ struct ParserTests { #expect(latex.contains("\\right.")) } + @Test + func arrayRejectsInvalidColumnFormat() throws { + let str = "\\begin{array}{xyz}a\\end{array}" + var error: Math.ParserError? = nil + + let list = Math.Parser.build(fromString: str, error: &error) + + #expect(list == nil) + #expect(error?.code == .invalidEnvironment) + } + + @Test + func arrayRejectsTooFewColumnSpecifiers() throws { + let str = "\\begin{array}{l}a&b\\end{array}" + var error: Math.ParserError? = nil + + let list = Math.Parser.build(fromString: str, error: &error) + + #expect(list == nil) + #expect(error?.code == .invalidNumberOfColumns) + } + @Test func defaultTable() throws { let str = "x \\\\ y"