Fix boundary handling in Parser and update tests for empty cases
This commit is contained in:
@@ -764,6 +764,12 @@ extension Math {
|
|||||||
// reinstate the old inner atom.
|
// reinstate the old inner atom.
|
||||||
let newInner = currentInnerAtom
|
let newInner = currentInnerAtom
|
||||||
currentInnerAtom = oldInner
|
currentInnerAtom = oldInner
|
||||||
|
if newInner?.leftBoundary?.nucleus.isEmpty == true {
|
||||||
|
newInner?.leftBoundary = nil
|
||||||
|
}
|
||||||
|
if newInner?.rightBoundary?.nucleus.isEmpty == true {
|
||||||
|
newInner?.rightBoundary = nil
|
||||||
|
}
|
||||||
return newInner
|
return newInner
|
||||||
} else if command == "overline" {
|
} else if command == "overline" {
|
||||||
// The overline command has 1 arguments
|
// The overline command has 1 arguments
|
||||||
@@ -1162,6 +1168,12 @@ extension Math {
|
|||||||
}
|
}
|
||||||
let newInner = self.currentInnerAtom
|
let newInner = self.currentInnerAtom
|
||||||
currentInnerAtom = oldInner
|
currentInnerAtom = oldInner
|
||||||
|
if newInner?.leftBoundary?.nucleus.isEmpty == true {
|
||||||
|
newInner?.leftBoundary = nil
|
||||||
|
}
|
||||||
|
if newInner?.rightBoundary?.nucleus.isEmpty == true {
|
||||||
|
newInner?.rightBoundary = nil
|
||||||
|
}
|
||||||
return newInner
|
return newInner
|
||||||
} else if command == "overline" {
|
} else if command == "overline" {
|
||||||
let over = Overline()
|
let over = Overline()
|
||||||
|
|||||||
@@ -594,13 +594,21 @@ struct ParserTests {
|
|||||||
let innerList = try #require(inner.innerList)
|
let innerList = try #require(inner.innerList)
|
||||||
checkAtomTypes(innerList, types: testCase.type2)
|
checkAtomTypes(innerList, types: testCase.type2)
|
||||||
|
|
||||||
|
if testCase.left.isEmpty {
|
||||||
|
#expect(inner.leftBoundary == nil)
|
||||||
|
} else {
|
||||||
let leftBoundary = try #require(inner.leftBoundary)
|
let leftBoundary = try #require(inner.leftBoundary)
|
||||||
#expect(leftBoundary.type == .boundary)
|
#expect(leftBoundary.type == .boundary)
|
||||||
#expect(leftBoundary.nucleus == testCase.left)
|
#expect(leftBoundary.nucleus == testCase.left)
|
||||||
|
}
|
||||||
|
|
||||||
|
if testCase.right.isEmpty {
|
||||||
|
#expect(inner.rightBoundary == nil)
|
||||||
|
} else {
|
||||||
let rightBoundary = try #require(inner.rightBoundary)
|
let rightBoundary = try #require(inner.rightBoundary)
|
||||||
#expect(rightBoundary.type == .boundary)
|
#expect(rightBoundary.type == .boundary)
|
||||||
#expect(rightBoundary.nucleus == testCase.right)
|
#expect(rightBoundary.nucleus == testCase.right)
|
||||||
|
}
|
||||||
|
|
||||||
// convert it back to latex
|
// convert it back to latex
|
||||||
let latex = Math.Parser.atomListToString(list)
|
let latex = Math.Parser.atomListToString(list)
|
||||||
|
|||||||
Reference in New Issue
Block a user