19use PHPUnit\Framework\TestCase;
34 protected function setUp(): void
54 sprintf(
"Failed asserting that '%s' is numerically equal to '%s'.", $actual, $expected)
58 #[\PHPUnit\Framework\Attributes\DataProvider('addData')]
59 public function testAdd(
string $a,
string $b,
string $result,
int $scale): void
64 #[\PHPUnit\Framework\Attributes\DataProvider('subData')]
65 public function testSub(
string $a,
string $b,
string $result,
int $scale): void
70 #[\PHPUnit\Framework\Attributes\DataProvider('mulData')]
71 public function testMul(
string $a,
string $b,
string $result,
int $scale): void
76 #[\PHPUnit\Framework\Attributes\DataProvider('divData')]
77 public function testDiv(
string $a,
string $b,
string $result,
int $scale): void
82 #[\PHPUnit\Framework\Attributes\DataProvider('sqrtData')]
83 public function testSqrt(
string $a,
string $result, ?
int $scale): void
88 #[\PHPUnit\Framework\Attributes\DataProvider('powData')]
89 public function testPow(
string $a,
string $b,
string $result, ?
int $scale): void
97 #[\PHPUnit\Framework\Attributes\DataProvider('modData')]
98 public function testMod(
string $a,
string $b,
string $result): void
103 #[\PHPUnit\Framework\Attributes\DataProvider('equalsData')]
104 public function testEquals(
string $a,
string $b,
bool $result, ?
int $scale): void
109 #[\PHPUnit\Framework\Attributes\DataProvider('calcData')]
112 $this->
assertEqualNumbers($result, ilMath::_applyScale($this->evalMath->evaluate($formula), $scale));
120 $this->expectException(ilMathDivisionByZeroException::class);
122 $this->mathAdapter->div(1, 0);
130 $this->expectException(ilMathDivisionByZeroException::class);
132 $this->mathAdapter->mod(1, 0);
197 [
'12345678901234567890',
'3513641828',
null],
198 [
'12345678901234567890',
'3513641828.82', 2]
218 [
'3',
'3',
true,
null],
219 [
'27.424',
'27.424',
true, 5]
233 [
'13/60',
'0.2166666666666', 13],
236 [
'(-(-41)-sqrt((-41)^2-4*(1)*(5)))/(2*(1))',
'0.122', 3],
237 [
'(-(-41)+sqrt((-41)^2-4*(1)*(5)))/(2*(1))',
'40.877', 3],
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testSub(string $a, string $b, string $result, int $scale)
testDiv(string $a, string $b, string $result, int $scale)
testSqrt(string $a, string $result, ?int $scale)
testAdd(string $a, string $b, string $result, int $scale)
testEquals(string $a, string $b, bool $result, ?int $scale)
testMod(string $a, string $b, string $result)
ilMathAdapter $mathAdapter
assertEqualNumbers(string $expected, string $actual)
This method is used as a 'Comparator' for two numeric strings and is equal to the ScalarComparator be...
testMul(string $a, string $b, string $result, int $scale)
testPow(string $a, string $b, string $result, ?int $scale)
testCalculation(string $formula, string $result, int $scale)
static setDefaultAdapter(ilMathAdapter $adapter)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples