mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'MDL-29173_calc' of git://github.com/andyjdavis/moodle
This commit is contained in:
commit
6f337ea935
2 changed files with 18 additions and 1 deletions
|
@ -142,6 +142,10 @@ class mathsslib_testcase extends basic_testcase {
|
|||
}
|
||||
|
||||
public function test_rounding_function() {
|
||||
|
||||
// Rounding to the default number of decimal places
|
||||
// The default == 0
|
||||
|
||||
$formula = new calc_formula('=round(2.5)');
|
||||
$this->assertEquals($formula->evaluate(), 3);
|
||||
|
||||
|
@ -196,6 +200,19 @@ class mathsslib_testcase extends basic_testcase {
|
|||
$formula = new calc_formula('=floor(-2.5)');
|
||||
$this->assertEquals($formula->evaluate(), -3);
|
||||
|
||||
// Rounding to an explicit number of decimal places
|
||||
|
||||
$formula = new calc_formula('=round(2.5, 1)');
|
||||
$this->assertEquals($formula->evaluate(), 2.5);
|
||||
|
||||
$formula = new calc_formula('=round(2.5, 0)');
|
||||
$this->assertEquals($formula->evaluate(), 3);
|
||||
|
||||
$formula = new calc_formula('=round(1.2345, 2)');
|
||||
$this->assertEquals($formula->evaluate(), 1.23);
|
||||
|
||||
$formula = new calc_formula('=round(123.456, -1)');
|
||||
$this->assertEquals($formula->evaluate(), 120);
|
||||
}
|
||||
|
||||
public function test_scientific_notation() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue