commit
message
[ISLOGICAL] formula added and tested
author
Ben Vogt <[email protected]>
date
2017-06-16 00:17:11
stats
8 file(s) changed,
63 insertions(+),
6 deletions(-)
files
DOCS.md
TODO.md
dist/Formulas/AllFormulas.js
dist/Formulas/Info.js
src/Formulas/AllFormulas.ts
src/Formulas/Info.ts
tests/Formulas/InfoTest.ts
tests/SheetFormulaTest.ts
1diff --git a/DOCS.md b/DOCS.md
2index b68baeb..acf8f25 100644
3--- a/DOCS.md
4+++ b/DOCS.md
5@@ -454,6 +454,15 @@
6 @returns {boolean}.
7 @constructor
8 ```
9+
10+### ISLOGICAL
11+
12+```
13+ Returns true if value is a boolean (FALSE, or TRUE). Numerical and text values return false.
14+@param value - value or reference to check.
15+@returns {boolean}
16+@constructor
17+```
18 ## Logical
19
20
21diff --git a/TODO.md b/TODO.md
22index e4cc06e..3b5ddd0 100644
23--- a/TODO.md
24+++ b/TODO.md
25@@ -31,7 +31,6 @@ For example 64 tbs to a qt.
26 * ISERR
27 * ISERROR
28 * ISFORMULA
29-* ISLOGICAL
30 * ISNA
31 * ISNONTEXT
32 * ISNUMBER
33diff --git a/dist/Formulas/AllFormulas.js b/dist/Formulas/AllFormulas.js
34index c5cd84a..aecda72 100644
35--- a/dist/Formulas/AllFormulas.js
36+++ b/dist/Formulas/AllFormulas.js
37@@ -74,6 +74,7 @@ exports.UMINUS = Math_1.UMINUS;
38 var Info_1 = require("./Info");
39 exports.NA = Info_1.NA;
40 exports.ISTEXT = Info_1.ISTEXT;
41+exports.ISLOGICAL = Info_1.ISLOGICAL;
42 var Lookup_1 = require("./Lookup");
43 exports.CHOOSE = Lookup_1.CHOOSE;
44 var Logical_1 = require("./Logical");
45diff --git a/dist/Formulas/Info.js b/dist/Formulas/Info.js
46index 18152ae..7235711 100644
47--- a/dist/Formulas/Info.js
48+++ b/dist/Formulas/Info.js
49@@ -2,6 +2,7 @@
50 exports.__esModule = true;
51 var ArgsChecker_1 = require("../Utilities/ArgsChecker");
52 var Errors_1 = require("../Errors");
53+var TypeConverter_1 = require("../Utilities/TypeConverter");
54 /**
55 * Returns the "value not available" error, "#N/A".
56 * @constructor
57@@ -19,6 +20,17 @@ exports.NA = NA;
58 */
59 var ISTEXT = function (value) {
60 ArgsChecker_1.ArgsChecker.checkLength(arguments, 1, "ISTEXT");
61- return typeof value === "string";
62+ return typeof TypeConverter_1.TypeConverter.firstValue(value) === "string";
63 };
64 exports.ISTEXT = ISTEXT;
65+/**
66+ * Returns true if value is a boolean (FALSE, or TRUE). Numerical and text values return false.
67+ * @param value - value or reference to check.
68+ * @returns {boolean}
69+ * @constructor
70+ */
71+var ISLOGICAL = function (value) {
72+ ArgsChecker_1.ArgsChecker.checkLength(arguments, 1, "ISLOGICAL");
73+ return typeof TypeConverter_1.TypeConverter.firstValue(value) === "boolean";
74+};
75+exports.ISLOGICAL = ISLOGICAL;
76diff --git a/src/Formulas/AllFormulas.ts b/src/Formulas/AllFormulas.ts
77index 290d75e..b3ef233 100644
78--- a/src/Formulas/AllFormulas.ts
79+++ b/src/Formulas/AllFormulas.ts
80@@ -72,7 +72,8 @@ import {
81 } from "./Math";
82 import {
83 NA,
84- ISTEXT
85+ ISTEXT,
86+ ISLOGICAL
87 } from "./Info";
88 import {
89 CHOOSE
90@@ -329,5 +330,6 @@ export {
91 STDEVA,
92 STDEVP,
93 STDEVPA,
94- ISTEXT
95+ ISTEXT,
96+ ISLOGICAL
97 }
98\ No newline at end of file
99diff --git a/src/Formulas/Info.ts b/src/Formulas/Info.ts
100index 2f3b5b9..21c9e1c 100644
101--- a/src/Formulas/Info.ts
102+++ b/src/Formulas/Info.ts
103@@ -4,6 +4,9 @@ import {
104 import {
105 NAError
106 } from "../Errors";
107+import {
108+ TypeConverter
109+} from "../Utilities/TypeConverter";
110
111
112 /**
113@@ -24,11 +27,24 @@ var NA = function () {
114 */
115 var ISTEXT = function (value) {
116 ArgsChecker.checkLength(arguments, 1, "ISTEXT");
117- return typeof value === "string";
118+ return typeof TypeConverter.firstValue(value) === "string";
119+};
120+
121+
122+/**
123+ * Returns true if value is a boolean (FALSE, or TRUE). Numerical and text values return false.
124+ * @param value - value or reference to check.
125+ * @returns {boolean}
126+ * @constructor
127+ */
128+var ISLOGICAL = function (value) {
129+ ArgsChecker.checkLength(arguments, 1, "ISLOGICAL");
130+ return typeof TypeConverter.firstValue(value) === "boolean";
131 };
132
133
134 export {
135 NA,
136- ISTEXT
137+ ISTEXT,
138+ ISLOGICAL
139 }
140\ No newline at end of file
141diff --git a/tests/Formulas/InfoTest.ts b/tests/Formulas/InfoTest.ts
142index dfa8d6c..a7d0954 100644
143--- a/tests/Formulas/InfoTest.ts
144+++ b/tests/Formulas/InfoTest.ts
145@@ -1,6 +1,7 @@
146 import {
147 NA,
148- ISTEXT
149+ ISTEXT,
150+ ISLOGICAL
151 } from "../../src/Formulas/Info";
152 import * as ERRORS from "../../src/Errors";
153 import {
154@@ -18,9 +19,20 @@ test("NA", function(){
155
156 test("ISTEXT", function(){
157 assertEquals(ISTEXT("str"), true);
158+ assertEquals(ISTEXT(["str"]), true);
159 assertEquals(ISTEXT(9), false);
160 assertEquals(ISTEXT(false), false);
161 catchAndAssertEquals(function() {
162 ISTEXT.apply(this, []);
163 }, ERRORS.NA_ERROR);
164 });
165+
166+test("ISLOGICAL", function(){
167+ assertEquals(ISLOGICAL("str"), false);
168+ assertEquals(ISLOGICAL(9), false);
169+ assertEquals(ISLOGICAL(false), true);
170+ assertEquals(ISLOGICAL(true), true);
171+ catchAndAssertEquals(function() {
172+ ISLOGICAL.apply(this, []);
173+ }, ERRORS.NA_ERROR);
174+});
175diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
176index c49c767..51198ca 100644
177--- a/tests/SheetFormulaTest.ts
178+++ b/tests/SheetFormulaTest.ts
179@@ -659,6 +659,10 @@ test("Sheet ISTEXT", function(){
180 assertFormulaEquals('=ISTEXT("str")', true);
181 });
182
183+test("Sheet ISLOGICAL", function(){
184+ assertFormulaEquals('=ISLOGICAL(true)', true);
185+});
186+
187 test("Sheet *", function(){
188 assertFormulaEquals('= 10 * 10', 100);
189 assertFormulaEquals('= 10 * 0', 0);