File was renamed from num-int/tests/numint/ExpressionTest.py |
| | |
| | | |
| | | def test_prio_product_exponent(self): |
| | | parser = Lark_StandAlone() |
| | | tree = parser.parse("x ^ -3 * sin(12)") # => (x^3) * sin(12) |
| | | tree = parser.parse("x ** -3 * sin(12)") # => (x^3) * sin(12) |
| | | print(tree.pretty()) |
| | | |
| | | def test_prio_product_exponent_revert(self): |
| | | parser = Lark_StandAlone() |
| | | tree = parser.parse("sin(12) * x ^ sqrt(4)") # => sin(12) * (x^sqrt(4)) |
| | | tree = parser.parse("sin(12) * x ** sqrt(4)") # => sin(12) * (x ** sqrt(4)) |
| | | print(tree.pretty()) |
| | | |
| | | def test_use_transform(self): |
| | | parser = Lark_StandAlone(transformer=ExpressionTransformer()) |
| | | tree = parser.parse("log(-12, 5) * x ^ sqrt(4)") # => sin(12) * (x^sqrt(4)) |
| | | tree = parser.parse("log(-12, 5) * x ** sqrt(4)") # => sin(12) * (x^sqrt(4)) |
| | | self.assertEqual(tree, 'math.log(-12, 5) * x ** math.sqrt(4)') |
| | | |
| | | print(tree) |