def test_a_plus_b_(self):
     data = EquationData(r"""\[a+b\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertEqual(res.getTokenType(), TokenType.T_PLUS)
     self.assertTrue(res.hasChild(LexicalRuleItem.K_LEFT))
     self.assertTrue(res.hasChild(LexicalRuleItem.K_RIGHT))
 def test_delta_with_respect_times_y(self):
     data = EquationData(r"""\[{\delta x}y\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertIsNotNone(res, "Build node should return a node")
     self.assertEqual(res.getTokenType(), TokenType.T_MULT)
     left = res.hasChild(LexicalRuleItem.K_LEFT)
     self.assertTrue(left)
 def test_buildTree_with_sin_number(self):
     data = EquationData(r"""\[\sin4\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertIsNotNone(res, "Build node should return a node")
     self.assertEqual(res.getTokenType(), TokenType.T_SIN)
     left = res.hasChild(LexicalRuleItem.K_PARAM1)
     self.assertTrue(left)
 def test_buildTree_with_expression(self):
     data = EquationData(r"""\[\cos\lparen4\rparen\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertIsNotNone(res, "Build node should return a node")
     self.assertEqual(res.getTokenType(), TokenType.T_COS)
     left = res.hasChild(LexicalRuleItem.K_PARAM1)
     self.assertTrue(left)
 def test_ab_multiply(self):
     data = EquationData(r"""\[ab\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertIsNotNone(res, "Build node should return a node")
     self.assertEqual(res.getTokenType(), TokenType.T_MULT)
     left = res.hasChild(LexicalRuleItem.K_LEFT)
     right = res.hasChild(LexicalRuleItem.K_RIGHT)
     self.assertTrue(left)
     self.assertTrue(right)
 def test_buildTree_with_double_parens_reversed_no_mutiply(self):
     data = EquationData(r"""\[{{4}}3\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertIsNotNone(res, "Build node should return a node")
     self.assertEqual(res.getTokenType(), TokenType.T_MULT)
     left = res.hasChild(LexicalRuleItem.K_LEFT)
     right = res.hasChild(LexicalRuleItem.K_RIGHT)
     self.assertTrue(left)
     self.assertTrue(right)
 def test_integral_with_func_2(self):
     data = EquationData(r"""\[\int_{a}^{b} {x^2}{\delta x}\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertIsNotNone(res, "Build node should return a node")
     self.assertEqual(res.getTokenType(), TokenType.T_INTEGRAL)
     self.assertEqual(
         res.getChild(LexicalRuleItem.K_MIDDLE).getTokenType(),
         TokenType.T_POWER)
     self.assertEqual(
         res.getChild(LexicalRuleItem.K_RANGE).getTokenType(),
         TokenType.S_VERTICAL)
 def test_P_y_P_times_delta_x(self):
     data = EquationData(r"""\[{\lparen y\rparen}{\delta x}\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertIsNotNone(res, "Build node should return a node")
     self.assertEqual(res.getTokenType(), TokenType.T_MULT)
     left = res.hasChild(LexicalRuleItem.K_LEFT)
     self.assertTrue(left)
     left = res.getChild(LexicalRuleItem.K_LEFT)
     self.assertEqual(left.getTokenType(), TokenType.T_VARIABLE)
     right = res.getChild(LexicalRuleItem.K_RIGHT)
     self.assertEqual(right.getTokenType(), TokenType.T_DELTA)
 def test_negative(self):
     data = EquationData(r"""\[-4\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertEqual(res.getTokenType(), TokenType.T_NUM)
     self.assertEqual(res.value, '-4')
示例#10
0
 def test_decimal0134(self):
     data = EquationData(r"""\[0.134\]""")
     mathNode = data.findMathNode()
     res = data.buildTree(mathNode)
     self.assertEqual(res.getTokenType(), TokenType.T_NUM)
     self.assertEqual(res.value, '0.134')