$vs->calculate('{a}{b}'); // Have to make sure this does not just evaluate to 12.
}
+ public function test_division_by_zero_expression() {
+
+ if (intval(PHP_VERSION) < 7) {
+ $this->markTestSkipped('Division by zero triggers a PHP warning before PHP 7.');
+ }
+
+ $this->setExpectedException('moodle_exception');
+ $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 0), '.');
+ $vs->calculate('{a} / {b}');
+ }
+
public function test_replace_expressions_in_text_simple_var() {
$vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.');
$this->assertEquals('1 + 2', $vs->replace_expressions_in_text('{a} + {b}'));