spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[Math] Breaking out Math.ts tests into seperate file
author
Ben Vogt <[email protected]>
date
2017-04-29 21:58:59
stats
2 file(s) changed, 1086 insertions(+), 1063 deletions(-)
files
tests/FormulasTest.ts
tests/MathTest.ts
   1diff --git a/tests/FormulasTest.ts b/tests/FormulasTest.ts
   2index 3099102..cf7888a 100644
   3--- a/tests/FormulasTest.ts
   4+++ b/tests/FormulasTest.ts
   5@@ -1,12 +1,11 @@
   6-import { ABS, ACOS, ACOSH, ACOTH, ARABIC, ASIN, ASINH, ATAN, ATAN2, ATANH, AVEDEV, AVERAGE,
   7-    AVERAGEA, AVERAGEIF, CEILING,
   8-    CHAR, CODE, COMBIN, CONCATENATE, CONVERT, PEARSON,
   9-    CORREL, COS, PI, COSH, COT, COTH, COUNT, COUNTA, COUNTIF, COUNTIFS, COUNTUNIQUE,
  10-    DEGREES, DEVSQ,
  11-    ERF, ERFC, EVEN, EXPONDIST, FINV, FLOOR, __COMPLEX, FISHER, FISHERINV, IF,
  12-    INT, ISEVEN, ISODD, LN, LOG, LOG10, MAX, MAXA, MEDIAN, MIN, MINA, MOD, ODD,
  13-    POWER, ROUND, ROUNDDOWN, ROUNDUP, SIN, SINH, SPLIT, SQRT, SQRTPI, SUM, SUMIF, SUMPRODUCT, RADIANS,
  14-    SUMSQ, SUMX2MY2, SUMX2PY2, TAN, TANH, TRUNC } from "../src/RawFormulas/RawFormulas";
  15+import { ARABIC, AVEDEV, AVERAGE,
  16+    AVERAGEA, AVERAGEIF,
  17+    CHAR, CODE, CONCATENATE, CONVERT, PEARSON,
  18+    CORREL, COUNT, COUNTA,
  19+    DEVSQ,
  20+    EXPONDIST, FINV, __COMPLEX, FISHER, FISHERINV,
  21+    MAX, MAXA, MEDIAN, MIN, MINA,
  22+    SPLIT } from "../src/RawFormulas/RawFormulas";
  23 import * as ERRORS from "../src/Errors"
  24 import {assertEquals, assertArrayEquals} from "./utils/Asserts"
  25 
  26@@ -25,62 +24,6 @@ function catchAndAssertEquals(toExecute, expected) {
  27   }
  28 }
  29 
  30-// Test ABS
  31-assertEquals(ABS(-10), 10);
  32-assertEquals(ABS(-10.111), 10.111);
  33-assertEquals(ABS(0), 0);
  34-assertEquals(ABS(false), 0);
  35-assertEquals(ABS("-44"), 44);
  36-catchAndAssertEquals(function() {
  37-  ABS();
  38-}, ERRORS.NA_ERROR);
  39-catchAndAssertEquals(function() {
  40-  ABS("str");
  41-}, ERRORS.VALUE_ERROR);
  42-
  43-
  44-// Test ACOS
  45-assertEquals(ACOS(0), 1.5707963267948966);
  46-assertEquals(ACOS(-1), 3.141592653589793);
  47-assertEquals(ACOS(1), 0);
  48-assertEquals(ACOS("-1"), 3.141592653589793);
  49-assertEquals(ACOS(false), 1.5707963267948966);
  50-catchAndAssertEquals(function() {
  51-  ACOS("str");
  52-}, ERRORS.VALUE_ERROR);
  53-catchAndAssertEquals(function() {
  54-  ACOS(2);
  55-}, ERRORS.NUM_ERROR);
  56-
  57-
  58-// Test ACOSH
  59-assertEquals(ACOSH(22), 3.783672704329451);
  60-assertEquals(ACOSH(1), 0);
  61-assertEquals(ACOSH("11"), 3.0889699048446033);
  62-catchAndAssertEquals(function() {
  63-  ACOSH(-1);
  64-}, ERRORS.NUM_ERROR);
  65-catchAndAssertEquals(function() {
  66-  ACOSH("str");
  67-}, ERRORS.VALUE_ERROR);
  68-catchAndAssertEquals(function() {
  69-  ACOSH(false);
  70-}, ERRORS.NUM_ERROR);
  71-
  72-
  73-// Test ACOTH
  74-assertEquals(ACOTH(22), 0.04548588910286339);
  75-assertEquals(ACOTH(-1.1), -1.522261218861711);
  76-assertEquals(ACOTH("-22"), -0.04548588910286338);
  77-catchAndAssertEquals(function() {
  78-  ACOTH(-1);
  79-}, ERRORS.NUM_ERROR);
  80-catchAndAssertEquals(function() {
  81-  ACOTH("str");
  82-}, ERRORS.VALUE_ERROR);
  83-catchAndAssertEquals(function() {
  84-  ACOTH(false);
  85-}, ERRORS.NUM_ERROR);
  86 
  87 
  88 // Test ARABIC
  89@@ -98,70 +41,6 @@ catchAndAssertEquals(function() {
  90 }, ERRORS.VALUE_ERROR);
  91 
  92 
  93-// Test ASIN
  94-assertEquals(ASIN(0), 0);
  95-assertEquals(ASIN(1), 1.5707963267948966);
  96-assertEquals(ASIN("1"), 1.5707963267948966);
  97-assertEquals(ASIN(false), 0);
  98-catchAndAssertEquals(function() {
  99-  ASIN(2);
 100-}, ERRORS.NUM_ERROR);
 101-catchAndAssertEquals(function() {
 102-  ASIN("str");
 103-}, ERRORS.VALUE_ERROR);
 104-
 105-
 106-// Test ASINH
 107-assertEquals(ASINH(1), 0.8813735870195429);
 108-assertEquals(ASINH(0), 0);
 109-assertEquals(ASINH("1"), 0.8813735870195429);
 110-assertEquals(ASINH(false), 0);
 111-assertEquals(ASINH(true), 0.8813735870195429);
 112-catchAndAssertEquals(function() {
 113-  ASINH("str");
 114-}, ERRORS.VALUE_ERROR);
 115-
 116-
 117-// Test ATAN
 118-assertEquals(ATAN(1), 0.7853981633974483);
 119-assertEquals(ATAN(0), 0);
 120-assertEquals(ATAN("1"), 0.7853981633974483);
 121-assertEquals(ATAN(false), 0);
 122-assertEquals(ATAN(true), 0.7853981633974483);
 123-catchAndAssertEquals(function() {
 124-  ASINH("str");
 125-}, ERRORS.VALUE_ERROR);
 126-
 127-// Test ATAN2
 128-assertEquals(ATAN2(4, 3), 0.6435011087932844);
 129-assertEquals(ATAN2(-1, -1), -2.356194490192345);
 130-catchAndAssertEquals(function() {
 131-  ATAN2(0, 0);
 132-}, ERRORS.DIV_ZERO_ERROR);
 133-assertEquals(ATAN2(1, 0), 0);
 134-assertEquals(ATAN2(0, 1), 1.5707963267948966);
 135-assertEquals(ATAN2(-1, "-1"), -2.356194490192345);
 136-assertEquals(ATAN2(true, false), 0);
 137-assertEquals(ATAN2(true, true), 0.7853981633974483);
 138-catchAndAssertEquals(function() {
 139-  ATAN2("str", false);
 140-}, ERRORS.VALUE_ERROR);
 141-
 142-
 143-// Test ATANH
 144-assertEquals(ATANH(0.51), 0.5627297693521489);
 145-assertEquals(ATANH(0.44), 0.47223080442042564);
 146-assertEquals(ATANH(0), 0);
 147-assertEquals(ATANH("0.1"), 0.10033534773107562);
 148-assertEquals(ATANH(false), 0);
 149-catchAndAssertEquals(function() {
 150-  ATANH(true);
 151-}, ERRORS.NUM_ERROR);
 152-catchAndAssertEquals(function() {
 153-  ATANH("str");
 154-}, ERRORS.VALUE_ERROR);
 155-
 156-
 157 // Test AVEDEV
 158 assertEquals(AVEDEV(1, 2, 4, 55), 19.75);
 159 assertEquals(AVEDEV(1, 2, 4, "55"), 19.75);
 160@@ -259,27 +138,6 @@ catchAndAssertEquals(function() {
 161 }, ERRORS.DIV_ZERO_ERROR);
 162 
 163 
 164-// Test CEILING
 165-assertEquals(CEILING(10.1), 11);
 166-assertEquals(CEILING("10.1"), 11);
 167-assertEquals(CEILING(10.11111111, 0.1), 10.2);
 168-assertEquals(CEILING(10.22222222, 0.1), 10.3);
 169-assertEquals(CEILING(10.33333333, 0.2), 10.4);
 170-assertEquals(CEILING(10.33333333, 0.1), 10.4);
 171-assertEquals(CEILING([10.33333333], 0.1), 10.4);
 172-assertEquals(CEILING(10.22222222, 5), 15);
 173-assertEquals(CEILING(10.22222222, 8), 16);
 174-assertEquals(CEILING(10.22222222, true), 11);
 175-catchAndAssertEquals(function() {
 176-  CEILING(10, 0);
 177-}, ERRORS.DIV_ZERO_ERROR);
 178-catchAndAssertEquals(function() {
 179-  CEILING(10, 1, 2);
 180-}, ERRORS.NA_ERROR);
 181-catchAndAssertEquals(function() {
 182-  CEILING();
 183-}, ERRORS.NA_ERROR);
 184-
 185 // Test CHAR
 186 assertEquals(CHAR(97), "a");
 187 assertEquals(CHAR("97"), "a");
 188@@ -322,35 +180,6 @@ assertEquals(CODE(['a']), 97);
 189 assertEquals(CODE([['a'], 'p']), 97);
 190 
 191 
 192-// Test COMBIN
 193-assertEquals(COMBIN(4, 2), 6);
 194-assertEquals(COMBIN(4.999, 2.888), 6);
 195-assertEquals(COMBIN([4, "str"], [2]), 6);
 196-assertEquals(COMBIN(0, 0), 1);
 197-catchAndAssertEquals(function() {
 198-  COMBIN(2, "str");
 199-}, ERRORS.VALUE_ERROR);
 200-catchAndAssertEquals(function() {
 201-  COMBIN(2, []);
 202-}, ERRORS.REF_ERROR);
 203-catchAndAssertEquals(function() {
 204-  COMBIN(2, 4);
 205-}, ERRORS.NUM_ERROR);
 206-catchAndAssertEquals(function() {
 207-  COMBIN(0, 1);
 208-}, ERRORS.NUM_ERROR);
 209-catchAndAssertEquals(function() {
 210-  COMBIN();
 211-}, ERRORS.NA_ERROR);
 212-catchAndAssertEquals(function() {
 213-  COMBIN(4);
 214-}, ERRORS.NA_ERROR);
 215-catchAndAssertEquals(function() {
 216-  COMBIN(4, 2, 66);
 217-}, ERRORS.NA_ERROR);
 218-
 219-
 220-
 221 // Test CONCATENATE
 222 assertEquals(CONCATENATE("hey", " ", "there"), "hey there");
 223 assertEquals(CONCATENATE(["hey", " ", "there"]), "hey there");
 224@@ -369,8 +198,9 @@ catchAndAssertEquals(function() {
 225   CONCATENATE([]);
 226 }, ERRORS.REF_ERROR);
 227 
 228-assertEquals(CONVERT(5.1, "mm", "m"), 0.0050999999999999995);
 229 
 230+// Test CONVERT
 231+assertEquals(CONVERT(5.1, "mm", "m"), 0.0050999999999999995);
 232 
 233 // Test CORREL
 234 assertEquals(CORREL([9, 5],[10, 4]), 1);
 235@@ -402,95 +232,6 @@ catchAndAssertEquals(function() {
 236 assertEquals(PEARSON([9, 5],[10, 4]), 1);
 237 
 238 
 239-// Test COS
 240-assertEquals(COS(PI()), -1);
 241-assertEquals(COS(1), 0.5403023058681398);
 242-assertEquals(COS(false), 1);
 243-assertEquals(COS(true), 0.5403023058681398);
 244-assertEquals(COS(""), 1);
 245-assertEquals(COS("0"), 1);
 246-catchAndAssertEquals(function() {
 247-  COS("str");
 248-}, ERRORS.VALUE_ERROR);
 249-catchAndAssertEquals(function() {
 250-  COS();
 251-}, ERRORS.NA_ERROR);
 252-catchAndAssertEquals(function() {
 253-  COS(1, 1);
 254-}, ERRORS.NA_ERROR);
 255-assertEquals(COS([0, "str"]), 1);
 256-
 257-
 258-// Test COSH
 259-assertEquals(COSH(PI()), 11.591953275521522);
 260-assertEquals(COSH(1), 1.5430806348152437);
 261-assertEquals(COSH(false), 1);
 262-assertEquals(COSH(0), 1);
 263-assertEquals(COSH(true), 1.5430806348152437);
 264-assertEquals(COSH(""), 1);
 265-catchAndAssertEquals(function() {
 266-  COSH("str");
 267-}, ERRORS.VALUE_ERROR);
 268-catchAndAssertEquals(function() {
 269-  COSH();
 270-}, ERRORS.NA_ERROR);
 271-catchAndAssertEquals(function() {
 272-  COSH(1, 1);
 273-}, ERRORS.NA_ERROR);
 274-assertEquals(COSH([0, "str"]), 1);
 275-
 276-
 277-// Test COT
 278-assertEquals(COT(30), -0.15611995216165922);
 279-assertEquals(COT(1), 0.6420926159343306);
 280-assertEquals(COT(true), 0.6420926159343306);
 281-assertEquals(COT([1, "str"]), 0.6420926159343306);
 282-catchAndAssertEquals(function() {
 283-  COT(false);
 284-}, ERRORS.DIV_ZERO_ERROR);
 285-catchAndAssertEquals(function() {
 286-  COT(0);
 287-}, ERRORS.DIV_ZERO_ERROR);
 288-catchAndAssertEquals(function() {
 289-  COT("");
 290-}, ERRORS.DIV_ZERO_ERROR);
 291-catchAndAssertEquals(function() {
 292-  COT("str");
 293-}, ERRORS.VALUE_ERROR);
 294-catchAndAssertEquals(function() {
 295-  COT();
 296-}, ERRORS.NA_ERROR);
 297-catchAndAssertEquals(function() {
 298-  COT(1, 1);
 299-}, ERRORS.NA_ERROR);
 300-
 301-
 302-// Test COTH
 303-assertEquals(COTH(30), 1);
 304-assertEquals(COTH(1), 1.3130352854993315);
 305-assertEquals(COTH(true), 1.3130352854993315);
 306-assertEquals(COTH([1, "str"]), 1.3130352854993315);
 307-assertEquals(COTH(-1), -1.3130352854993315);
 308-catchAndAssertEquals(function() {
 309-  COTH(false);
 310-}, ERRORS.DIV_ZERO_ERROR);
 311-catchAndAssertEquals(function() {
 312-  COTH(0);
 313-}, ERRORS.DIV_ZERO_ERROR);
 314-catchAndAssertEquals(function() {
 315-  COTH("");
 316-}, ERRORS.DIV_ZERO_ERROR);
 317-catchAndAssertEquals(function() {
 318-  COTH("str");
 319-}, ERRORS.VALUE_ERROR);
 320-catchAndAssertEquals(function() {
 321-  COTH();
 322-}, ERRORS.NA_ERROR);
 323-catchAndAssertEquals(function() {
 324-  COTH(1, 1);
 325-}, ERRORS.NA_ERROR);
 326-
 327-
 328 // Test COUNT
 329 assertEquals(COUNT([1, 5, 10, 0]), 4);
 330 assertEquals(COUNT(1, 5, 10, 0), 4);
 331@@ -520,118 +261,6 @@ catchAndAssertEquals(function() {
 332 }, ERRORS.NA_ERROR);
 333 
 334 
 335-// Test COUNTIF
 336-assertEquals(COUNTIF([1, 5, 10], ">4"), 2);
 337-assertEquals(COUNTIF([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 7);
 338-assertEquals(COUNTIF([1, 5, 10], 5), 1);
 339-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], 5), 4);
 340-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], 10), 1);
 341-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">5"), 1);
 342-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=5"), 4);
 343-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=10"), 1);
 344-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=     10  "), 1);
 345-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">0"), 6);
 346-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">=5"), 5);
 347-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "<10"), 5);
 348-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 6);
 349-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">4.99"), 5);
 350-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
 351-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
 352-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=>5"), 0);
 353-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "==5"), 0);
 354-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "boom"], "*o*"), 3);
 355-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "mom"), 2);
 356-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "?o?"), 3);
 357-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "???"), 5);
 358-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "????"), 0);
 359-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "?"), 0);
 360-// dollar sign and negative values
 361-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=$5"), 4);
 362-assertEquals(COUNTIF([1, -5, -5, -5, 10, -5], "=-$5"), 4);
 363-assertEquals(COUNTIF([1, -5, -5, -5, 10, -5], "=-5"), 4);
 364-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">$5"), 1);
 365-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=$10"), 1);
 366-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=  $ 10"), 1);
 367-catchAndAssertEquals(function() {
 368-  COUNTIF([0, 1, 0, 1]);
 369-}, ERRORS.NA_ERROR);
 370-catchAndAssertEquals(function() {
 371-  COUNTIF();
 372-}, ERRORS.NA_ERROR);
 373-catchAndAssertEquals(function() {
 374-  COUNTIF([], "=1", []);
 375-}, ERRORS.NA_ERROR);
 376-
 377-
 378-// Test COUNTIFS
 379-// All COUNTIF tests should also work on COUNTIFS
 380-assertEquals(COUNTIFS([1, 5, 10], ">4"), 2);
 381-assertEquals(COUNTIFS([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 7);
 382-assertEquals(COUNTIFS([1, 5, 10], 5), 1);
 383-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], 5), 4);
 384-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], 10), 1);
 385-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">5"), 1);
 386-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=5"), 4);
 387-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=10"), 1);
 388-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=     10  "), 1);
 389-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">0"), 6);
 390-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">=5"), 5);
 391-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "<10"), 5);
 392-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5, 44], "<=10"), 6);
 393-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">4.99"), 5);
 394-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "<4.99"), 1);
 395-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
 396-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=>5"), 0);
 397-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "==5"), 0);
 398-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "boom"], "*o*"), 3);
 399-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "mom"), 2);
 400-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "?o?"), 3);
 401-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "???"), 5);
 402-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "????"), 0);
 403-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "?"), 0);
 404-// Now actually test COUNTIFS
 405-assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1"), 2);
 406-assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1"), 2);
 407-assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1", [0, 0, 1, 1], "=1"), 2);
 408-assertEquals(COUNTIFS([1, 5, 10, 20, 40], ">4", [0, 0, 1, 1, 1], "=1", [0, 0, 0, 0, 0], "=1"), 0);
 409-assertEquals(COUNTIFS([1, 2, 3, 4], ">3", [true, true, false, true], true), 1);
 410-catchAndAssertEquals(function() {
 411-  COUNTIFS([1, 5, 10, 20], ">4", [0, 0], "=1");
 412-}, ERRORS.VALUE_ERROR);
 413-
 414-
 415-// Test COUNTUNIQUE
 416-assertEquals(COUNTUNIQUE([1, 1, 10]), 2);
 417-assertEquals(COUNTUNIQUE(["1", 1, 10]), 3);
 418-assertEquals(COUNTUNIQUE(["1", 1, 10, ""]), 4);
 419-assertEquals(COUNTUNIQUE(["1", 1, 10, "", ""]), 4);
 420-assertEquals(COUNTUNIQUE(["1", 1, 10, "", " "]), 5);
 421-assertEquals(COUNTUNIQUE(["1", 1, 10, []]), 4);
 422-assertEquals(COUNTUNIQUE(["", " ", [""], []]), 2);
 423-assertEquals(COUNTUNIQUE([[""], []]), 1);
 424-catchAndAssertEquals(function() {
 425-  COUNTUNIQUE();
 426-}, ERRORS.NA_ERROR);
 427-
 428-
 429-// Test DEGREES
 430-assertEquals(DEGREES(PI()), 180);
 431-assertEquals(DEGREES([PI(), "str"]), 180);
 432-assertEquals(DEGREES(false), 0);
 433-assertEquals(DEGREES(true), 57.29577951308232);
 434-assertEquals(DEGREES(1), 57.29577951308232);
 435-assertEquals(DEGREES(12), 687.5493541569879);
 436-catchAndAssertEquals(function() {
 437-  DEGREES("str");
 438-}, ERRORS.VALUE_ERROR);
 439-catchAndAssertEquals(function() {
 440-  DEGREES();
 441-}, ERRORS.NA_ERROR);
 442-catchAndAssertEquals(function() {
 443-  DEGREES(10, 10);
 444-}, ERRORS.NA_ERROR);
 445-
 446-
 447 // Test DEVSQ
 448 assertEquals(DEVSQ(1, 2), 0.5);
 449 assertEquals(DEVSQ([1, 2]), 0.5);
 450@@ -652,59 +281,6 @@ catchAndAssertEquals(function() {
 451 }, ERRORS.REF_ERROR);
 452 
 453 
 454-// Test ERF
 455-assertEquals(ERF(2), 0.9953222650189527);
 456-assertEquals(ERF("2"), 0.9953222650189527);
 457-assertEquals(ERF(0), 1.1102230246251565e-16);
 458-assertEquals(ERF(1), 0.8427007929497149);
 459-assertEquals(ERF(true), 0.8427007929497149);
 460-assertEquals(ERF(false), 1.1102230246251565e-16);
 461-catchAndAssertEquals(function() {
 462-  ERF();
 463-}, ERRORS.NA_ERROR);
 464-catchAndAssertEquals(function() {
 465-  ERF([]);
 466-}, ERRORS.REF_ERROR);
 467-assertEquals(ERF(1, 2), 0.15262147206923782);
 468-assertEquals(ERF(2, 1), -0.15262147206923782);
 469-
 470-
 471-// Test ERFC
 472-assertEquals(ERFC(2), 0.004677734981047288);
 473-assertEquals(ERFC("2"), 0.004677734981047288);
 474-assertEquals(ERFC(0), 1);
 475-assertEquals(ERFC(1), 0.1572992070502851);
 476-assertEquals(ERFC(-1), 1.842700792949715);
 477-assertEquals(ERFC(-10), 2);
 478-catchAndAssertEquals(function() {
 479-  ERFC();
 480-}, ERRORS.NA_ERROR);
 481-catchAndAssertEquals(function() {
 482-  ERFC([]);
 483-}, ERRORS.REF_ERROR);
 484-
 485-
 486-
 487-// Test EVEN
 488-assertEquals(EVEN(3), 4);
 489-assertEquals(EVEN(4), 4);
 490-assertEquals(EVEN(5), 6);
 491-assertEquals(EVEN("4"), 4);
 492-assertEquals(EVEN(false), 0);
 493-assertEquals(EVEN(true), 2);
 494-assertEquals(EVEN([11, 22]), 12);
 495-assertEquals(EVEN([10, 22, "str"]), 10);
 496-catchAndAssertEquals(function() {
 497-  EVEN();
 498-}, ERRORS.NA_ERROR);
 499-catchAndAssertEquals(function() {
 500-  EVEN(1, 2, 3);
 501-}, ERRORS.NA_ERROR);
 502-catchAndAssertEquals(function() {
 503-  EVEN("str");
 504-}, ERRORS.VALUE_ERROR);
 505-
 506-
 507 // Test EXPONDIST
 508 assertEquals(EXPONDIST(4, 0.5, false), 0.06766764161830635);
 509 assertEquals(EXPONDIST(4, 0.5, 0), 0.06766764161830635);
 510@@ -797,165 +373,6 @@ catchAndAssertEquals(function() {
 511 }, ERRORS.NA_ERROR);
 512 
 513 
 514-// Test FLOOR
 515-assertEquals(FLOOR(10.1), 10);
 516-assertEquals(FLOOR("10.1"), 10);
 517-assertEquals(FLOOR(10.11111111, 0.1), 10.1);
 518-assertEquals(FLOOR(10.22222222, 0.1), 10.2);
 519-assertEquals(FLOOR(10.33333333, 0.2), 10.2);
 520-assertEquals(FLOOR(10.33333333, 0.1), 10.3);
 521-assertEquals(FLOOR([10.33333333], 0.1), 10.3);
 522-assertEquals(FLOOR(10.22222222, 5), 10);
 523-assertEquals(FLOOR(10.22222222, 8), 8);
 524-assertEquals(FLOOR(10.22222222, true), 10);
 525-catchAndAssertEquals(function() {
 526-  FLOOR(10, 0);
 527-}, ERRORS.DIV_ZERO_ERROR);
 528-catchAndAssertEquals(function() {
 529-  FLOOR(10, 1, 2);
 530-}, ERRORS.NA_ERROR);
 531-catchAndAssertEquals(function() {
 532-  FLOOR();
 533-}, ERRORS.NA_ERROR);
 534-
 535-
 536-// Test IF
 537-assertEquals(IF(true, "hit", "miss"), "hit");
 538-assertEquals(IF(false, "hit", "miss"), "miss");
 539-assertEquals(IF("", "hit", "miss"), "miss");
 540-assertEquals(IF("", "hit", "miss"), "miss");
 541-assertEquals(IF([true], "hit", "miss"), "hit");
 542-assertEquals(IF([false], "hit", "miss"), "miss");
 543-assertEquals(IF([""], "hit", "miss"), "miss");
 544-assertEquals(IF([""], "hit", "miss"), "miss");
 545-catchAndAssertEquals(function() {
 546-  IF("str", 1, 2);
 547-}, ERRORS.VALUE_ERROR);
 548-catchAndAssertEquals(function() {
 549-  IF([], 1, 2);
 550-}, ERRORS.REF_ERROR);
 551-
 552-
 553-// Test INT
 554-assertEquals(INT(99.33), 99);
 555-assertEquals(INT(99.99), 99);
 556-assertEquals(INT(true), 1);
 557-assertEquals(INT(false), 0);
 558-assertEquals(INT(""), 0);
 559-assertEquals(INT([1.1, "str"]), 1);
 560-catchAndAssertEquals(function() {
 561-  INT(100, 10);
 562-}, ERRORS.NA_ERROR);
 563-catchAndAssertEquals(function() {
 564-  INT();
 565-}, ERRORS.NA_ERROR);
 566-catchAndAssertEquals(function() {
 567-  INT("str");
 568-}, ERRORS.VALUE_ERROR);
 569-
 570-
 571-// Test ISEVEN
 572-assertEquals(ISEVEN(4), true);
 573-assertEquals(ISEVEN(3), false);
 574-assertEquals(ISEVEN(4.1), true);
 575-assertEquals(ISEVEN(false), true);
 576-assertEquals(ISEVEN(true), false);
 577-assertEquals(ISEVEN([4]), true);
 578-catchAndAssertEquals(function() {
 579-  ISEVEN(100, 10);
 580-}, ERRORS.NA_ERROR);
 581-catchAndAssertEquals(function() {
 582-  ISEVEN();
 583-}, ERRORS.NA_ERROR);
 584-catchAndAssertEquals(function() {
 585-  ISEVEN("");
 586-}, ERRORS.VALUE_ERROR);
 587-
 588-
 589-// Test ISODD
 590-assertEquals(ISODD(4), false);
 591-assertEquals(ISODD(3), true);
 592-assertEquals(ISODD(4.1), false);
 593-assertEquals(ISODD(false), false);
 594-assertEquals(ISODD(true), true);
 595-assertEquals(ISODD([4]), false);
 596-catchAndAssertEquals(function() {
 597-  ISODD(100, 10);
 598-}, ERRORS.NA_ERROR);
 599-catchAndAssertEquals(function() {
 600-  ISODD();
 601-}, ERRORS.NA_ERROR);
 602-catchAndAssertEquals(function() {
 603-  ISODD("");
 604-}, ERRORS.VALUE_ERROR);
 605-
 606-
 607-// Test LN
 608-assertEquals(LN(100), 4.605170185988092);
 609-assertEquals(LN("100"), 4.605170185988092);
 610-assertEquals(LN(1), 0);
 611-assertEquals(LN(true), 0);
 612-catchAndAssertEquals(function() {
 613-  LN(false);
 614-}, ERRORS.NUM_ERROR);
 615-catchAndAssertEquals(function() {
 616-  LN("str");
 617-}, ERRORS.VALUE_ERROR);
 618-catchAndAssertEquals(function() {
 619-  LN();
 620-}, ERRORS.NA_ERROR);
 621-catchAndAssertEquals(function() {
 622-  LN(10, 10);
 623-}, ERRORS.NA_ERROR);
 624-
 625-
 626-// Test LOG
 627-assertEquals(LOG(256, 2), 8);
 628-assertEquals(LOG(100), 2);
 629-assertEquals(LOG(100), 2);
 630-assertEquals(LOG(256, 10), 2.408239965311849);
 631-assertEquals(LOG(256), 2.408239965311849);
 632-assertEquals(LOG("100"), 2);
 633-assertEquals(LOG(1, 2), 0);
 634-catchAndAssertEquals(function() {
 635-  LOG("str");
 636-}, ERRORS.VALUE_ERROR);
 637-catchAndAssertEquals(function() {
 638-  LOG(256, 0);
 639-}, ERRORS.NUM_ERROR);
 640-catchAndAssertEquals(function() {
 641-  LOG(256, 1);
 642-}, ERRORS.DIV_ZERO_ERROR);
 643-catchAndAssertEquals(function() {
 644-  LOG(256, false);
 645-}, ERRORS.NUM_ERROR);
 646-catchAndAssertEquals(function() {
 647-  LOG(256, true);
 648-}, ERRORS.DIV_ZERO_ERROR);
 649-
 650-
 651-// Test LOG10
 652-assertEquals(LOG10(100), 2);
 653-assertEquals(LOG10("100"), 2);
 654-assertEquals(LOG10(1), 0);
 655-assertEquals(LOG10(10.1), 1.0043213737826424);
 656-catchAndAssertEquals(function() {
 657-  LOG10(false);
 658-}, ERRORS.NUM_ERROR);
 659-catchAndAssertEquals(function() {
 660-  LOG10("");
 661-}, ERRORS.NUM_ERROR);
 662-catchAndAssertEquals(function() {
 663-  LOG10("str");
 664-}, ERRORS.VALUE_ERROR);
 665-catchAndAssertEquals(function() {
 666-  LOG10();
 667-}, ERRORS.NA_ERROR);
 668-catchAndAssertEquals(function() {
 669-  LOG10(10, 10);
 670-}, ERRORS.NA_ERROR);
 671-
 672-
 673 // Test MAX
 674 assertEquals(MAX(100, 22), 100);
 675 assertEquals(MAX(100, "22"), 100);
 676@@ -1037,183 +454,6 @@ catchAndAssertEquals(function() {
 677 assertEquals(MINA(100, 22, 44), 22);
 678 
 679 
 680-// Test MOD
 681-assertEquals(MOD(10, 3), 1);
 682-catchAndAssertEquals(function() {
 683-  MOD(10, 3, 10);
 684-}, ERRORS.NA_ERROR);
 685-catchAndAssertEquals(function() {
 686-  MOD([10, 3]);
 687-}, ERRORS.NA_ERROR);
 688-catchAndAssertEquals(function() {
 689-  MOD(0, 0);
 690-}, ERRORS.DIV_ZERO_ERROR);
 691-catchAndAssertEquals(function() {
 692-  MOD(10);
 693-}, ERRORS.NA_ERROR);
 694-catchAndAssertEquals(function() {
 695-  MOD(10, false);
 696-}, ERRORS.DIV_ZERO_ERROR);
 697-catchAndAssertEquals(function() {
 698-  MOD(10, 0);
 699-}, ERRORS.DIV_ZERO_ERROR);
 700-catchAndAssertEquals(function() {
 701-  MOD(10, "str");
 702-}, ERRORS.VALUE_ERROR);
 703-assertEquals(MOD(10, "3"), 1);
 704-assertEquals(MOD(10.1, 3), 1.0999999999999996);
 705-assertEquals(MOD(10, 3.1), 0.6999999999999997);
 706-
 707-
 708-
 709-// Test ODD
 710-assertEquals(ODD(2), 3);
 711-assertEquals(ODD(4), 5);
 712-assertEquals(ODD(5), 5);
 713-assertEquals(ODD("4"), 5);
 714-assertEquals(ODD(false), 1);
 715-assertEquals(ODD(true), 1);
 716-assertEquals(ODD([10, 22]), 11);
 717-assertEquals(ODD([10, 22, "str"]), 11);
 718-catchAndAssertEquals(function() {
 719-  ODD();
 720-}, ERRORS.NA_ERROR);
 721-catchAndAssertEquals(function() {
 722-  ODD(1, 2, 3);
 723-}, ERRORS.NA_ERROR);
 724-catchAndAssertEquals(function() {
 725-  ODD("str");
 726-}, ERRORS.VALUE_ERROR);
 727-
 728-
 729-// Test PI
 730-assertEquals(PI(), 3.141592653589793);
 731-
 732-
 733-// Test POWER
 734-assertEquals(POWER(4, 10), 1048576);
 735-assertEquals(POWER(4, false), 1);
 736-assertEquals(POWER(4, true), 4);
 737-assertEquals(POWER([4], [10]), 1048576);
 738-assertEquals(POWER([4], [10, "str"]), 1048576);
 739-catchAndAssertEquals(function() {
 740-  POWER(4, "str");
 741-}, ERRORS.VALUE_ERROR);
 742-catchAndAssertEquals(function() {
 743-  POWER();
 744-}, ERRORS.NA_ERROR);
 745-catchAndAssertEquals(function() {
 746-  POWER(4);
 747-}, ERRORS.NA_ERROR);
 748-catchAndAssertEquals(function() {
 749-  POWER(4, 10, 22);
 750-}, ERRORS.NA_ERROR);
 751-
 752-
 753-// Test RADIANS
 754-assertEquals(RADIANS(180), 3.141592653589793);
 755-assertEquals(RADIANS(false), 0);
 756-assertEquals(RADIANS(true), 0.017453292519943295);
 757-catchAndAssertEquals(function() {
 758-  RADIANS("str");
 759-}, ERRORS.VALUE_ERROR);
 760-catchAndAssertEquals(function() {
 761-  RADIANS();
 762-}, ERRORS.NA_ERROR);
 763-catchAndAssertEquals(function() {
 764-  RADIANS(4, 10);
 765-}, ERRORS.NA_ERROR);
 766-
 767-
 768-// Test ROUND
 769-assertEquals(ROUND(99.44, 1), 99.4);
 770-assertEquals(ROUND(99.44, 0), 99);
 771-assertEquals(ROUND(99.4444444444444, 9), 99.444444444);
 772-assertEquals(ROUND(99.44), 99);
 773-assertEquals(ROUND("99.44"), 99);
 774-assertEquals(ROUND([99.44, 22.222], [1, 4]), 99.4);
 775-catchAndAssertEquals(function() {
 776-  ROUND();
 777-}, ERRORS.NA_ERROR);
 778-catchAndAssertEquals(function() {
 779-  ROUND(99.44, 1, 44);
 780-}, ERRORS.NA_ERROR);
 781-catchAndAssertEquals(function() {
 782-  ROUND(99.999, "str");
 783-}, ERRORS.VALUE_ERROR);
 784-
 785-
 786-// Test ROUNDDOWN
 787-assertEquals(ROUNDDOWN(99.46, 1), 99.4);
 788-assertEquals(ROUNDDOWN(99.99, 1), 99.9);
 789-assertEquals(ROUNDDOWN(99.5555555555555, 9), 99.555555555);
 790-assertEquals(ROUNDDOWN(99.99), 99);
 791-assertEquals(ROUNDDOWN("99.99"), 99);
 792-assertEquals(ROUNDDOWN([99.46666, 22.222], [1, 4]), 99.4);
 793-catchAndAssertEquals(function() {
 794-  ROUNDDOWN();
 795-}, ERRORS.NA_ERROR);
 796-catchAndAssertEquals(function() {
 797-  ROUNDDOWN(99.44, 1, 44);
 798-}, ERRORS.NA_ERROR);
 799-catchAndAssertEquals(function() {
 800-  ROUNDDOWN(99.999, "str");
 801-}, ERRORS.VALUE_ERROR);
 802-
 803-
 804-// Test ROUNDUP
 805-assertEquals(ROUNDUP(99.46, 1), 99.5);
 806-assertEquals(ROUNDUP(99.99, 1), 100);
 807-assertEquals(ROUNDUP(99.5555555555555, 9), 99.555555556);
 808-assertEquals(ROUNDUP(99.99), 100);
 809-assertEquals(ROUNDUP("99.99"), 100);
 810-assertEquals(ROUNDUP([99.46666, 22.222], [1, 4]), 99.5);
 811-catchAndAssertEquals(function() {
 812-  ROUNDUP();
 813-}, ERRORS.NA_ERROR);
 814-catchAndAssertEquals(function() {
 815-  ROUNDUP(99.44, 1, 44);
 816-}, ERRORS.NA_ERROR);
 817-catchAndAssertEquals(function() {
 818-  ROUNDUP(99.999, "str");
 819-}, ERRORS.VALUE_ERROR);
 820-
 821-
 822-// Test SIN
 823-assertEquals(SIN(0), 0);
 824-assertEquals(SIN(1), 0.8414709848078965);
 825-assertEquals(SIN(PI() / 2), 1);
 826-assertEquals(SIN(PI()), 0);
 827-assertEquals(SIN(true), 0.8414709848078965);
 828-assertEquals(SIN(false), 0);
 829-assertEquals(SIN("0"), 0);
 830-assertEquals(SIN(""), 0);
 831-catchAndAssertEquals(function() {
 832-  SIN("str");
 833-}, ERRORS.VALUE_ERROR);
 834-assertEquals(SIN([1]), 0.8414709848078965);
 835-assertEquals(SIN([[1]]), 0.8414709848078965);
 836-assertEquals(SIN([1, "str"]), 0.8414709848078965);
 837-
 838-
 839-// Test SINH
 840-assertEquals(SINH(PI()), 11.548739357257748);
 841-assertEquals(SINH(1), 1.1752011936438014);
 842-assertEquals(SINH(false), 0);
 843-assertEquals(SINH(true), 1.1752011936438014);
 844-assertEquals(SINH(""), 0);
 845-assertEquals(SINH("0"), 0);
 846-catchAndAssertEquals(function() {
 847-  SINH("str");
 848-}, ERRORS.VALUE_ERROR);
 849-assertEquals(SINH([10]), 11013.232874703393);
 850-assertEquals(SINH([[10]]), 11013.232874703393);
 851-catchAndAssertEquals(function() {
 852-  SIN([[]]);
 853-}, ERRORS.REF_ERROR);
 854-assertEquals(SINH([[10, "str"]]), 11013.232874703393);
 855-
 856-
 857 // Test SPLIT
 858 assertArrayEquals(SPLIT("1,2,3", ","), ['1', '2', '3']);
 859 assertArrayEquals(SPLIT("little kitty cat", "i"), ['l', 'ttle k', 'tty cat']);
 860@@ -1226,249 +466,4 @@ catchAndAssertEquals(function() {
 861 }, ERRORS.REF_ERROR);
 862 catchAndAssertEquals(function() {
 863   SPLIT("er", "er", true, 10);
 864-}, ERRORS.NA_ERROR);
 865-
 866-
 867-// Test SQRT
 868-assertEquals(SQRT(9), 3);
 869-assertEquals(SQRT("9"), 3);
 870-assertEquals(SQRT(4), 2);
 871-assertEquals(SQRT(false), 0);
 872-assertEquals(SQRT(true), 1);
 873-assertEquals(SQRT(""), 0);
 874-catchAndAssertEquals(function() {
 875-  SQRT("str");
 876-}, ERRORS.VALUE_ERROR);
 877-catchAndAssertEquals(function() {
 878-  SQRT(-9);
 879-}, ERRORS.VALUE_ERROR);
 880-catchAndAssertEquals(function() {
 881-  SQRT();
 882-}, ERRORS.NA_ERROR);
 883-catchAndAssertEquals(function() {
 884-  SQRT(4, 4);
 885-}, ERRORS.NA_ERROR);
 886-
 887-
 888-// Test SQRTPI
 889-assertEquals(SQRTPI(9), 5.317361552716548);
 890-assertEquals(SQRTPI("9"), 5.317361552716548);
 891-assertEquals(SQRTPI([9]), 5.317361552716548);
 892-assertEquals(SQRTPI(0), 0);
 893-assertEquals(SQRTPI(1), 1.7724538509055159);
 894-assertEquals(SQRTPI(""), 0);
 895-catchAndAssertEquals(function() {
 896-  SQRTPI("str");
 897-}, ERRORS.VALUE_ERROR);
 898-catchAndAssertEquals(function() {
 899-  SQRTPI(-1);
 900-}, ERRORS.NUM_ERROR);
 901-catchAndAssertEquals(function() {
 902-  SQRTPI();
 903-}, ERRORS.NA_ERROR);
 904-catchAndAssertEquals(function() {
 905-  SQRTPI(4, 4);
 906-}, ERRORS.NA_ERROR);
 907-
 908-
 909-// Test SUM
 910-assertEquals(SUM(10), 10);
 911-assertEquals(SUM(10, 10), 20);
 912-assertEquals(SUM(10, [5, 5]), 20);
 913-assertEquals(SUM("10", [5, 5]), 20);
 914-assertEquals(SUM(false, [10, 10]), 20);
 915-assertEquals(SUM(true, [10, 10]), 21);
 916-catchAndAssertEquals(function() {
 917-  SUM([10, 10], "");
 918-}, ERRORS.VALUE_ERROR);
 919-catchAndAssertEquals(function() {
 920-  SUM([10, 10], "str");
 921-}, ERRORS.VALUE_ERROR);
 922-catchAndAssertEquals(function() {
 923-  SUM();
 924-}, ERRORS.NA_ERROR);
 925-
 926-
 927-// Test SUMIF
 928-assertEquals(SUMIF([1, 5, 10], 5), 5);
 929-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], 5), 20);
 930-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], 10), 10);
 931-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">5"), 10);
 932-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=5"), 20);
 933-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=1"), 1);
 934-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=     1  "), 1);
 935-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">0"), 31);
 936-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">=5"), 30);
 937-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "<10"), 21);
 938-assertEquals(SUMIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 31);
 939-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">4.99"), 30);
 940-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
 941-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
 942-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=>5"), 0);
 943-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "==5"), 0);
 944-assertEquals(SUMIF(["m", "m", 3, 11, true], "m"), 0);
 945-assertEquals(SUMIF(["m", "p", "m"], "m", [1, 1, 1]), 2);
 946-assertEquals(SUMIF(["p", "p", "p"], "m", [1, 1, 1]), 0);
 947-assertEquals(SUMIF(["p", "p", "p"], "", [1, 1, 1]), 0);
 948-assertEquals(SUMIF(["p", "p", "p"], "*", [1, 1, 1]), 3);
 949-assertEquals(SUMIF(["mom", "pop", "pap"], "*o*", [1, 1, 1]), 2);
 950-assertEquals(SUMIF(["mom", "pop", "pap"], "*a*", [1, 1, 1]), 1);
 951-assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1, 1]), 2);
 952-assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1, 1]), 2);
 953-assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1,]), 1);
 954-assertEquals(SUMIF(["pop", "pap"], "p*p", [1, 2, 4]), 3);
 955-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "boom"], "*o*", [1, 1, 1, 1, 1]), 3);
 956-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "mom", [1, 1, 1, 1, 1]), 2);
 957-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "?o?", [1, 1, 1, 1, 1]), 3);
 958-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "???", [1, 1, 1, 1, 1]), 5);
 959-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "????", [1, 1, 1, 1, 1]), 0);
 960-assertEquals(SUMIF([0, 1, 0, 1], "=1", [1, 2, 4, 8]), 10);
 961-catchAndAssertEquals(function() {
 962-  SUMIF([0, 1, 0, 1]);
 963-}, ERRORS.NA_ERROR);
 964-catchAndAssertEquals(function() {
 965-  SUMIF();
 966-}, ERRORS.NA_ERROR);
 967-catchAndAssertEquals(function() {
 968-  SUMIF([], "=1", [], true);
 969-}, ERRORS.NA_ERROR);
 970-
 971-
 972-// Test SUMPRODUCT
 973-assertEquals(SUMPRODUCT([1, 5, 10], [2, 2, 2]), 32);
 974-assertEquals(SUMPRODUCT([1, 5, 10], [2, 2, 2], [2, 2, 2]), 64);
 975-assertEquals(SUMPRODUCT([1, 5, 10], [1, 2, 2], [1, 4, 4]), 121);
 976-assertEquals(SUMPRODUCT([1, 5, 10]), 16);
 977-assertEquals(SUMPRODUCT([1, 5, 10, ""]), 16);
 978-assertEquals(SUMPRODUCT([1, 5, 10, 200], [2, 2, 2, ""]), 32);
 979-assertEquals(SUMPRODUCT([1, 5, 10, "str"]), 16);
 980-assertEquals(SUMPRODUCT([10, 10, 22, "str"], [2, 2, [2, 2]]), 84);
 981-assertEquals(SUMPRODUCT(1, 5, 10), 50);
 982-assertEquals(SUMPRODUCT([1, 5, 10]), 16);
 983-catchAndAssertEquals(function() {
 984-  SUMPRODUCT([1, 5, 10], [2, 2]);
 985-}, ERRORS.VALUE_ERROR);
 986-catchAndAssertEquals(function() {
 987-  SUMPRODUCT([1, 5, 10], [2, 2, 2, []]);
 988-}, ERRORS.REF_ERROR);
 989-catchAndAssertEquals(function() {
 990-  SUMPRODUCT();
 991-}, ERRORS.NA_ERROR);
 992-
 993-
 994-
 995-// Test SUMSQ
 996-assertEquals(SUMSQ([1, 5, 10], 10), 226);
 997-assertEquals(SUMSQ([10, 10, 22, ""]), 684);
 998-assertEquals(SUMSQ(10, 10, 22), 684);
 999-assertEquals(SUMSQ(10, 10, "22", true), 685);
