commit
message
[UPLUS] formula added and tested
author
Ben Vogt <[email protected]>
date
2017-06-13 01:47:11
stats
8 file(s) changed,
56 insertions(+),
6 deletions(-)
files
DOCS.md
TODO.md
dist/Formulas/AllFormulas.js
dist/Formulas/Math.js
src/Formulas/AllFormulas.ts
src/Formulas/Math.ts
tests/Formulas/MathTest.ts
tests/SheetFormulaTest.ts
1diff --git a/DOCS.md b/DOCS.md
2index 84099fe..df833c3 100644
3--- a/DOCS.md
4+++ b/DOCS.md
5@@ -1161,6 +1161,15 @@
6 @returns {number}
7 @constructor
8 ```
9+
10+### UPLUS
11+
12+```
13+ Returns a value, but does nothing to it. If given a range, will return first value.
14+@param value to return
15+@returns any value
16+@constructor
17+```
18 ## Statistical
19
20
21diff --git a/TODO.md b/TODO.md
22index 76be2b4..952fd62 100644
23--- a/TODO.md
24+++ b/TODO.md
25@@ -62,7 +62,6 @@ For example 64 tbs to a qt.
26 * SUBTOTAL
27 * UMINUS
28 * UNARY_PERCENT
29-* UPLUS
30 * TO_DATE - Contingent upon cells having display formats derived from type-hierarchy
31 * TO_DOLLARS - Contingent upon cells having display formats derived from type-hierarchy
32 * TO_PERCENT - Contingent upon cells having display formats derived from type-hierarchy
33diff --git a/dist/Formulas/AllFormulas.js b/dist/Formulas/AllFormulas.js
34index b04d472..f6fc9de 100644
35--- a/dist/Formulas/AllFormulas.js
36+++ b/dist/Formulas/AllFormulas.js
37@@ -69,6 +69,7 @@ exports.LCM = Math_1.LCM;
38 exports.GAMMALN = Math_1.GAMMALN;
39 exports.PRODUCT = Math_1.PRODUCT;
40 exports.QUOTIENT = Math_1.QUOTIENT;
41+exports.UPLUS = Math_1.UPLUS;
42 var Info_1 = require("./Info");
43 exports.NA = Info_1.NA;
44 var Lookup_1 = require("./Lookup");
45diff --git a/dist/Formulas/Math.js b/dist/Formulas/Math.js
46index 28b78b2..2692f47 100644
47--- a/dist/Formulas/Math.js
48+++ b/dist/Formulas/Math.js
49@@ -1259,3 +1259,14 @@ var QUOTIENT = function (dividend, divisor) {
50 return dv / ds;
51 };
52 exports.QUOTIENT = QUOTIENT;
53+/**
54+ * Returns a value, but does nothing to it. If given a range, will return first value.
55+ * @param value to return
56+ * @returns any value
57+ * @constructor
58+ */
59+var UPLUS = function (value) {
60+ ArgsChecker_1.ArgsChecker.checkLength(arguments, 1, "UPLUS");
61+ return TypeConverter_1.TypeConverter.firstValue(value);
62+};
63+exports.UPLUS = UPLUS;
64diff --git a/src/Formulas/AllFormulas.ts b/src/Formulas/AllFormulas.ts
65index 13337c9..b33390d 100644
66--- a/src/Formulas/AllFormulas.ts
67+++ b/src/Formulas/AllFormulas.ts
68@@ -66,7 +66,8 @@ import {
69 LCM,
70 GAMMALN,
71 PRODUCT,
72- QUOTIENT
73+ QUOTIENT,
74+ UPLUS
75 } from "./Math";
76 import {
77 NA
78@@ -315,5 +316,6 @@ export {
79 QUARTILE,
80 PERCENTILE,
81 PRODUCT,
82- QUOTIENT
83+ QUOTIENT,
84+ UPLUS
85 }
86\ No newline at end of file
87diff --git a/src/Formulas/Math.ts b/src/Formulas/Math.ts
88index 0afcf5e..a0421c3 100644
89--- a/src/Formulas/Math.ts
90+++ b/src/Formulas/Math.ts
91@@ -1269,6 +1269,18 @@ var QUOTIENT = function (dividend, divisor) {
92 };
93
94
95+/**
96+ * Returns a value, but does nothing to it. If given a range, will return first value.
97+ * @param value to return
98+ * @returns any value
99+ * @constructor
100+ */
101+var UPLUS = function (value) : any {
102+ ArgsChecker.checkLength(arguments, 1, "UPLUS");
103+ return TypeConverter.firstValue(value);
104+};
105+
106+
107 export {
108 ABS,
109 ACOS,
110@@ -1337,5 +1349,6 @@ export {
111 LCM,
112 GAMMALN,
113 PRODUCT,
114- QUOTIENT
115+ QUOTIENT,
116+ UPLUS
117 }
118\ No newline at end of file
119diff --git a/tests/Formulas/MathTest.ts b/tests/Formulas/MathTest.ts
120index 2526005..a62b3b3 100644
121--- a/tests/Formulas/MathTest.ts
122+++ b/tests/Formulas/MathTest.ts
123@@ -66,7 +66,8 @@ import {
124 LCM,
125 GAMMALN,
126 PRODUCT,
127- QUOTIENT
128+ QUOTIENT,
129+ UPLUS
130 } from "../../src/Formulas/Math";
131 import * as ERRORS from "../../src/Errors";
132 import {
133@@ -102,6 +103,17 @@ test("LCM", function(){
134 });
135
136
137+test("UPLUS", function(){
138+ assertEquals(UPLUS(2), 2);
139+ assertEquals(UPLUS(false), false);
140+ assertEquals(UPLUS([1, 2, 3]), 1);
141+ assertEquals(UPLUS("hello"), "hello");
142+ catchAndAssertEquals(function() {
143+ UPLUS.apply(this, []);
144+ }, ERRORS.NA_ERROR);
145+});
146+
147+
148 test("PRODUCT", function(){
149 assertEquals(PRODUCT(2, 5), 10);
150 assertEquals(PRODUCT(2, 5, 4, 2, 8, 1, 77, 2, 3, 1), 295680);
151diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
152index 0baf63c..c1323f2 100644
153--- a/tests/SheetFormulaTest.ts
154+++ b/tests/SheetFormulaTest.ts
155@@ -267,6 +267,10 @@ test("Sheet QUOTIENT", function(){
156 assertFormulaEquals('=QUOTIENT(8, 2)', 4);
157 });
158
159+test("Sheet UPLUS", function(){
160+ assertFormulaEquals('=UPLUS(8)', 8);
161+});
162+
163 test("Sheet PERCENTILE", function(){
164 assertFormulaEquals('=PERCENTILE([10], 0)', 10);
165 });