def test_vertial_input_is_delimiter_opening(self): data = EquationData(r"""\[\int_{a}^{b}{x^2}{\delta x}\]""") mathNode = data.findMathNode() stack = [] nextNode = data.getNodeAt(mathNode, 0) res, remaining = data.buildNode(nextNode, None, None, None) nextNode = data.getNodeAt(mathNode, 1) node, remaining = data.buildNode(nextNode, None, None, None) data.addToStack(stack, res, node) self.assertFalse(node.isOpeningDelimeter(), "latex vertical is an opening delimeter")
def test_LeftParanMacro(self): data = EquationData(r"""\[\lparen\]""") mathNode = data.findMathNode() nextNode = data.getNodeAt(mathNode, 0) res, _ = data.buildNode(nextNode) self.assertIsNotNone(res, "Build node should return a node") self.assertEqual(res.getTokenType(), TokenType.T_LPAR)
def test_delta(self): data = EquationData(r"""\[\delta\]""") mathNode = data.findMathNode() nextNode = data.getNodeAt(mathNode, 0) res, _ = data.buildNode(nextNode) self.assertIsNotNone(res, "Build node should return a node") self.assertEqual(res.getTokenType(), TokenType.T_DELTA)
def test_power_with_func(self): data = EquationData(r"""\[{a}^{b}\]""") mathNode = data.findMathNode() nextNode = data.getNodeAt(mathNode, 1) res, _ = data.buildNode(nextNode) self.assertIsNotNone(res, "Build node should return a node") self.assertEqual(res.getTokenType(), TokenType.T_POWER)
def test_GROUP_with_func(self): data = EquationData(r"""\[\int_{a}^{b}{x^2}{\delta x}\]""") mathNode = data.findMathNode() nextNode = data.getNodeAt(mathNode, 2) res, _ = data.buildNode(nextNode) self.assertIsNotNone(res, "Build node should return a node") self.assertEqual(res.getTokenType(), TokenType.T_VARIABLE)
def test_vertial_input_is_closing(self): data = EquationData(r"""\[\int_{a+1}^{b}{{x+1}^{2c}}{\delta x}\]""") mathNode = data.findMathNode() nextNode = data.getNodeAt(mathNode, 1) res, remaining = data.buildNode(nextNode, None, None, None) self.assertEqual(res.getTokenType(), TokenType.S_VERTICAL) self.assertFalse(res.isClosing())
def test_integral_is_not_closing_empty(self): data = EquationData(r"""\[\int_{a+1}^{b}{{x+1}^{2c}}{\delta x}\]""") # \int_{a+1}^{b}{{x+1}^{2c}+x^{2c}}{\delta x} mathNode = data.findMathNode() nextNode = data.getNodeAt(mathNode, 0) res, remaining = data.buildNode(nextNode, None, None, None) self.assertFalse(res.isClosing())
def test_integral_is_delimiter(self): data = EquationData(r"""\[\int_{a}^{b}{x^2}{\delta x}\]""") mathNode = data.findMathNode() nextNode = data.getNodeAt(mathNode, 0) res, remaining = data.buildNode(nextNode, None, None, None) self.assertFalse(res.isDelimiter(), "an integral is not a delimiter in an empty stack")
def test_if_integral_is_full(self): data = EquationData(r"""\[\int_{a}^{b}{x^2}{\delta x}\]""") mathNode = data.findMathNode() stack = [] nextNode = data.getNodeAt(mathNode, 0) res, remaining = data.buildNode(nextNode, None, None, None) self.assertFalse(res.isClosing(), "latex vertical is an opening delimeter")
def test_avaraible_returns(self): data = EquationData(r"""\[a\]""") mathNode = data.findMathNode() nextNode = data.getNodeAt(mathNode, 0) res, _ = data.buildNode(nextNode, None, None, None) self.assertEqual(res.getTokenType(), TokenType.T_VARIABLE) self.assertTrue(res.isClosing()) self.assertFalse(res.lookAhead()) self.assertFalse(res.lookBehind())