19use PHPUnit\Framework\TestCase;
20use SebastianBergmann\Diff\Differ;
21use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder;
36 protected function setUp(): void
53 $differ =
new Differ(
new UnifiedDiffOutputBuilder(
"\n--- Expected\n+++ Actual\n"));
56 $this->assertTrue($actual == $expected, $differ->diff($actual, $expected));
62 public function testAdd(
string $a,
string $b,
string $result,
int $scale): void
70 public function testSub(
string $a,
string $b,
string $result,
int $scale): void
78 public function testMul(
string $a,
string $b,
string $result,
int $scale): void
86 public function testDiv(
string $a,
string $b,
string $result,
int $scale): void
94 public function testSqrt(
string $a,
string $result, ?
int $scale): void
102 public function testPow(
string $a,
string $b,
string $result, ?
int $scale): void
111 public function testMod(
string $a,
string $b,
string $result): void
119 public function testEquals(
string $a,
string $b,
bool $result, ?
int $scale): void
129 $this->
assertEqualNumbers($result, ilMath::_applyScale($this->evalMath->evaluate($formula), $scale));
137 $this->expectException(ilMathDivisionByZeroException::class);
139 $this->mathAdapter->div(1, 0);
147 $this->expectException(ilMathDivisionByZeroException::class);
149 $this->mathAdapter->mod(1, 0);
214 [
'12345678901234567890',
'3513641828',
null],
215 [
'12345678901234567890',
'3513641828.82', 2]
235 [
'3',
'3',
true,
null],
236 [
'27.424',
'27.424',
true, 5]
250 [
'13/60',
'0.2166666666666', 13],
253 [
'(-(-41)-sqrt((-41)^2-4*(1)*(5)))/(2*(1))',
'0.122', 3],
254 [
'(-(-41)+sqrt((-41)^2-4*(1)*(5)))/(2*(1))',
'40.877', 3],
assertEqualNumbers(string $actual, string $expected)
This method is used as a 'Comparator' for two numeric strings and is equal to the ScalarComparator be...
ilMathAdapter $mathAdapter
testCalculation(string $formula, string $result, int $scale)
@dataProvider calcData
testMul(string $a, string $b, string $result, int $scale)
@dataProvider mulData
testAdd(string $a, string $b, string $result, int $scale)
@dataProvider addData
testPow(string $a, string $b, string $result, ?int $scale)
@dataProvider powData
testDiv(string $a, string $b, string $result, int $scale)
@dataProvider divData
testMod(string $a, string $b, string $result)
@dataProvider modData
testSub(string $a, string $b, string $result, int $scale)
@dataProvider subData
testEquals(string $a, string $b, bool $result, ?int $scale)
@dataProvider equalsData
testSqrt(string $a, string $result, ?int $scale)
@dataProvider sqrtData
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