commit
message
Fixing TAN formula to function properly for PI value
author
Ben Vogt <[email protected]>
date
2017-01-08 21:29:36
stats
2 file(s) changed,
7 insertions(+),
2 deletions(-)
files
src/SupportedFormulas.ts
tests/SheetFormulaTest.ts
1diff --git a/src/SupportedFormulas.ts b/src/SupportedFormulas.ts
2index f53d212..098a593 100644
3--- a/src/SupportedFormulas.ts
4+++ b/src/SupportedFormulas.ts
5@@ -36,6 +36,9 @@ const OverrideFormulas = {
6 },
7 SIN: function (rad) {
8 return rad === Math.PI ? 0 : Math.sin(rad);
9+ },
10+ TAN: function (rad) {
11+ return rad === Math.PI ? 0 : Math.tan(rad);
12 }
13 };
14
15diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
16index f5f9520..9f75d8d 100644
17--- a/tests/SheetFormulaTest.ts
18+++ b/tests/SheetFormulaTest.ts
19@@ -445,8 +445,10 @@ testFormula('=SUMX2MY2([1, 5, 10], [1, 5, 10])', 0);
20 // testFormulaWithDependencies('=SUMX2PY2(B1:B3, C1:C3)', 0, [["B1", "1"], ["B2", "5"], ["B3", "10"], ["C1", "1"], ["C2", "5"], ["C3", "10"]]);
21
22 // Test TAN
23-// TODO: This should work.
24-// testFormula('=TAN(PI())', 0);
25+testFormula('=TAN(0)', 0);
26+testFormula('=TAN(1)', 1.5574077246549023);
27+testFormula('=TAN(PI() / 2)', 16331239353195370);
28+testFormula('=TAN(PI())', 0);
29
30 // Test TANH
31 testFormula('=TANH(PI())', 0.99627207622075);