Unhappy path unit tests (#1814)
* Unhappy path unit tests * Fix unhappy error for BETADIST and BETAINV min/max range
This commit is contained in:
parent
4092da0525
commit
80155cf26a
|
|
@ -765,14 +765,14 @@ class Statistical
|
||||||
$rMax = Functions::flattenSingleValue($rMax);
|
$rMax = Functions::flattenSingleValue($rMax);
|
||||||
|
|
||||||
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
|
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
|
||||||
if (($value < $rMin) || ($value > $rMax) || ($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax)) {
|
|
||||||
return Functions::NAN();
|
|
||||||
}
|
|
||||||
if ($rMin > $rMax) {
|
if ($rMin > $rMax) {
|
||||||
$tmp = $rMin;
|
$tmp = $rMin;
|
||||||
$rMin = $rMax;
|
$rMin = $rMax;
|
||||||
$rMax = $tmp;
|
$rMax = $tmp;
|
||||||
}
|
}
|
||||||
|
if (($value < $rMin) || ($value > $rMax) || ($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax)) {
|
||||||
|
return Functions::NAN();
|
||||||
|
}
|
||||||
$value -= $rMin;
|
$value -= $rMin;
|
||||||
$value /= ($rMax - $rMin);
|
$value /= ($rMax - $rMin);
|
||||||
|
|
||||||
|
|
@ -804,14 +804,14 @@ class Statistical
|
||||||
$rMax = Functions::flattenSingleValue($rMax);
|
$rMax = Functions::flattenSingleValue($rMax);
|
||||||
|
|
||||||
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
|
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
|
||||||
if (($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax) || ($probability <= 0) || ($probability > 1)) {
|
|
||||||
return Functions::NAN();
|
|
||||||
}
|
|
||||||
if ($rMin > $rMax) {
|
if ($rMin > $rMax) {
|
||||||
$tmp = $rMin;
|
$tmp = $rMin;
|
||||||
$rMin = $rMax;
|
$rMin = $rMax;
|
||||||
$rMax = $tmp;
|
$rMax = $tmp;
|
||||||
}
|
}
|
||||||
|
if (($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax) || ($probability <= 0) || ($probability > 1)) {
|
||||||
|
return Functions::NAN();
|
||||||
|
}
|
||||||
$a = 0;
|
$a = 0;
|
||||||
$b = 2;
|
$b = 2;
|
||||||
|
|
||||||
|
|
@ -3000,11 +3000,11 @@ class Statistical
|
||||||
public static function QUARTILE(...$args)
|
public static function QUARTILE(...$args)
|
||||||
{
|
{
|
||||||
$aArgs = Functions::flattenArray($args);
|
$aArgs = Functions::flattenArray($args);
|
||||||
|
$entry = array_pop($aArgs);
|
||||||
|
|
||||||
// Calculate
|
// Calculate
|
||||||
$entry = floor(array_pop($aArgs));
|
|
||||||
|
|
||||||
if ((is_numeric($entry)) && (!is_string($entry))) {
|
if ((is_numeric($entry)) && (!is_string($entry))) {
|
||||||
|
$entry = floor($entry);
|
||||||
$entry /= 4;
|
$entry /= 4;
|
||||||
if (($entry < 0) || ($entry > 1)) {
|
if (($entry < 0) || ($entry > 1)) {
|
||||||
return Functions::NAN();
|
return Functions::NAN();
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@ return [
|
||||||
0.960370937542,
|
0.960370937542,
|
||||||
3, 7.5, 9, 1, 4,
|
3, 7.5, 9, 1, 4,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
0.960370937542,
|
||||||
|
3, 7.5, 9, 4, 1,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
0.598190307617,
|
0.598190307617,
|
||||||
7.5, 8, 9, 5, 10,
|
7.5, 8, 9, 5, 10,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ return [
|
||||||
2.164759759129,
|
2.164759759129,
|
||||||
0.3, 7.5, 9, 1, 4,
|
0.3, 7.5, 9, 1, 4,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
2.164759759129,
|
||||||
|
0.3, 7.5, 9, 4, 1,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
7.761240188783,
|
7.761240188783,
|
||||||
0.75, 8, 9, 5, 10,
|
0.75, 8, 9, 5, 10,
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,12 @@ return [
|
||||||
48.4,
|
48.4,
|
||||||
[10.5, 7.2, 200, 5.4, 8.1, 0.8],
|
[10.5, 7.2, 200, 5.4, 8.1, 0.8],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'#NUM!',
|
||||||
|
[1, 2, 3, 4, -0.3],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'#VALUE!',
|
||||||
|
[1, 2, 3, 4, 'NaN'],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -49,4 +49,20 @@ return [
|
||||||
[13, 12, 11, 8, 4, 3, 2, 1, 1, 1],
|
[13, 12, 11, 8, 4, 3, 2, 1, 1, 1],
|
||||||
5,
|
5,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
0.67,
|
||||||
|
[1, 'Deux', 2, 'Uno', 3, 4],
|
||||||
|
3,
|
||||||
|
2,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'#NUM!',
|
||||||
|
['A', 'B', 'C', 'D'],
|
||||||
|
'E',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'#N/A',
|
||||||
|
[1, 2, 3, 4],
|
||||||
|
5,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -37,4 +37,12 @@ return [
|
||||||
9.25,
|
9.25,
|
||||||
[7, 8, 9, 10, 3],
|
[7, 8, 9, 10, 3],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'#NUM!',
|
||||||
|
[7, 8, 9, 10, 5],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'#VALUE!',
|
||||||
|
[7, 8, 9, 10, 'X'],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -28,4 +28,14 @@ return [
|
||||||
7.2,
|
7.2,
|
||||||
[10.5, 7.2, 200, 5.4, 8.1],
|
[10.5, 7.2, 200, 5.4, 8.1],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
3,
|
||||||
|
3.5,
|
||||||
|
[7, 3.5, 'ONE', 'UNO', 3.5, 1, 2],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'#N/A',
|
||||||
|
1.5,
|
||||||
|
[7, 3.5, 3.5, 1, 2],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue