commit
message
Formulas.ACOSH written and tested.
author
Ben Vogt <[email protected]>
date
2017-01-16 21:39:16
stats
2 file(s) changed,
25 insertions(+),
2 deletions(-)
files
src/RawFormulas.ts
tests/FormulasTest.ts
1diff --git a/src/RawFormulas.ts b/src/RawFormulas.ts
2index 24ed276..f9a645b 100644
3--- a/src/RawFormulas.ts
4+++ b/src/RawFormulas.ts
5@@ -117,7 +117,14 @@ var ACOS = function (value?) {
6 return Math.acos(value);
7 };
8
9-var ACOSH = Formula["ACOSH"];
10+var ACOSH = function (value?) {
11+ checkArgumentsLength(arguments, 1);
12+ value = valueToNumber(value);
13+ if (value < 1) {
14+ throw new CellError(ERRORS.NUM_ERROR, "Function ____ parameter 1 value is " + value + ". It should be greater than or equal to 1.");
15+ }
16+ return Math.log(value + Math.sqrt(value * value - 1));
17+};
18 var ACOTH = Formula["ACOTH"];
19 var AND = Formula["AND"];
20 var ARABIC = Formula["ARABIC"];
21diff --git a/tests/FormulasTest.ts b/tests/FormulasTest.ts
22index d0ef1c7..b639efa 100644
23--- a/tests/FormulasTest.ts
24+++ b/tests/FormulasTest.ts
25@@ -22,7 +22,7 @@ function catchAndAssertEquals(toExecute, expected) {
26 }
27 }
28
29-
30+// Test ABS
31 assertEquals(ABS(-10), 10);
32 assertEquals(ABS(-10.111), 10.111);
33 assertEquals(ABS(0), 0);
34@@ -36,10 +36,12 @@ catchAndAssertEquals(function() {
35 }, ERRORS.VALUE_ERROR);
36
37
38+// Test ACCRINT
39 // TODO: This formula doesn't work properly under some circumstances.
40 assertEquals(ACCRINT(DATE(2011, 1, 1), DATE(2011, 2, 1), DATE(2014, 7, 1), 0.1, 1000, 1, 0), 350);
41
42
43+// Test ACOS
44 assertEquals(ACOS(0), 1.5707963267948966);
45 assertEquals(ACOS(-1), 3.141592653589793);
46 assertEquals(ACOS(1), 0);
47@@ -53,7 +55,20 @@ catchAndAssertEquals(function() {
48 }, ERRORS.NUM_ERROR);
49
50
51+// Test ACOSH
52 assertEquals(ACOSH(22), 3.783672704329451);
53+assertEquals(ACOSH(1), 0);
54+assertEquals(ACOSH("11"), 3.0889699048446033);
55+catchAndAssertEquals(function() {
56+ return ACOSH(-1);
57+}, ERRORS.NUM_ERROR);
58+catchAndAssertEquals(function() {
59+ return ACOSH("str");
60+}, ERRORS.VALUE_ERROR);
61+catchAndAssertEquals(function() {
62+ return ACOSH(false);
63+}, ERRORS.NUM_ERROR);
64+
65
66 assertEquals(ACOTH(22), 0.04548588910286339);
67