diff options
author | Jean-Michel Vedrine <vedrine@vedrine.org> | 2018-01-01 19:10:49 +0100 |
---|---|---|
committer | Jean-Michel Vedrine <vedrine@vedrine.org> | 2018-01-01 19:10:49 +0100 |
commit | 294edec77a967e743631bfe2cde6b8ecc47b980c (patch) | |
tree | 992d1425dc9ccaaea338b8a43196a28e6f16b673 /tests/parser_test.php | |
parent | 256a9808276e420bc7ee6168f04ab31b6cfe4d44 (diff) |
Test multiplication display
Diffstat (limited to 'tests/parser_test.php')
-rw-r--r-- | tests/parser_test.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/parser_test.php b/tests/parser_test.php index 71a9d77..13dbe23 100644 --- a/tests/parser_test.php +++ b/tests/parser_test.php @@ -37,13 +37,29 @@ require_once($CFG->dirroot . '/question/type/algebra/parser.php'); */ class qtype_algebra_parser_test extends advanced_testcase { - + /** + * Test base elements of the parser + */ public function test_parser_vars_functions() { $p = new qtype_algebra_parser; $expr = $p->parse('sin(2x) + cos(3y)'); $this->assertEquals(array('x', 'y'), $expr->get_variables()); $this->assertEquals(array('sin', 'cos'), $expr->get_functions()); + $this->assertEquals('\sin \left( 2 x_{} \right) + \cos \left( 3 y_{} \right)', $expr->tex()); + } + + /** + * Test how various multiplications are displayed using TeX + */ + public function test_parser_multiply_display() { + $p = new qtype_algebra_parser; + + $expr = $p->parse('sin(2x) + cos(3y)'); $this->assertEquals('\sin \left( 2 x_{} \right) + \cos \left( 3 y_{} \right)', $expr->tex()); + $expr = $p->parse('sin(4 x) + cos(5 y)'); + $this->assertEquals('\sin \left( 4 x_{} \right) + \cos \left( 5 y_{} \right)', $expr->tex()); + $expr = $p->parse('sin(6*x) + cos(7*y)'); + $this->assertEquals('\sin \left( 6 x_{} \right) + \cos \left( 7 y_{} \right)', $expr->tex()); } } |