spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[Logical, Sheet] TRUE and FALSE should throw errors on args length. Sheet should not pass them args.
author
Ben Vogt <[email protected]>
date
2017-05-13 21:46:44
stats
3 file(s) changed, 10 insertions(+), 3 deletions(-)
files
src/Formulas/Logical.ts
src/Sheet.ts
tests/Formulas/LogicalTest.ts
 1diff --git a/src/Formulas/Logical.ts b/src/Formulas/Logical.ts
 2index 0c89672..479b596 100644
 3--- a/src/Formulas/Logical.ts
 4+++ b/src/Formulas/Logical.ts
 5@@ -55,9 +55,9 @@ var EXACT = function (...values) {
 6  * Returns true.
 7  * @returns {boolean} true boolean
 8  * @constructor
 9- * TODO: Should throw NA error if param passed in.
10  */
11 var TRUE = function () : boolean {
12+  ArgsChecker.checkLength(arguments, 0, "TRUE");
13   return true;
14 };
15 
16@@ -65,9 +65,9 @@ var TRUE = function () : boolean {
17  * Returns false.
18  * @returns {boolean} false boolean
19  * @constructor
20- * TODO: Should throw NA error if param passed in.
21  */
22 var FALSE = function () : boolean {
23+  ArgsChecker.checkLength(arguments, 0, "FALSE");
24   return false;
25 };
26 
27diff --git a/src/Sheet.ts b/src/Sheet.ts
28index 01df1e7..7acff7c 100644
29--- a/src/Sheet.ts
30+++ b/src/Sheet.ts
31@@ -445,7 +445,7 @@ var Sheet = (function () {
32 
33     callVariable: function (args) {
34       args = args || [];
35-      var str = args[0];
36+      var str = args.shift(); // the first in args is the name of the function to call.
37 
38       if (str) {
39         str = str.toUpperCase();
40diff --git a/tests/Formulas/LogicalTest.ts b/tests/Formulas/LogicalTest.ts
41index e3ba392..37e47c8 100644
42--- a/tests/Formulas/LogicalTest.ts
43+++ b/tests/Formulas/LogicalTest.ts
44@@ -69,11 +69,17 @@ test("EXACT", function(){
45 
46 test("TRUE", function(){
47   assertEquals(TRUE(), true);
48+  catchAndAssertEquals(function() {
49+    TRUE.apply(this, [0]);
50+  }, ERRORS.NA_ERROR);
51 });
52 
53 
54 test("FALSE", function(){
55   assertEquals(FALSE(), false);
56+  catchAndAssertEquals(function() {
57+    FALSE.apply(this, [0]);
58+  }, ERRORS.NA_ERROR);
59 });
60 
61