27 require_once
'Services/Math/classes/class.ilMath.php';
28 require_once
'Services/Math/classes/class.EvalMath.php';
40 $this->assertEquals(
$result, $this->mathAdapter->add($a, $b, $scale));
48 $this->assertEquals(
$result, $this->mathAdapter->sub($a, $b, $scale));
56 $this->assertEquals(
$result, $this->mathAdapter->mul($a, $b, $scale));
64 $this->assertEquals(
$result, $this->mathAdapter->div($a, $b, $scale));
72 $this->assertEquals(
$result, $this->mathAdapter->sqrt($a, $scale));
80 $this->assertEquals(
$result, $this->mathAdapter->pow($a, $b, $scale));
88 $this->assertEquals(
$result, $this->mathAdapter->mod($a, $b));
96 $this->assertEquals(
$result, $this->mathAdapter->equals($a, $b, $scale));
104 $this->assertEquals(
$result, ilMath::_applyScale($this->evalMath->evaluate($formula), $scale));
112 $this->setExpectedException(ilMathDivisionByZeroException::class);
114 $this->mathAdapter->div(1, 0);
122 $this->setExpectedException(ilMathDivisionByZeroException::class);
124 $this->mathAdapter->mod(1, 0);
133 [
'1',
'2',
'3', self::DEFAULT_SCALE]
143 [
'1',
'2',
'-1', self::DEFAULT_SCALE]
153 [
'1',
'2',
'2', self::DEFAULT_SCALE],
154 [
'1',
'',
'0', self::DEFAULT_SCALE]
164 [
'1',
'2',
'0.5', self::DEFAULT_SCALE],
165 [
'',
'2',
'0', self::DEFAULT_SCALE],
185 [
'9',
'3', self::DEFAULT_SCALE],
186 [
'4294967296',
'65536', self::DEFAULT_SCALE],
187 [
'12345678901234567890',
'3513641828', null],
188 [
'12345678901234567890',
'3513641828.82', 2]
198 [
'3',
'2',
'9', self::DEFAULT_SCALE]
208 [
'3',
'3',
true, null],
209 [
'27.424',
'27.424',
true, 5]
219 [
'3+5',
'8', self::DEFAULT_SCALE],
220 [
'-3+5',
'2', self::DEFAULT_SCALE],
221 [
'3*6+5',
'23', self::DEFAULT_SCALE],
222 [
'10/2',
'5', self::DEFAULT_SCALE],
223 [
'13/60',
'0.2166666666666', 13],
224 [
'(-(-8)-sqrt((-8)^2-4*(7)))/(2)',
'1', self::DEFAULT_SCALE],
225 [
'(-(-8)+sqrt((-8)^2-4*(7)))/(2)',
'7', self::DEFAULT_SCALE],
226 [
'(-(-41)-sqrt((-41)^2-4*(1)*(5)))/(2*(1))',
'0.122', 3],
227 [
'(-(-41)+sqrt((-41)^2-4*(1)*(5)))/(2*(1))',
'40.877', 3],
228 [
'4^2-2*4+0.5*-16',
'0', self::DEFAULT_SCALE],
229 [
'-2^2-2*-2+0.5*-16',
'-8', self::DEFAULT_SCALE]
testAdd($a, $b, $result, $scale)
addData
testMul($a, $b, $result, $scale)
mulData
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
testMod($a, $b, $result)
modData
testCalculation($formula, $result, $scale)
calcData
testPow($a, $b, $result, $scale)
powData