29 protected function setUp() : void
31 require_once
'Services/Math/classes/class.ilMath.php';
32 require_once
'Services/Math/classes/class.EvalMath.php';
49 $differ =
new Differ(
new UnifiedDiffOutputBuilder(
"\n--- Expected\n+++ Actual\n"));
51 $this->assertTrue($actual == $expected, $differ->diff($actual, $expected));
131 $this->expectException(ilMathDivisionByZeroException::class);
133 $this->mathAdapter->div(1, 0);
141 $this->expectException(ilMathDivisionByZeroException::class);
143 $this->mathAdapter->mod(1, 0);
152 [
'1',
'2',
'3', self::DEFAULT_SCALE]
162 [
'1',
'2',
'-1', self::DEFAULT_SCALE]
172 [
'1',
'2',
'2', self::DEFAULT_SCALE],
173 [
'1',
'',
'0', self::DEFAULT_SCALE]
183 [
'1',
'2',
'0.5', self::DEFAULT_SCALE],
184 [
'',
'2',
'0', self::DEFAULT_SCALE],
204 [
'9',
'3', self::DEFAULT_SCALE],
205 [
'4294967296',
'65536', self::DEFAULT_SCALE],
206 [
'12345678901234567890',
'3513641828', null],
207 [
'12345678901234567890',
'3513641828.82', 2]
217 [
'3',
'2',
'9', self::DEFAULT_SCALE]
227 [
'3',
'3',
true, null],
228 [
'27.424',
'27.424',
true, 5]
238 [
'3+5',
'8', self::DEFAULT_SCALE],
239 [
'-3+5',
'2', self::DEFAULT_SCALE],
240 [
'3*6+5',
'23', self::DEFAULT_SCALE],
241 [
'10/2',
'5', self::DEFAULT_SCALE],
242 [
'13/60',
'0.2166666666666', 13],
243 [
'(-(-8)-sqrt((-8)^2-4*(7)))/(2)',
'1', self::DEFAULT_SCALE],
244 [
'(-(-8)+sqrt((-8)^2-4*(7)))/(2)',
'7', self::DEFAULT_SCALE],
245 [
'(-(-41)-sqrt((-41)^2-4*(1)*(5)))/(2*(1))',
'0.122', 3],
246 [
'(-(-41)+sqrt((-41)^2-4*(1)*(5)))/(2*(1))',
'40.877', 3],
247 [
'4^2-2*4+0.5*-16',
'0', self::DEFAULT_SCALE],
248 [
'-2^2-2*-2+0.5*-16',
'-8', self::DEFAULT_SCALE]
testAdd($a, $b, $result, $scale)
addData
testMul($a, $b, $result, $scale)
mulData
assertEqualNumbers(string $actual, string $expected)
This method is used as a 'Comparator' for two numeric strings and is equal to the ScalarComparator be...
testSub($a, $b, $result, $scale)
subData
testDiv($a, $b, $result, $scale)
divData
testSqrt($a, $result, $scale)
sqrtData
static setDefaultAdapter(ilMathAdapter $adapter)
testEquals($a, $b, $result, $scale)
equalsData
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
testMod($a, $b, $result)
modData
testCalculation($formula, $result, $scale)
calcData
testPow($a, $b, $result, $scale)
powData