pmatrix/bmatrix/vmatrix LaTeX command support
This commit is contained in:
@@ -2344,19 +2344,46 @@ final class MTMathListBuilderTests: XCTestCase {
|
||||
let testCases = [
|
||||
("\\begin{pmatrix*}[r] 1 & 2 \\\\ 3 & 4 \\end{pmatrix*}", "pmatrix* right align"),
|
||||
("\\begin{bmatrix*}[l] a & b \\\\ c & d \\end{bmatrix*}", "bmatrix* left align"),
|
||||
("\\begin{vmatrix*}[c] x & y \\\\ z & w \\end{vmatrix*}", "vmatrix* center align")
|
||||
("\\begin{vmatrix*}[c] x & y \\\\ z & w \\end{vmatrix*}", "vmatrix* center align"),
|
||||
("\\begin{matrix*}[r] 10 & 20 \\\\ 30 & 40 \\end{matrix*}", "matrix* right align (no delimiters)")
|
||||
]
|
||||
|
||||
for (latex, desc) in testCases {
|
||||
print("Testing: \(desc)")
|
||||
print(" LaTeX: \(latex)")
|
||||
var error: NSError? = nil
|
||||
let list = MTMathListBuilder.build(fromString: latex, error: &error)
|
||||
|
||||
if list == nil || error != nil {
|
||||
throw XCTSkip("Starred matrix environments (*matrix*) not implemented: \(desc). Error: \(error?.localizedDescription ?? "nil result")")
|
||||
if let err = error {
|
||||
print(" ERROR: \(err.localizedDescription)")
|
||||
} else if list == nil {
|
||||
print(" List is nil but no error")
|
||||
} else {
|
||||
print(" SUCCESS: Got \(list!.atoms.count) atoms")
|
||||
}
|
||||
|
||||
let unwrappedList = try XCTUnwrap(list, "Should parse: \(desc)")
|
||||
XCTAssertNil(error, "Should not error on \(desc): \(error?.localizedDescription ?? "")")
|
||||
XCTAssertTrue(unwrappedList.atoms.count >= 1, "\(desc) should have atoms")
|
||||
|
||||
// Verify we have a table structure
|
||||
var foundTable = false
|
||||
for atom in unwrappedList.atoms {
|
||||
if atom.type == .table {
|
||||
foundTable = true
|
||||
break
|
||||
}
|
||||
// Check inside inner atoms (for matrices with delimiters)
|
||||
if atom.type == .inner, let inner = atom as? MTInner, let innerList = inner.innerList {
|
||||
for innerAtom in innerList.atoms {
|
||||
if innerAtom.type == .table {
|
||||
foundTable = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
XCTAssertTrue(foundTable, "\(desc) should contain a table structure")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user