Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 29... Línea 29...
29
 *
29
 *
30
 * @package    qtype_calculated
30
 * @package    qtype_calculated
31
 * @copyright  2011 The Open University
31
 * @copyright  2011 The Open University
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
33
 */
34
class variablesubstituter_test extends \advanced_testcase {
34
final class variablesubstituter_test extends \advanced_testcase {
35
    public function test_simple_expression(): void {
35
    public function test_simple_expression(): void {
36
        $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.');
36
        $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.');
37
        $this->assertEquals(3, $vs->calculate('{a} + {b}'));
37
        $this->assertEquals(3, $vs->calculate('{a} + {b}'));
38
    }
38
    }
Línea 58... Línea 58...
58
        $this->expectException(\moodle_exception::class);
58
        $this->expectException(\moodle_exception::class);
59
        $vs->calculate('{a}{b}'); // Have to make sure this does not just evaluate to 12.
59
        $vs->calculate('{a}{b}'); // Have to make sure this does not just evaluate to 12.
60
    }
60
    }
Línea 61... Línea 61...
61
 
61
 
62
    public function test_division_by_zero_expression(): void {
-
 
63
 
-
 
64
        if (intval(PHP_VERSION) < 7) {
-
 
65
            $this->markTestSkipped('Division by zero triggers a PHP warning before PHP 7.');
-
 
66
        }
-
 
67
 
62
    public function test_division_by_zero_expression(): void {
68
        $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 0), '.');
63
        $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 0), '.');
69
        $this->expectException(\moodle_exception::class);
64
        $this->expectException(\moodle_exception::class);
70
        $vs->calculate('{a} / {b}');
65
        $vs->calculate('{a} / {b}');