spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[FINV] Throws NUM error when parameter 1 is not within range
author
Ben Vogt <[email protected]>
date
2017-05-01 23:50:06
stats
2 file(s) changed, 6 insertions(+), 1 deletions(-)
files
src/Formulas/Statistical.ts
tests/Formulas/StatisticalTest.ts
 1diff --git a/src/Formulas/Statistical.ts b/src/Formulas/Statistical.ts
 2index f57a71a..593a019 100644
 3--- a/src/Formulas/Statistical.ts
 4+++ b/src/Formulas/Statistical.ts
 5@@ -688,7 +688,8 @@ var FINV = function (...values) : number {
 6   ArgsChecker.checkLength(values, 3);
 7   var probability = TypeCaster.firstValueAsNumber(values[0]);
 8   if (probability <= 0.0 || probability > 1.0) {
 9-    // TODO: Throw num error.
10+    throw new NumError("Function FINV parameter 1 value is " + probability
11+      + ". It should be greater than or equal to 0, and less than 1.")
12   }
13   var d1 = TypeCaster.firstValueAsNumber(values[1]);
14   var d2 = TypeCaster.firstValueAsNumber(values[2]);
15diff --git a/tests/Formulas/StatisticalTest.ts b/tests/Formulas/StatisticalTest.ts
16index 647f44f..32635bb 100644
17--- a/tests/Formulas/StatisticalTest.ts
18+++ b/tests/Formulas/StatisticalTest.ts
19@@ -241,6 +241,10 @@ test("EXPONDIST", function(){
20 // TODO: Test this more.
21 test("FINV", function(){
22   assertEquals(FINV(0.42, 2, 3), 1.174597274485816);
23+  assertEquals(FINV("0.42", 2, 3), 1.174597274485816);
24+  catchAndAssertEquals(function() {
25+    FINV(-10, 2, 3);
26+  }, ERRORS.NUM_ERROR);
27 });
28 
29