1000-assertEquals(SUMSQ(10, 10, "22", false), 684);
1001-assertEquals(SUMSQ([10, 10, 22, true]), 684);
1002-catchAndAssertEquals(function() {
1003-  SUMSQ([10, 10, 22, "", []]);
1004-}, ERRORS.REF_ERROR);
1005-catchAndAssertEquals(function() {
1006-  SUMSQ([]);
1007-}, ERRORS.REF_ERROR);
1008-catchAndAssertEquals(function() {
1009-  SUMSQ();
1010-}, ERRORS.NA_ERROR);
1011-
1012-
1013-// Test SUMX2MY2
1014-assertEquals(SUMX2MY2([1,2,3],[4,5,6]), -63);
1015-assertEquals(SUMX2MY2([1, 2, 3], [[4, 5], [6]]), -63);
1016-assertEquals(SUMX2MY2(["1",2,3],[4,5,6]), -48);
1017-assertEquals(SUMX2MY2(["",2,3],[4,5,6]), -48);
1018-assertEquals(SUMX2MY2([false,2,3],[4,5,6]), -48);
1019-assertEquals(SUMX2MY2([true,2,3],[4,5,6]), -48);
1020-catchAndAssertEquals(function() {
1021-  SUMX2MY2([1,2,3],[4,5, []]);
1022-}, ERRORS.REF_ERROR);
1023-catchAndAssertEquals(function() {
1024-  SUMX2MY2([1,2,3],[4,5]);
1025-}, ERRORS.NA_ERROR);
1026-catchAndAssertEquals(function() {
1027-  SUMX2MY2();
1028-}, ERRORS.NA_ERROR);
1029-
1030-
1031-// Test SUMX2PY2
1032-assertEquals(SUMX2PY2([1, 2, 3], [4, 5, 6]), 91);
1033-assertEquals(SUMX2PY2([1, 2, 3], [[4, 5], [6]]), 91);
1034-assertEquals(SUMX2PY2(["1",2,3],[4,5,6]), 74);
1035-assertEquals(SUMX2PY2(["",2,3],[4,5,6]), 74);
1036-assertEquals(SUMX2PY2([false,2,3],[4,5,6]), 74);
1037-assertEquals(SUMX2PY2([true,2,3],[4,5,6]), 74);
1038-catchAndAssertEquals(function() {
1039-  SUMX2PY2([1,2,3],[4,5, []]);
1040-}, ERRORS.REF_ERROR);
1041-catchAndAssertEquals(function() {
1042-  SUMX2PY2([1,2,3],[4,5]);
1043-}, ERRORS.NA_ERROR);
1044-catchAndAssertEquals(function() {
1045-  SUMX2PY2();
1046-}, ERRORS.NA_ERROR);
1047-
1048-
1049-// Test TAN
1050-assertEquals(TAN(0), 0);
1051-assertEquals(TAN(1), 1.5574077246549023);
1052-assertEquals(TAN(PI() / 2), 16331239353195370);
1053-assertEquals(TAN(PI()), 0);
1054-assertEquals(TAN(false), 0);
1055-assertEquals(TAN(true), 1.5574077246549023);
1056-assertEquals(TAN(""), 0);
1057-assertEquals(TAN("0"), 0);
1058-catchAndAssertEquals(function() {
1059-  TAN("str");
1060-}, ERRORS.VALUE_ERROR);
1061-catchAndAssertEquals(function() {
1062-  TAN();
1063-}, ERRORS.NA_ERROR);
1064-catchAndAssertEquals(function() {
1065-  TAN(1, 1);
1066-}, ERRORS.NA_ERROR);
1067-assertEquals(TAN([1, 44]), 1.5574077246549023);
1068-assertEquals(TAN([1, "str"]), 1.5574077246549023);
1069-
1070-
1071-// Test TANH
1072-assertEquals(TANH(0), 0);
1073-assertEquals(TANH(1), 0.7615941559557649);
1074-assertEquals(TANH(PI() / 2), 0.9171523356672744);
1075-assertEquals(TANH(PI()), 0.9962720762207501);
1076-assertEquals(TANH(false), 0);
1077-assertEquals(TANH(true), 0.7615941559557649);
1078-assertEquals(TANH(""), 0);
1079-assertEquals(TANH("0"), 0);
1080-catchAndAssertEquals(function() {
1081-  TANH("str");
1082-}, ERRORS.VALUE_ERROR);
1083-catchAndAssertEquals(function() {
1084-  TANH();
1085-}, ERRORS.NA_ERROR);
1086-catchAndAssertEquals(function() {
1087-  TANH(1, 1);
1088-}, ERRORS.NA_ERROR);
1089-assertEquals(TANH([1, 44]), 0.7615941559557649);
1090-assertEquals(TANH([1, "str"]), 0.7615941559557649);
1091-
1092-
1093-// Test TRUNC
1094-assertEquals(TRUNC(PI(), 2), 3.14);
1095-assertEquals(TRUNC("3.141592653589793", "2"), 3.14);
1096-assertEquals(TRUNC(PI(), 1), 3.1);
1097-assertEquals(TRUNC(PI(), 0), 3);
1098-assertEquals(TRUNC(PI(), false), 3);
1099-assertEquals(TRUNC(PI(), -1), 0);
1100-assertEquals(TRUNC(31.41592653589793, -1), 30);
1101-assertEquals(TRUNC([31.41592653589793], [-1]), 30);
1102-assertEquals(TRUNC(31111.41592653589793, -4), 30000);
1103-assertEquals(TRUNC(31111.41592653589793, -2), 31100);
1104-catchAndAssertEquals(function() {
1105-  TRUNC();
1106-}, ERRORS.NA_ERROR);
1107-catchAndAssertEquals(function() {
1108-  TRUNC(3.1, 1, 1);
1109-}, ERRORS.NA_ERROR);
1110+}, ERRORS.NA_ERROR);
1111\ No newline at end of file
1112diff --git a/tests/MathTest.ts b/tests/MathTest.ts
1113new file mode 100644
1114index 0000000..7d97770
1115--- /dev/null
1116+++ b/tests/MathTest.ts
1117@@ -0,0 +1,1066 @@
1118+import {
1119+  ABS,
1120+  ACOS,
1121+  ACOSH,
1122+  ACOTH,
1123+  ASIN,
1124+  ASINH,
1125+  ATAN,
1126+  ATAN2,
1127+  ATANH,
1128+  COT,
1129+  COTH,
1130+  COSH,
1131+  COS,
1132+  COUNTUNIQUE,
1133+  EVEN,
1134+  ERF,
1135+  ERFC,
1136+  INT,
1137+  ISEVEN,
1138+  ISODD,
1139+  MOD,
1140+  ODD,
1141+  SIN,
1142+  SINH,
1143+  SUM,
1144+  SQRT,
1145+  SQRTPI,
1146+  PI,
1147+  POWER,
1148+  LOG,
1149+  LOG10,
1150+  LN,
1151+  TAN,
1152+  TANH,
1153+  ROUND,
1154+  ROUNDDOWN,
1155+  ROUNDUP,
1156+  SUMPRODUCT,
1157+  SUMIF,
1158+  SUMSQ,
1159+  SUMX2MY2,
1160+  SUMX2PY2,
1161+  FLOOR,
1162+  IF,
1163+  COUNTIF,
1164+  COUNTIFS,
1165+  CEILING,
1166+  TRUNC,
1167+  RADIANS,
1168+  DEGREES,
1169+  COMBIN
1170+} from "../src/RawFormulas/Math";
1171+import * as ERRORS from "../src/Errors"
1172+import {
1173+  assertEquals,
1174+  catchAndAssertEquals
1175+} from "./utils/Asserts";
1176+
1177+
1178+// Test ABS
1179+assertEquals(ABS(-10), 10);
1180+assertEquals(ABS(-10.111), 10.111);
1181+assertEquals(ABS(0), 0);
1182+assertEquals(ABS(false), 0);
1183+assertEquals(ABS("-44"), 44);
1184+catchAndAssertEquals(function() {
1185+  ABS();
1186+}, ERRORS.NA_ERROR);
1187+catchAndAssertEquals(function() {
1188+  ABS("str");
1189+}, ERRORS.VALUE_ERROR);
1190+
1191+
1192+// Test ACOS
1193+assertEquals(ACOS(0), 1.5707963267948966);
1194+assertEquals(ACOS(-1), 3.141592653589793);
1195+assertEquals(ACOS(1), 0);
1196+assertEquals(ACOS("-1"), 3.141592653589793);
1197+assertEquals(ACOS(false), 1.5707963267948966);
1198+catchAndAssertEquals(function() {
1199+  ACOS("str");
1200+}, ERRORS.VALUE_ERROR);
1201+catchAndAssertEquals(function() {
1202+  ACOS(2);
1203+}, ERRORS.NUM_ERROR);
1204+
1205+
1206+// Test ACOSH
1207+assertEquals(ACOSH(22), 3.783672704329451);
1208+assertEquals(ACOSH(1), 0);
1209+assertEquals(ACOSH("11"), 3.0889699048446033);
1210+catchAndAssertEquals(function() {
1211+  ACOSH(-1);
1212+}, ERRORS.NUM_ERROR);
1213+catchAndAssertEquals(function() {
1214+  ACOSH("str");
1215+}, ERRORS.VALUE_ERROR);
1216+catchAndAssertEquals(function() {
1217+  ACOSH(false);
1218+}, ERRORS.NUM_ERROR);
1219+
1220+
1221+// Test ACOTH
1222+assertEquals(ACOTH(22), 0.04548588910286339);
1223+assertEquals(ACOTH(-1.1), -1.522261218861711);
1224+assertEquals(ACOTH("-22"), -0.04548588910286338);
1225+catchAndAssertEquals(function() {
1226+  ACOTH(-1);
1227+}, ERRORS.NUM_ERROR);
1228+catchAndAssertEquals(function() {
1229+  ACOTH("str");
1230+}, ERRORS.VALUE_ERROR);
1231+catchAndAssertEquals(function() {
1232+  ACOTH(false);
1233+}, ERRORS.NUM_ERROR);
1234+
1235+
1236+// Test ASIN
1237+assertEquals(ASIN(0), 0);
1238+assertEquals(ASIN(1), 1.5707963267948966);
1239+assertEquals(ASIN("1"), 1.5707963267948966);
1240+assertEquals(ASIN(false), 0);
1241+catchAndAssertEquals(function() {
1242+  ASIN(2);
1243+}, ERRORS.NUM_ERROR);
1244+catchAndAssertEquals(function() {
1245+  ASIN("str");
1246+}, ERRORS.VALUE_ERROR);
1247+
1248+
1249+// Test ASINH
1250+assertEquals(ASINH(1), 0.8813735870195429);
1251+assertEquals(ASINH(0), 0);
1252+assertEquals(ASINH("1"), 0.8813735870195429);
1253+assertEquals(ASINH(false), 0);
1254+assertEquals(ASINH(true), 0.8813735870195429);
1255+catchAndAssertEquals(function() {
1256+  ASINH("str");
1257+}, ERRORS.VALUE_ERROR);
1258+
1259+
1260+// Test ATAN
1261+assertEquals(ATAN(1), 0.7853981633974483);
1262+assertEquals(ATAN(0), 0);
1263+assertEquals(ATAN("1"), 0.7853981633974483);
1264+assertEquals(ATAN(false), 0);
1265+assertEquals(ATAN(true), 0.7853981633974483);
1266+catchAndAssertEquals(function() {
1267+  ASINH("str");
1268+}, ERRORS.VALUE_ERROR);
1269+
1270+// Test ATAN2
1271+assertEquals(ATAN2(4, 3), 0.6435011087932844);
1272+assertEquals(ATAN2(-1, -1), -2.356194490192345);
1273+catchAndAssertEquals(function() {
1274+  ATAN2(0, 0);
1275+}, ERRORS.DIV_ZERO_ERROR);
1276+assertEquals(ATAN2(1, 0), 0);
1277+assertEquals(ATAN2(0, 1), 1.5707963267948966);
1278+assertEquals(ATAN2(-1, "-1"), -2.356194490192345);
1279+assertEquals(ATAN2(true, false), 0);
1280+assertEquals(ATAN2(true, true), 0.7853981633974483);
1281+catchAndAssertEquals(function() {
1282+  ATAN2("str", false);
1283+}, ERRORS.VALUE_ERROR);
1284+
1285+
1286+// Test ATANH
1287+assertEquals(ATANH(0.51), 0.5627297693521489);
1288+assertEquals(ATANH(0.44), 0.47223080442042564);
1289+assertEquals(ATANH(0), 0);
1290+assertEquals(ATANH("0.1"), 0.10033534773107562);
1291+assertEquals(ATANH(false), 0);
1292+catchAndAssertEquals(function() {
1293+  ATANH(true);
1294+}, ERRORS.NUM_ERROR);
1295+catchAndAssertEquals(function() {
1296+  ATANH("str");
1297+}, ERRORS.VALUE_ERROR);
1298+
1299+
1300+// Test CEILING
1301+assertEquals(CEILING(10.1), 11);
1302+assertEquals(CEILING("10.1"), 11);
1303+assertEquals(CEILING(10.11111111, 0.1), 10.2);
1304+assertEquals(CEILING(10.22222222, 0.1), 10.3);
1305+assertEquals(CEILING(10.33333333, 0.2), 10.4);
1306+assertEquals(CEILING(10.33333333, 0.1), 10.4);
1307+assertEquals(CEILING([10.33333333], 0.1), 10.4);
1308+assertEquals(CEILING(10.22222222, 5), 15);
1309+assertEquals(CEILING(10.22222222, 8), 16);
1310+assertEquals(CEILING(10.22222222, true), 11);
1311+catchAndAssertEquals(function() {
1312+  CEILING(10, 0);
1313+}, ERRORS.DIV_ZERO_ERROR);
1314+catchAndAssertEquals(function() {
1315+  CEILING(10, 1, 2);
1316+}, ERRORS.NA_ERROR);
1317+catchAndAssertEquals(function() {
1318+  CEILING();
1319+}, ERRORS.NA_ERROR);
1320+
1321+
1322+// Test COMBIN
1323+assertEquals(COMBIN(4, 2), 6);
1324+assertEquals(COMBIN(4.999, 2.888), 6);
1325+assertEquals(COMBIN([4, "str"], [2]), 6);
1326+assertEquals(COMBIN(0, 0), 1);
1327+catchAndAssertEquals(function() {
1328+  COMBIN(2, "str");
1329+}, ERRORS.VALUE_ERROR);
1330+catchAndAssertEquals(function() {
1331+  COMBIN(2, []);
1332+}, ERRORS.REF_ERROR);
1333+catchAndAssertEquals(function() {
1334+  COMBIN(2, 4);
1335+}, ERRORS.NUM_ERROR);
1336+catchAndAssertEquals(function() {
1337+  COMBIN(0, 1);
1338+}, ERRORS.NUM_ERROR);
1339+catchAndAssertEquals(function() {
1340+  COMBIN();
1341+}, ERRORS.NA_ERROR);
1342+catchAndAssertEquals(function() {
1343+  COMBIN(4);
1344+}, ERRORS.NA_ERROR);
1345+catchAndAssertEquals(function() {
1346+  COMBIN(4, 2, 66);
1347+}, ERRORS.NA_ERROR);
1348+
1349+
1350+
1351+// Test COS
1352+assertEquals(COS(PI()), -1);
1353+assertEquals(COS(1), 0.5403023058681398);
1354+assertEquals(COS(false), 1);
1355+assertEquals(COS(true), 0.5403023058681398);
1356+assertEquals(COS(""), 1);
1357+assertEquals(COS("0"), 1);
1358+catchAndAssertEquals(function() {
1359+  COS("str");
1360+}, ERRORS.VALUE_ERROR);
1361+catchAndAssertEquals(function() {
1362+  COS();
1363+}, ERRORS.NA_ERROR);
1364+catchAndAssertEquals(function() {
1365+  COS(1, 1);
1366+}, ERRORS.NA_ERROR);
1367+assertEquals(COS([0, "str"]), 1);
1368+
1369+
1370+// Test COSH
1371+assertEquals(COSH(PI()), 11.591953275521522);
1372+assertEquals(COSH(1), 1.5430806348152437);
1373+assertEquals(COSH(false), 1);
1374+assertEquals(COSH(0), 1);
1375+assertEquals(COSH(true), 1.5430806348152437);
1376+assertEquals(COSH(""), 1);
1377+catchAndAssertEquals(function() {
1378+  COSH("str");
1379+}, ERRORS.VALUE_ERROR);
1380+catchAndAssertEquals(function() {
1381+  COSH();
1382+}, ERRORS.NA_ERROR);
1383+catchAndAssertEquals(function() {
1384+  COSH(1, 1);
1385+}, ERRORS.NA_ERROR);
1386+assertEquals(COSH([0, "str"]), 1);
1387+
1388+
1389+// Test COT
1390+assertEquals(COT(30), -0.15611995216165922);
1391+assertEquals(COT(1), 0.6420926159343306);
1392+assertEquals(COT(true), 0.6420926159343306);
1393+assertEquals(COT([1, "str"]), 0.6420926159343306);
1394+catchAndAssertEquals(function() {
1395+  COT(false);
1396+}, ERRORS.DIV_ZERO_ERROR);
1397+catchAndAssertEquals(function() {
1398+  COT(0);
1399+}, ERRORS.DIV_ZERO_ERROR);
1400+catchAndAssertEquals(function() {
1401+  COT("");
1402+}, ERRORS.DIV_ZERO_ERROR);
1403+catchAndAssertEquals(function() {
1404+  COT("str");
1405+}, ERRORS.VALUE_ERROR);
1406+catchAndAssertEquals(function() {
1407+  COT();
1408+}, ERRORS.NA_ERROR);
1409+catchAndAssertEquals(function() {
1410+  COT(1, 1);
1411+}, ERRORS.NA_ERROR);
1412+
1413+
1414+// Test COTH
1415+assertEquals(COTH(30), 1);
1416+assertEquals(COTH(1), 1.3130352854993315);
1417+assertEquals(COTH(true), 1.3130352854993315);
1418+assertEquals(COTH([1, "str"]), 1.3130352854993315);
1419+assertEquals(COTH(-1), -1.3130352854993315);
1420+catchAndAssertEquals(function() {
1421+  COTH(false);
1422+}, ERRORS.DIV_ZERO_ERROR);
1423+catchAndAssertEquals(function() {
1424+  COTH(0);
1425+}, ERRORS.DIV_ZERO_ERROR);
1426+catchAndAssertEquals(function() {
1427+  COTH("");
1428+}, ERRORS.DIV_ZERO_ERROR);
1429+catchAndAssertEquals(function() {
1430+  COTH("str");
1431+}, ERRORS.VALUE_ERROR);
1432+catchAndAssertEquals(function() {
1433+  COTH();
1434+}, ERRORS.NA_ERROR);
1435+catchAndAssertEquals(function() {
1436+  COTH(1, 1);
1437+}, ERRORS.NA_ERROR);
1438+
1439+
1440+// Test COUNTIF
1441+assertEquals(COUNTIF([1, 5, 10], ">4"), 2);
1442+assertEquals(COUNTIF([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 7);
1443+assertEquals(COUNTIF([1, 5, 10], 5), 1);
1444+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], 5), 4);
1445+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], 10), 1);
1446+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">5"), 1);
1447+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=5"), 4);
1448+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=10"), 1);
1449+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=     10  "), 1);
1450+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">0"), 6);
1451+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">=5"), 5);
1452+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "<10"), 5);
1453+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 6);
1454+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">4.99"), 5);
1455+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
1456+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
1457+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=>5"), 0);
1458+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "==5"), 0);
1459+assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "boom"], "*o*"), 3);
1460+assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "mom"), 2);
1461+assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "?o?"), 3);
1462+assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "???"), 5);
1463+assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "????"), 0);
1464+assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "?"), 0);
1465+// dollar sign and negative values
1466+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=$5"), 4);
1467+assertEquals(COUNTIF([1, -5, -5, -5, 10, -5], "=-$5"), 4);
1468+assertEquals(COUNTIF([1, -5, -5, -5, 10, -5], "=-5"), 4);
1469+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">$5"), 1);
1470+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=$10"), 1);
1471+assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=  $ 10"), 1);
1472+catchAndAssertEquals(function() {
1473+  COUNTIF([0, 1, 0, 1]);
1474+}, ERRORS.NA_ERROR);
1475+catchAndAssertEquals(function() {
1476+  COUNTIF();
1477+}, ERRORS.NA_ERROR);
1478+catchAndAssertEquals(function() {
1479+  COUNTIF([], "=1", []);
1480+}, ERRORS.NA_ERROR);
1481+
1482+
1483+// Test COUNTIFS
1484+// All COUNTIF tests should also work on COUNTIFS
1485+assertEquals(COUNTIFS([1, 5, 10], ">4"), 2);
1486+assertEquals(COUNTIFS([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 7);
1487+assertEquals(COUNTIFS([1, 5, 10], 5), 1);
1488+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], 5), 4);
1489+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], 10), 1);
1490+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">5"), 1);
1491+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=5"), 4);
1492+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=10"), 1);
1493+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=     10  "), 1);
1494+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">0"), 6);
1495+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">=5"), 5);
1496+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "<10"), 5);
1497+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5, 44], "<=10"), 6);
1498+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">4.99"), 5);
1499+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "<4.99"), 1);
1500+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
1501+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=>5"), 0);
1502+assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "==5"), 0);
1503+assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "boom"], "*o*"), 3);
1504+assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "mom"), 2);
1505+assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "?o?"), 3);
1506+assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "???"), 5);
1507+assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "????"), 0);
1508+assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "?"), 0);
1509+// Now actually test COUNTIFS
1510+assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1"), 2);
1511+assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1"), 2);
1512+assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1", [0, 0, 1, 1], "=1"), 2);
1513+assertEquals(COUNTIFS([1, 5, 10, 20, 40], ">4", [0, 0, 1, 1, 1], "=1", [0, 0, 0, 0, 0], "=1"), 0);
1514+assertEquals(COUNTIFS([1, 2, 3, 4], ">3", [true, true, false, true], true), 1);
1515+catchAndAssertEquals(function() {
1516+  COUNTIFS([1, 5, 10, 20], ">4", [0, 0], "=1");
1517+}, ERRORS.VALUE_ERROR);
1518+
1519+
1520+// Test COUNTUNIQUE
1521+assertEquals(COUNTUNIQUE([1, 1, 10]), 2);
1522+assertEquals(COUNTUNIQUE(["1", 1, 10]), 3);
1523+assertEquals(COUNTUNIQUE(["1", 1, 10, ""]), 4);
1524+assertEquals(COUNTUNIQUE(["1", 1, 10, "", ""]), 4);
1525+assertEquals(COUNTUNIQUE(["1", 1, 10, "", " "]), 5);
1526+assertEquals(COUNTUNIQUE(["1", 1, 10, []]), 4);
1527+assertEquals(COUNTUNIQUE(["", " ", [""], []]), 2);
1528+assertEquals(COUNTUNIQUE([[""], []]), 1);
1529+catchAndAssertEquals(function() {
1530+  COUNTUNIQUE();
1531+}, ERRORS.NA_ERROR);
1532+
1533+
1534+// Test DEGREES
1535+assertEquals(DEGREES(PI()), 180);
1536+assertEquals(DEGREES([PI(), "str"]), 180);
1537+assertEquals(DEGREES(false), 0);
1538+assertEquals(DEGREES(true), 57.29577951308232);
1539+assertEquals(DEGREES(1), 57.29577951308232);
1540+assertEquals(DEGREES(12), 687.5493541569879);
1541+catchAndAssertEquals(function() {
1542+  DEGREES("str");
1543+}, ERRORS.VALUE_ERROR);
1544+catchAndAssertEquals(function() {
1545+  DEGREES();
1546+}, ERRORS.NA_ERROR);
1547+catchAndAssertEquals(function() {
1548+  DEGREES(10, 10);
1549+}, ERRORS.NA_ERROR);
1550+
1551+
1552+// Test ERF
1553+assertEquals(ERF(2), 0.9953222650189527);
1554+assertEquals(ERF("2"), 0.9953222650189527);
1555+assertEquals(ERF(0), 1.1102230246251565e-16);
1556+assertEquals(ERF(1), 0.8427007929497149);
1557+assertEquals(ERF(true), 0.8427007929497149);
1558+assertEquals(ERF(false), 1.1102230246251565e-16);
1559+catchAndAssertEquals(function() {
1560+  ERF();
1561+}, ERRORS.NA_ERROR);
1562+catchAndAssertEquals(function() {
1563+  ERF([]);
1564+}, ERRORS.REF_ERROR);
1565+assertEquals(ERF(1, 2), 0.15262147206923782);
1566+assertEquals(ERF(2, 1), -0.15262147206923782);
1567+
1568+
1569+// Test ERFC
1570+assertEquals(ERFC(2), 0.004677734981047288);
1571+assertEquals(ERFC("2"), 0.004677734981047288);
1572+assertEquals(ERFC(0), 1);
1573+assertEquals(ERFC(1), 0.1572992070502851);
1574+assertEquals(ERFC(-1), 1.842700792949715);
1575+assertEquals(ERFC(-10), 2);
1576+catchAndAssertEquals(function() {
1577+  ERFC();
1578+}, ERRORS.NA_ERROR);
1579+catchAndAssertEquals(function() {
1580+  ERFC([]);
1581+}, ERRORS.REF_ERROR);
1582+
1583+
1584+
1585+// Test EVEN
1586+assertEquals(EVEN(3), 4);
1587+assertEquals(EVEN(4), 4);
1588+assertEquals(EVEN(5), 6);
1589+assertEquals(EVEN("4"), 4);
1590+assertEquals(EVEN(false), 0);
1591+assertEquals(EVEN(true), 2);
1592+assertEquals(EVEN([11, 22]), 12);
1593+assertEquals(EVEN([10, 22, "str"]), 10);
1594+catchAndAssertEquals(function() {
1595+  EVEN();
1596+}, ERRORS.NA_ERROR);
1597+catchAndAssertEquals(function() {
1598+  EVEN(1, 2, 3);
1599+}, ERRORS.NA_ERROR);
1600+catchAndAssertEquals(function() {
1601+  EVEN("str");
1602+}, ERRORS.VALUE_ERROR);
1603+
1604+
1605+// Test FLOOR
1606+assertEquals(FLOOR(10.1), 10);
1607+assertEquals(FLOOR("10.1"), 10);
1608+assertEquals(FLOOR(10.11111111, 0.1), 10.1);
1609+assertEquals(FLOOR(10.22222222, 0.1), 10.2);
1610+assertEquals(FLOOR(10.33333333, 0.2), 10.2);
1611+assertEquals(FLOOR(10.33333333, 0.1), 10.3);
1612+assertEquals(FLOOR([10.33333333], 0.1), 10.3);
1613+assertEquals(FLOOR(10.22222222, 5), 10);
1614+assertEquals(FLOOR(10.22222222, 8), 8);
1615+assertEquals(FLOOR(10.22222222, true), 10);
1616+catchAndAssertEquals(function() {
1617+  FLOOR(10, 0);
1618+}, ERRORS.DIV_ZERO_ERROR);
1619+catchAndAssertEquals(function() {
1620+  FLOOR(10, 1, 2);
1621+}, ERRORS.NA_ERROR);
1622+catchAndAssertEquals(function() {
1623+  FLOOR();
1624+}, ERRORS.NA_ERROR);
1625+
1626+
1627+// Test IF
1628+assertEquals(IF(true, "hit", "miss"), "hit");
1629+assertEquals(IF(false, "hit", "miss"), "miss");
1630+assertEquals(IF("", "hit", "miss"), "miss");
1631+assertEquals(IF("", "hit", "miss"), "miss");
1632+assertEquals(IF([true], "hit", "miss"), "hit");
1633+assertEquals(IF([false], "hit", "miss"), "miss");
1634+assertEquals(IF([""], "hit", "miss"), "miss");
1635+assertEquals(IF([""], "hit", "miss"), "miss");
1636+catchAndAssertEquals(function() {
1637+  IF("str", 1, 2);
1638+}, ERRORS.VALUE_ERROR);
1639+catchAndAssertEquals(function() {
1640+  IF([], 1, 2);
1641+}, ERRORS.REF_ERROR);
1642+
1643+
1644+// Test INT
1645+assertEquals(INT(99.33), 99);
1646+assertEquals(INT(99.99), 99);
1647+assertEquals(INT(true), 1);
1648+assertEquals(INT(false), 0);
1649+assertEquals(INT(""), 0);
1650+assertEquals(INT([1.1, "str"]), 1);
1651+catchAndAssertEquals(function() {
1652+  INT(100, 10);
1653+}, ERRORS.NA_ERROR);
1654+catchAndAssertEquals(function() {
1655+  INT();
1656+}, ERRORS.NA_ERROR);
1657+catchAndAssertEquals(function() {
1658+  INT("str");
1659+}, ERRORS.VALUE_ERROR);
1660+
1661+
1662+// Test ISEVEN
1663+assertEquals(ISEVEN(4), true);
1664+assertEquals(ISEVEN(3), false);
1665+assertEquals(ISEVEN(4.1), true);
1666+assertEquals(ISEVEN(false), true);
1667+assertEquals(ISEVEN(true), false);
1668+assertEquals(ISEVEN([4]), true);
1669+catchAndAssertEquals(function() {
1670+  ISEVEN(100, 10);
1671+}, ERRORS.NA_ERROR);
1672+catchAndAssertEquals(function() {
1673+  ISEVEN();
1674+}, ERRORS.NA_ERROR);
1675+catchAndAssertEquals(function() {
1676+  ISEVEN("");
1677+}, ERRORS.VALUE_ERROR);
1678+
1679+
1680+// Test ISODD
1681+assertEquals(ISODD(4), false);
1682+assertEquals(ISODD(3), true);
1683+assertEquals(ISODD(4.1), false);
1684+assertEquals(ISODD(false), false);
1685+assertEquals(ISODD(true), true);
1686+assertEquals(ISODD([4]), false);
1687+catchAndAssertEquals(function() {
1688+  ISODD(100, 10);
1689+}, ERRORS.NA_ERROR);
1690+catchAndAssertEquals(function() {
1691+  ISODD();
1692+}, ERRORS.NA_ERROR);
1693+catchAndAssertEquals(function() {
1694+  ISODD("");
1695+}, ERRORS.VALUE_ERROR);
1696+
1697+
1698+// Test LN
1699+assertEquals(LN(100), 4.605170185988092);
1700+assertEquals(LN("100"), 4.605170185988092);
1701+assertEquals(LN(1), 0);
1702+assertEquals(LN(true), 0);
1703+catchAndAssertEquals(function() {
1704+  LN(false);
1705+}, ERRORS.NUM_ERROR);
1706+catchAndAssertEquals(function() {
1707+  LN("str");
1708+}, ERRORS.VALUE_ERROR);
1709+catchAndAssertEquals(function() {
1710+  LN();
1711+}, ERRORS.NA_ERROR);
1712+catchAndAssertEquals(function() {
1713+  LN(10, 10);
1714+}, ERRORS.NA_ERROR);
1715+
1716+
1717+// Test LOG
1718+assertEquals(LOG(256, 2), 8);
1719+assertEquals(LOG(100), 2);
1720+assertEquals(LOG(100), 2);
1721+assertEquals(LOG(256, 10), 2.408239965311849);
1722+assertEquals(LOG(256), 2.408239965311849);
1723+assertEquals(LOG("100"), 2);
1724+assertEquals(LOG(1, 2), 0);
1725+catchAndAssertEquals(function() {
1726+  LOG("str");
1727+}, ERRORS.VALUE_ERROR);
1728+catchAndAssertEquals(function() {
1729+  LOG(256, 0);
1730+}, ERRORS.NUM_ERROR);
1731+catchAndAssertEquals(function() {
1732+  LOG(256, 1);
1733+}, ERRORS.DIV_ZERO_ERROR);
1734+catchAndAssertEquals(function() {
1735+  LOG(256, false);
1736+}, ERRORS.NUM_ERROR);
1737+catchAndAssertEquals(function() {
1738+  LOG(256, true);
1739+}, ERRORS.DIV_ZERO_ERROR);
1740+
1741+
1742+// Test LOG10
1743+assertEquals(LOG10(100), 2);
1744+assertEquals(LOG10("100"), 2);
1745+assertEquals(LOG10(1), 0);
1746+assertEquals(LOG10(10.1), 1.0043213737826424);
1747+catchAndAssertEquals(function() {
1748+  LOG10(false);
1749+}, ERRORS.NUM_ERROR);
1750+catchAndAssertEquals(function() {
1751+  LOG10("");
1752+}, ERRORS.NUM_ERROR);
1753+catchAndAssertEquals(function() {
1754+  LOG10("str");
1755+}, ERRORS.VALUE_ERROR);
1756+catchAndAssertEquals(function() {
1757+  LOG10();
1758+}, ERRORS.NA_ERROR);
1759+catchAndAssertEquals(function() {
1760+  LOG10(10, 10);
1761+}, ERRORS.NA_ERROR);
1762+
1763+
1764+// Test MOD
1765+assertEquals(MOD(10, 3), 1);
1766+catchAndAssertEquals(function() {
1767+  MOD(10, 3, 10);
1768+}, ERRORS.NA_ERROR);
1769+catchAndAssertEquals(function() {
1770+  MOD([10, 3]);
1771+}, ERRORS.NA_ERROR);
1772+catchAndAssertEquals(function() {
1773+  MOD(0, 0);
1774+}, ERRORS.DIV_ZERO_ERROR);
1775+catchAndAssertEquals(function() {
1776+  MOD(10);
1777+}, ERRORS.NA_ERROR);
1778+catchAndAssertEquals(function() {
1779+  MOD(10, false);
1780+}, ERRORS.DIV_ZERO_ERROR);
1781+catchAndAssertEquals(function() {
1782+  MOD(10, 0);
1783+}, ERRORS.DIV_ZERO_ERROR);
1784+catchAndAssertEquals(function() {
1785+  MOD(10, "str");
1786+}, ERRORS.VALUE_ERROR);
1787+assertEquals(MOD(10, "3"), 1);
1788+assertEquals(MOD(10.1, 3), 1.0999999999999996);
1789+assertEquals(MOD(10, 3.1), 0.6999999999999997);
1790+
1791+
1792+
1793+// Test ODD
1794+assertEquals(ODD(2), 3);
1795+assertEquals(ODD(4), 5);
1796+assertEquals(ODD(5), 5);
1797+assertEquals(ODD("4"), 5);
1798+assertEquals(ODD(false), 1);
1799+assertEquals(ODD(true), 1);
1800+assertEquals(ODD([10, 22]), 11);
1801+assertEquals(ODD([10, 22, "str"]), 11);
1802+catchAndAssertEquals(function() {
1803+  ODD();
1804+}, ERRORS.NA_ERROR);
1805+catchAndAssertEquals(function() {
1806+  ODD(1, 2, 3);
1807+}, ERRORS.NA_ERROR);
1808+catchAndAssertEquals(function() {
1809+  ODD("str");
1810+}, ERRORS.VALUE_ERROR);
1811+
1812+
1813+// Test PI
1814+assertEquals(PI(), 3.141592653589793);
1815+
1816+
1817+// Test POWER
1818+assertEquals(POWER(4, 10), 1048576);
1819+assertEquals(POWER(4, false), 1);
1820+assertEquals(POWER(4, true), 4);
1821+assertEquals(POWER([4], [10]), 1048576);
1822+assertEquals(POWER([4], [10, "str"]), 1048576);
1823+catchAndAssertEquals(function() {
1824+  POWER(4, "str");
1825+}, ERRORS.VALUE_ERROR);
1826+catchAndAssertEquals(function() {
1827+  POWER();
1828+}, ERRORS.NA_ERROR);
1829+catchAndAssertEquals(function() {
1830+  POWER(4);
1831+}, ERRORS.NA_ERROR);
1832+catchAndAssertEquals(function() {
1833+  POWER(4, 10, 22);
1834+}, ERRORS.NA_ERROR);
1835+
1836+
1837+// Test RADIANS
1838+assertEquals(RADIANS(180), 3.141592653589793);
1839+assertEquals(RADIANS(false), 0);
1840+assertEquals(RADIANS(true), 0.017453292519943295);
1841+catchAndAssertEquals(function() {
1842+  RADIANS("str");
1843+}, ERRORS.VALUE_ERROR);
1844+catchAndAssertEquals(function() {
1845+  RADIANS();
1846+}, ERRORS.NA_ERROR);
1847+catchAndAssertEquals(function() {
1848+  RADIANS(4, 10);
1849+}, ERRORS.NA_ERROR);
1850+
1851+
1852+// Test ROUND
1853+assertEquals(ROUND(99.44, 1), 99.4);
1854+assertEquals(ROUND(99.44, 0), 99);
1855+assertEquals(ROUND(99.4444444444444, 9), 99.444444444);
1856+assertEquals(ROUND(99.44), 99);
1857+assertEquals(ROUND("99.44"), 99);
1858+assertEquals(ROUND([99.44, 22.222], [1, 4]), 99.4);
1859+catchAndAssertEquals(function() {
1860+  ROUND();
1861+}, ERRORS.NA_ERROR);
1862+catchAndAssertEquals(function() {
1863+  ROUND(99.44, 1, 44);
1864+}, ERRORS.NA_ERROR);
1865+catchAndAssertEquals(function() {
1866+  ROUND(99.999, "str");
1867+}, ERRORS.VALUE_ERROR);
1868+
1869+
1870+// Test ROUNDDOWN
1871+assertEquals(ROUNDDOWN(99.46, 1), 99.4);
1872+assertEquals(ROUNDDOWN(99.99, 1), 99.9);
1873+assertEquals(ROUNDDOWN(99.5555555555555, 9), 99.555555555);
1874+assertEquals(ROUNDDOWN(99.99), 99);
1875+assertEquals(ROUNDDOWN("99.99"), 99);
1876+assertEquals(ROUNDDOWN([99.46666, 22.222], [1, 4]), 99.4);
1877+catchAndAssertEquals(function() {
1878+  ROUNDDOWN();
1879+}, ERRORS.NA_ERROR);
1880+catchAndAssertEquals(function() {
1881+  ROUNDDOWN(99.44, 1, 44);
1882+}, ERRORS.NA_ERROR);
1883+catchAndAssertEquals(function() {
1884+  ROUNDDOWN(99.999, "str");
1885+}, ERRORS.VALUE_ERROR);
1886+
1887+
1888+// Test ROUNDUP
1889+assertEquals(ROUNDUP(99.46, 1), 99.5);
1890+assertEquals(ROUNDUP(99.99, 1), 100);
1891+assertEquals(ROUNDUP(99.5555555555555, 9), 99.555555556);
1892+assertEquals(ROUNDUP(99.99), 100);
1893+assertEquals(ROUNDUP("99.99"), 100);
1894+assertEquals(ROUNDUP([99.46666, 22.222], [1, 4]), 99.5);
1895+catchAndAssertEquals(function() {
1896+  ROUNDUP();
1897+}, ERRORS.NA_ERROR);
1898+catchAndAssertEquals(function() {
1899+  ROUNDUP(99.44, 1, 44);
1900+}, ERRORS.NA_ERROR);
1901+catchAndAssertEquals(function() {
1902+  ROUNDUP(99.999, "str");
1903+}, ERRORS.VALUE_ERROR);
1904+
1905+
1906+// Test SIN
1907+assertEquals(SIN(0), 0);
1908+assertEquals(SIN(1), 0.8414709848078965);
1909+assertEquals(SIN(PI() / 2), 1);
1910+assertEquals(SIN(PI()), 0);
1911+assertEquals(SIN(true), 0.8414709848078965);
1912+assertEquals(SIN(false), 0);
1913+assertEquals(SIN("0"), 0);
1914+assertEquals(SIN(""), 0);
1915+catchAndAssertEquals(function() {
1916+  SIN("str");
1917+}, ERRORS.VALUE_ERROR);
1918+assertEquals(SIN([1]), 0.8414709848078965);
1919+assertEquals(SIN([[1]]), 0.8414709848078965);
1920+assertEquals(SIN([1, "str"]), 0.8414709848078965);
1921+
1922+
1923+// Test SINH
1924+assertEquals(SINH(PI()), 11.548739357257748);
1925+assertEquals(SINH(1), 1.1752011936438014);
1926+assertEquals(SINH(false), 0);
1927+assertEquals(SINH(true), 1.1752011936438014);
1928+assertEquals(SINH(""), 0);
1929+assertEquals(SINH("0"), 0);
1930+catchAndAssertEquals(function() {
1931+  SINH("str");
1932+}, ERRORS.VALUE_ERROR);
1933+assertEquals(SINH([10]), 11013.232874703393);
1934+assertEquals(SINH([[10]]), 11013.232874703393);
1935+catchAndAssertEquals(function() {
1936+  SIN([[]]);
1937+}, ERRORS.REF_ERROR);
1938+assertEquals(SINH([[10, "str"]]), 11013.232874703393);
1939+
1940+
1941+// Test SQRT
1942+assertEquals(SQRT(9), 3);
1943+assertEquals(SQRT("9"), 3);
1944+assertEquals(SQRT(4), 2);
1945+assertEquals(SQRT(false), 0);
1946+assertEquals(SQRT(true), 1);
1947+assertEquals(SQRT(""), 0);
1948+catchAndAssertEquals(function() {
1949+  SQRT("str");
1950+}, ERRORS.VALUE_ERROR);
1951+catchAndAssertEquals(function() {
1952+  SQRT(-9);
1953+}, ERRORS.VALUE_ERROR);
1954+catchAndAssertEquals(function() {
1955+  SQRT();
1956+}, ERRORS.NA_ERROR);
1957+catchAndAssertEquals(function() {
1958+  SQRT(4, 4);
1959+}, ERRORS.NA_ERROR);
1960+
1961+
1962+// Test SQRTPI
1963+assertEquals(SQRTPI(9), 5.317361552716548);
1964+assertEquals(SQRTPI("9"), 5.317361552716548);
1965+assertEquals(SQRTPI([9]), 5.317361552716548);
1966+assertEquals(SQRTPI(0), 0);
1967+assertEquals(SQRTPI(1), 1.7724538509055159);
1968+assertEquals(SQRTPI(""), 0);
1969+catchAndAssertEquals(function() {
1970+  SQRTPI("str");
1971+}, ERRORS.VALUE_ERROR);
1972+catchAndAssertEquals(function() {
1973+  SQRTPI(-1);
1974+}, ERRORS.NUM_ERROR);
1975+catchAndAssertEquals(function() {
1976+  SQRTPI();
1977+}, ERRORS.NA_ERROR);
1978+catchAndAssertEquals(function() {
1979+  SQRTPI(4, 4);
1980+}, ERRORS.NA_ERROR);
1981+
1982+
1983+// Test SUM
1984+assertEquals(SUM(10), 10);
1985+assertEquals(SUM(10, 10), 20);
1986+assertEquals(SUM(10, [5, 5]), 20);
1987+assertEquals(SUM("10", [5, 5]), 20);
1988+assertEquals(SUM(false, [10, 10]), 20);
1989+assertEquals(SUM(true, [10, 10]), 21);
1990+catchAndAssertEquals(function() {
1991+  SUM([10, 10], "");
1992+}, ERRORS.VALUE_ERROR);
1993+catchAndAssertEquals(function() {
1994+  SUM([10, 10], "str");
1995+}, ERRORS.VALUE_ERROR);
1996+catchAndAssertEquals(function() {
1997+  SUM();
1998+}, ERRORS.NA_ERROR);
1999+
2000+
2001+// Test SUMIF
2002+assertEquals(SUMIF([1, 5, 10], 5), 5);
2003+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], 5), 20);
2004+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], 10), 10);
2005+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">5"), 10);
2006+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=5"), 20);
2007+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=1"), 1);
2008+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=     1  "), 1);
2009+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">0"), 31);
2010+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">=5"), 30);
2011+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "<10"), 21);
2012+assertEquals(SUMIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 31);
2013+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">4.99"), 30);
2014+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
2015+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
2016+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=>5"), 0);
2017+assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "==5"), 0);
2018+assertEquals(SUMIF(["m", "m", 3, 11, true], "m"), 0);
2019+assertEquals(SUMIF(["m", "p", "m"], "m", [1, 1, 1]), 2);
2020+assertEquals(SUMIF(["p", "p", "p"], "m", [1, 1, 1]), 0);
2021+assertEquals(SUMIF(["p", "p", "p"], "", [1, 1, 1]), 0);
2022+assertEquals(SUMIF(["p", "p", "p"], "*", [1, 1, 1]), 3);
2023+assertEquals(SUMIF(["mom", "pop", "pap"], "*o*", [1, 1, 1]), 2);
2024+assertEquals(SUMIF(["mom", "pop", "pap"], "*a*", [1, 1, 1]), 1);
2025+assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1, 1]), 2);
2026+assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1, 1]), 2);
2027+assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1,]), 1);
2028+assertEquals(SUMIF(["pop", "pap"], "p*p", [1, 2, 4]), 3);
2029+assertEquals(SUMIF(["mom", "pop", "dad", "etc", "boom"], "*o*", [1, 1, 1, 1, 1]), 3);
2030+assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "mom", [1, 1, 1, 1, 1]), 2);
2031+assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "?o?", [1, 1, 1, 1, 1]), 3);
2032+assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "???", [1, 1, 1, 1, 1]), 5);
2033+assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "????", [1, 1, 1, 1, 1]), 0);
2034+assertEquals(SUMIF([0, 1, 0, 1], "=1", [1, 2, 4, 8]), 10);
2035+catchAndAssertEquals(function() {
2036+  SUMIF([0, 1, 0, 1]);
2037+}, ERRORS.NA_ERROR);
2038+catchAndAssertEquals(function() {
2039+  SUMIF();
2040+}, ERRORS.NA_ERROR);
2041+catchAndAssertEquals(function() {
2042+  SUMIF([], "=1", [], true);
2043+}, ERRORS.NA_ERROR);
2044+
2045+
2046+// Test SUMPRODUCT
2047+assertEquals(SUMPRODUCT([1, 5, 10], [2, 2, 2]), 32);
2048+assertEquals(SUMPRODUCT([1, 5, 10], [2, 2, 2], [2, 2, 2]), 64);
2049+assertEquals(SUMPRODUCT([1, 5, 10], [1, 2, 2], [1, 4, 4]), 121);
2050+assertEquals(SUMPRODUCT([1, 5, 10]), 16);
2051+assertEquals(SUMPRODUCT([1, 5, 10, ""]), 16);
2052+assertEquals(SUMPRODUCT([1, 5, 10, 200], [2, 2, 2, ""]), 32);
2053+assertEquals(SUMPRODUCT([1, 5, 10, "str"]), 16);
2054+assertEquals(SUMPRODUCT([10, 10, 22, "str"], [2, 2, [2, 2]]), 84);
2055+assertEquals(SUMPRODUCT(1, 5, 10), 50);
2056+assertEquals(SUMPRODUCT([1, 5, 10]), 16);
2057+catchAndAssertEquals(function() {
2058+  SUMPRODUCT([1, 5, 10], [2, 2]);
2059+}, ERRORS.VALUE_ERROR);
2060+catchAndAssertEquals(function() {
2061+  SUMPRODUCT([1, 5, 10], [2, 2, 2, []]);
2062+}, ERRORS.REF_ERROR);
2063+catchAndAssertEquals(function() {
2064+  SUMPRODUCT();
2065+}, ERRORS.NA_ERROR);
2066+
2067+
2068+
2069+// Test SUMSQ
2070+assertEquals(SUMSQ([1, 5, 10], 10), 226);
2071+assertEquals(SUMSQ([10, 10, 22, ""]), 684);
2072+assertEquals(SUMSQ(10, 10, 22), 684);
2073+assertEquals(SUMSQ(10, 10, "22", true), 685);
2074+assertEquals(SUMSQ(10, 10, "22", false), 684);
2075+assertEquals(SUMSQ([10, 10, 22, true]), 684);
2076+catchAndAssertEquals(function() {
2077+  SUMSQ([10, 10, 22, "", []]);
2078+}, ERRORS.REF_ERROR);
2079+catchAndAssertEquals(function() {
2080+  SUMSQ([]);
2081+}, ERRORS.REF_ERROR);
2082+catchAndAssertEquals(function() {
2083+  SUMSQ();
2084+}, ERRORS.NA_ERROR);
2085+
2086+
2087+// Test SUMX2MY2
2088+assertEquals(SUMX2MY2([1,2,3],[4,5,6]), -63);
2089+assertEquals(SUMX2MY2([1, 2, 3], [[4, 5], [6]]), -63);
2090+assertEquals(SUMX2MY2(["1",2,3],[4,5,6]), -48);
2091+assertEquals(SUMX2MY2(["",2,3],[4,5,6]), -48);
2092+assertEquals(SUMX2MY2([false,2,3],[4,5,6]), -48);
2093+assertEquals(SUMX2MY2([true,2,3],[4,5,6]), -48);
2094+catchAndAssertEquals(function() {
2095+  SUMX2MY2([1,2,3],[4,5, []]);
2096+}, ERRORS.REF_ERROR);
2097+catchAndAssertEquals(function() {
2098+  SUMX2MY2([1,2,3],[4,5]);
2099+}, ERRORS.NA_ERROR);
2100+catchAndAssertEquals(function() {
2101+  SUMX2MY2();
2102+}, ERRORS.NA_ERROR);
2103+
2104+
2105+// Test SUMX2PY2
2106+assertEquals(SUMX2PY2([1, 2, 3], [4, 5, 6]), 91);
2107+assertEquals(SUMX2PY2([1, 2, 3], [[4, 5], [6]]), 91);
2108+assertEquals(SUMX2PY2(["1",2,3],[4,5,6]), 74);
2109+assertEquals(SUMX2PY2(["",2,3],[4,5,6]), 74);
2110+assertEquals(SUMX2PY2([false,2,3],[4,5,6]), 74);
2111+assertEquals(SUMX2PY2([true,2,3],[4,5,6]), 74);
2112+catchAndAssertEquals(function() {
2113+  SUMX2PY2([1,2,3],[4,5, []]);
2114+}, ERRORS.REF_ERROR);
2115+catchAndAssertEquals(function() {
2116+  SUMX2PY2([1,2,3],[4,5]);
2117+}, ERRORS.NA_ERROR);
2118+catchAndAssertEquals(function() {
2119+  SUMX2PY2();
2120+}, ERRORS.NA_ERROR);
2121+
2122+
2123+// Test TAN
2124+assertEquals(TAN(0), 0);
2125+assertEquals(TAN(1), 1.5574077246549023);
2126+assertEquals(TAN(PI() / 2), 16331239353195370);
2127+assertEquals(TAN(PI()), 0);
2128+assertEquals(TAN(false), 0);
2129+assertEquals(TAN(true), 1.5574077246549023);
2130+assertEquals(TAN(""), 0);
2131+assertEquals(TAN("0"), 0);
2132+catchAndAssertEquals(function() {
2133+  TAN("str");
2134+}, ERRORS.VALUE_ERROR);
2135+catchAndAssertEquals(function() {
2136+  TAN();
2137+}, ERRORS.NA_ERROR);
2138+catchAndAssertEquals(function() {
2139+  TAN(1, 1);
2140+}, ERRORS.NA_ERROR);
2141+assertEquals(TAN([1, 44]), 1.5574077246549023);
2142+assertEquals(TAN([1, "str"]), 1.5574077246549023);
2143+
2144+
2145+// Test TANH
2146+assertEquals(TANH(0), 0);
2147+assertEquals(TANH(1), 0.7615941559557649);
2148+assertEquals(TANH(PI() / 2), 0.9171523356672744);
2149+assertEquals(TANH(PI()), 0.9962720762207501);
2150+assertEquals(TANH(false), 0);
2151+assertEquals(TANH(true), 0.7615941559557649);
2152+assertEquals(TANH(""), 0);
2153+assertEquals(TANH("0"), 0);
2154+catchAndAssertEquals(function() {
2155+  TANH("str");
2156+}, ERRORS.VALUE_ERROR);
2157+catchAndAssertEquals(function() {
2158+  TANH();
2159+}, ERRORS.NA_ERROR);
2160+catchAndAssertEquals(function() {
2161+  TANH(1, 1);
2162+}, ERRORS.NA_ERROR);
2163+assertEquals(TANH([1, 44]), 0.7615941559557649);
2164+assertEquals(TANH([1, "str"]), 0.7615941559557649);
2165+
2166+
2167+// Test TRUNC
2168+assertEquals(TRUNC(PI(), 2), 3.14);
2169+assertEquals(TRUNC("3.141592653589793", "2"), 3.14);
2170+assertEquals(TRUNC(PI(), 1), 3.1);
2171+assertEquals(TRUNC(PI(), 0), 3);
2172+assertEquals(TRUNC(PI(), false), 3);
2173+assertEquals(TRUNC(PI(), -1), 0);
2174+assertEquals(TRUNC(31.41592653589793, -1), 30);
2175+assertEquals(TRUNC([31.41592653589793], [-1]), 30);
2176+assertEquals(TRUNC(31111.41592653589793, -4), 30000);
2177+assertEquals(TRUNC(31111.41592653589793, -2), 31100);
2178+catchAndAssertEquals(function() {
2179+  TRUNC();
2180+}, ERRORS.NA_ERROR);
2181+catchAndAssertEquals(function() {
2182+  TRUNC(3.1, 1, 1);
2183+}, ERRORS.NA_ERROR);