spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
Formulas.SINH written and tested.
author
Ben Vogt <[email protected]>
date
2017-01-31 14:19:57
stats
3 file(s) changed, 33 insertions(+), 2 deletions(-)
files
src/RawFormulas/RawFormulas.ts
tests/FormulasTest.ts
tests/SheetFormulaTest.ts
 1diff --git a/src/RawFormulas/RawFormulas.ts b/src/RawFormulas/RawFormulas.ts
 2index 1a88485..b0ddbf8 100644
 3--- a/src/RawFormulas/RawFormulas.ts
 4+++ b/src/RawFormulas/RawFormulas.ts
 5@@ -142,7 +142,19 @@ var SIN = function (...values) {
 6   return rad === Math.PI ? 0 : Math.sin(rad);
 7 };
 8 
 9-var SINH = Formula["SINH"];
10+/**
11+ * Returns the hyperbolic sine of any real number.
12+ * @param values[0] real number to find the hyperbolic sine of
13+ * @returns {number} hyperbolic sine
14+ * @constructor
15+ */
16+var SINH = function (...values) : number {
17+  checkArgumentsLength(values, 1);
18+  var rad = firstValueAsNumber(values[0]);
19+  return Math["sinh"](rad);
20+};
21+
22+
23 var SPLIT = Formula["SPLIT"];
24 var SQRT = Formula["SQRT"];
25 var SQRTPI = Formula["SQRTPI"];
26diff --git a/tests/FormulasTest.ts b/tests/FormulasTest.ts
27index d504414..1489069 100644
28--- a/tests/FormulasTest.ts
29+++ b/tests/FormulasTest.ts
30@@ -667,7 +667,23 @@ assertEquals(SIN([[1]]), 0.8414709848078965);
31 assertEquals(SIN([1, "str"]), 0.8414709848078965);
32 
33 
34-assertEquals(SINH(PI()), 11.548739357257752);
35+// Test SINH
36+assertEquals(SINH(PI()), 11.548739357257748);
37+assertEquals(SINH(1), 1.1752011936438014);
38+assertEquals(SINH(false), 0);
39+assertEquals(SINH(true), 1.1752011936438014);
40+assertEquals(SINH(""), 0);
41+assertEquals(SINH("0"), 0);
42+catchAndAssertEquals(function() {
43+  SINH("str");
44+}, ERRORS.VALUE_ERROR);
45+assertEquals(SINH([10]), 11013.232874703393);
46+assertEquals(SINH([[10]]), 11013.232874703393);
47+catchAndAssertEquals(function() {
48+  SIN([[]]);
49+}, ERRORS.REF_ERROR);
50+assertEquals(SINH([[10, "str"]]), 11013.232874703393);
51+
52 
53 assertArrayEquals(SPLIT("1,2,3", ",", true), [ '1', '2', '3' ]);
54 
55diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
56index 6de5fdd..fec6ebb 100644
57--- a/tests/SheetFormulaTest.ts
58+++ b/tests/SheetFormulaTest.ts
59@@ -426,7 +426,7 @@ testFormula('=SIN(PI())', 0);
60 
61 
62 // Test SINH
63-testFormula('=SINH(PI())', 11.548739357257752);
64+testFormula('=SINH(PI())', 11.548739357257748);
65 
66 // Test SPLIT
67 testFormulaToArray('=SPLIT("1,2,3", ",", TRUE)', [ '1', '2', '3' ]);