spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[tests] labeling and logging sets of tests
author
Ben Vogt <[email protected]>
date
2017-04-30 18:05:25
stats
15 file(s) changed, 4769 insertions(+), 3573 deletions(-)
files
README.md
tests/CellTest.ts
tests/Formulas/DateFormulasTest.ts
tests/Formulas/DateFormulasTestTimeOverride.ts
tests/Formulas/EngineeringTest.ts
tests/Formulas/FinancialTest.ts
tests/Formulas/HelperTest.ts
tests/Formulas/LogicalTest.ts
tests/Formulas/MathTest.ts
tests/Formulas/StatisticalTest.ts
tests/Formulas/TextTest.ts
tests/SheetFormulaTest.ts
tests/SheetParseTest.ts
tests/SheetTest.ts
tests/utils/Asserts.ts
   1diff --git a/README.md b/README.md
   2index c2e8def..609e2e9 100644
   3--- a/README.md
   4+++ b/README.md
   5@@ -43,6 +43,8 @@ Right now we're just using the number of days since 1900, but we should check th
   6 
   7 ### Numbers with commas in them should still parse to numbers.
   8 
   9+### Ensure all formulas are tested inside of SheetFormulaTest.ts
  10+
  11 
  12 ## Testing Guidelines
  13 
  14diff --git a/tests/CellTest.ts b/tests/CellTest.ts
  15index 84b20f7..c00baa3 100644
  16--- a/tests/CellTest.ts
  17+++ b/tests/CellTest.ts
  18@@ -1,22 +1,31 @@
  19-import { Cell } from "../src/Cell"
  20-import { assertEquals, assertArrayEquals } from "./utils/Asserts"
  21+import {
  22+  Cell
  23+} from "../src/Cell";
  24+import {
  25+  assertEquals,
  26+  assertArrayEquals,
  27+  test
  28+} from "./utils/Asserts";
  29 
  30-//Test constructor
  31-var cell = new Cell("A1");
  32-assertEquals(cell.getColumn(), 0);
  33-assertEquals(cell.getRow(), 0);
  34-assertArrayEquals(cell.getDependencies(), []);
  35-assertEquals(cell.getId(), "A1");
  36-assertEquals(cell.getFormula(), null);
  37+test("Cell.constructor", function(){
  38+  var cell = new Cell("A1");
  39+  assertEquals(cell.getColumn(), 0);
  40+  assertEquals(cell.getRow(), 0);
  41+  assertArrayEquals(cell.getDependencies(), []);
  42+  assertEquals(cell.getId(), "A1");
  43+  assertEquals(cell.getFormula(), null);
  44+});
  45 
  46-//Test updateDependencies
  47-var one = new Cell("A1");
  48-one.updateDependencies(["B2", "C1", "D12", "D13"]);
  49-assertArrayEquals(one.getDependencies(), ["B2", "C1", "D12", "D13"]);
  50-one.updateDependencies(["M4"]);
  51-assertArrayEquals(one.getDependencies(), ["B2", "C1", "D12", "D13", "M4"]);
  52+test("Cell.updateDependencies", function(){
  53+  var one = new Cell("A1");
  54+  one.updateDependencies(["B2", "C1", "D12", "D13"]);
  55+  assertArrayEquals(one.getDependencies(), ["B2", "C1", "D12", "D13"]);
  56+  one.updateDependencies(["M4"]);
  57+  assertArrayEquals(one.getDependencies(), ["B2", "C1", "D12", "D13", "M4"]);
  58+});
  59 
  60-//Test setValue
  61-var v = new Cell("A1");
  62-v.setValue("100");
  63-assertEquals("100", v.getValue());
  64+test("Cell.setValue", function(){
  65+  var v = new Cell("A1");
  66+  v.setValue("100");
  67+  assertEquals("100", v.getValue());
  68+});
  69diff --git a/tests/Formulas/DateFormulasTest.ts b/tests/Formulas/DateFormulasTest.ts
  70index b66bf0e..cf0c7be 100644
  71--- a/tests/Formulas/DateFormulasTest.ts
  72+++ b/tests/Formulas/DateFormulasTest.ts
  73@@ -25,1989 +25,2008 @@ import {
  74 import * as ERRORS from "../../src/Errors";
  75 import {
  76   assertEquals,
  77-  catchAndAssertEquals
  78+  catchAndAssertEquals,
  79+  test
  80 } from "../utils/Asserts"
  81 
  82 
  83-// Test WORKDAY.INTL
  84-assertEquals(WORKDAY$INTL(DATE(1999, 2, 2), 10), DATE(1999, 2, 16));
  85-assertEquals(WORKDAY$INTL(DATE(1999, 10, 10), 100), DATE(2000, 2, 25));
  86-assertEquals(WORKDAY$INTL(DATE(1909, 12, 11), 222), DATE(1910, 10, 18));
  87-assertEquals(WORKDAY$INTL(DATE(1922, 4, 1), 1234), DATE(1926, 12, 23));
  88-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000), DATE(1968, 1, 12));
  89-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "0000011"), DATE(1968, 1, 12));
  90-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1000001"), DATE(1968, 1, 13));
  91-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1100001"), DATE(1973, 10, 13));
  92-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1110000"), DATE(1973, 10, 14));
  93-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1110001"), DATE(1983, 5, 14));
  94-assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, 6), DATE(1968, 1, 14));
  95-catchAndAssertEquals(function() {
  96-  WORKDAY$INTL(12, 12, [12], false, 1);
  97-}, ERRORS.NA_ERROR);
  98-catchAndAssertEquals(function() {
  99-  WORKDAY$INTL(12);
 100-}, ERRORS.NA_ERROR);
 101-catchAndAssertEquals(function() {
 102-  WORKDAY$INTL("1992-1-1", "str");
 103-}, ERRORS.VALUE_ERROR);
 104-catchAndAssertEquals(function() {
 105-  WORKDAY$INTL("1992-1-1", 12, []);
 106-}, ERRORS.REF_ERROR);
 107-catchAndAssertEquals(function() {
 108-  WORKDAY$INTL("1992-1-1", 16, "000");
 109-}, ERRORS.NUM_ERROR);
 110-catchAndAssertEquals(function() {
 111-  WORKDAY$INTL("1992-1-1", 12, 9);
 112-}, ERRORS.NUM_ERROR);
 113-catchAndAssertEquals(function() {
 114-  WORKDAY$INTL("1992-1-1", 66, false);
 115-}, ERRORS.VALUE_ERROR);
 116+test("WORKDAY.INTL", function () {
 117+  assertEquals(WORKDAY$INTL(DATE(1999, 2, 2), 10), DATE(1999, 2, 16));
 118+  assertEquals(WORKDAY$INTL(DATE(1999, 10, 10), 100), DATE(2000, 2, 25));
 119+  assertEquals(WORKDAY$INTL(DATE(1909, 12, 11), 222), DATE(1910, 10, 18));
 120+  assertEquals(WORKDAY$INTL(DATE(1922, 4, 1), 1234), DATE(1926, 12, 23));
 121+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000), DATE(1968, 1, 12));
 122+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "0000011"), DATE(1968, 1, 12));
 123+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1000001"), DATE(1968, 1, 13));
 124+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1100001"), DATE(1973, 10, 13));
 125+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1110000"), DATE(1973, 10, 14));
 126+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, "1110001"), DATE(1983, 5, 14));
 127+  assertEquals(WORKDAY$INTL(DATE(1945, 1, 14), 6000, 6), DATE(1968, 1, 14));
 128+  catchAndAssertEquals(function() {
 129+    WORKDAY$INTL(12, 12, [12], false, 1);
 130+  }, ERRORS.NA_ERROR);
 131+  catchAndAssertEquals(function() {
 132+    WORKDAY$INTL(12);
 133+  }, ERRORS.NA_ERROR);
 134+  catchAndAssertEquals(function() {
 135+    WORKDAY$INTL("1992-1-1", "str");
 136+  }, ERRORS.VALUE_ERROR);
 137+  catchAndAssertEquals(function() {
 138+    WORKDAY$INTL("1992-1-1", 12, []);
 139+  }, ERRORS.REF_ERROR);
 140+  catchAndAssertEquals(function() {
 141+    WORKDAY$INTL("1992-1-1", 16, "000");
 142+  }, ERRORS.NUM_ERROR);
 143+  catchAndAssertEquals(function() {
 144+    WORKDAY$INTL("1992-1-1", 12, 9);
 145+  }, ERRORS.NUM_ERROR);
 146+  catchAndAssertEquals(function() {
 147+    WORKDAY$INTL("1992-1-1", 66, false);
 148+  }, ERRORS.VALUE_ERROR);
 149+});
 150 
 151 
 152-// Test WORKDAY
 153-assertEquals(WORKDAY(DATE(1999, 2, 2), 10), DATE(1999, 2, 16));
 154-assertEquals(WORKDAY(DATE(1999, 10, 10), 100), DATE(2000, 2, 25));
 155-assertEquals(WORKDAY(DATE(1909, 12, 11), 222), DATE(1910, 10, 18));
 156-assertEquals(WORKDAY(DATE(1922, 4, 1), 1234), DATE(1926, 12, 23));
 157-assertEquals(WORKDAY(DATE(1945, 1, 14), 6000), DATE(1968, 1, 12));
 158-assertEquals(WORKDAY(DATE(1945, 1, 14), 6000, [23855, 23856, 23857, 23858, 23859]), DATE(1968, 1, 17));
 159-assertEquals(WORKDAY(DATE(1945, 1, 14), 6000, 23859), DATE(1968, 1, 15));
 160-assertEquals(WORKDAY(DATE(2012, 5, 29), 1000, [41058, 41059, 41060, 41061, 41062]), DATE(2016, 4, 1));
 161-assertEquals(WORKDAY([DATE(1999, 2, 2)], [10]), DATE(1999, 2, 16));
 162-catchAndAssertEquals(function() {
 163-  WORKDAY();
 164-}, ERRORS.NA_ERROR);
 165-catchAndAssertEquals(function() {
 166-  WORKDAY(DATE(2012, 5, 29), 1000, [10], 11);
 167-}, ERRORS.NA_ERROR);
 168+test("WORKDAY", function () {
 169+  assertEquals(WORKDAY(DATE(1999, 2, 2), 10), DATE(1999, 2, 16));
 170+  assertEquals(WORKDAY(DATE(1999, 10, 10), 100), DATE(2000, 2, 25));
 171+  assertEquals(WORKDAY(DATE(1909, 12, 11), 222), DATE(1910, 10, 18));
 172+  assertEquals(WORKDAY(DATE(1922, 4, 1), 1234), DATE(1926, 12, 23));
 173+  assertEquals(WORKDAY(DATE(1945, 1, 14), 6000), DATE(1968, 1, 12));
 174+  assertEquals(WORKDAY(DATE(1945, 1, 14), 6000, [23855, 23856, 23857, 23858, 23859]), DATE(1968, 1, 17));
 175+  assertEquals(WORKDAY(DATE(1945, 1, 14), 6000, 23859), DATE(1968, 1, 15));
 176+  assertEquals(WORKDAY(DATE(2012, 5, 29), 1000, [41058, 41059, 41060, 41061, 41062]), DATE(2016, 4, 1));
 177+  assertEquals(WORKDAY([DATE(1999, 2, 2)], [10]), DATE(1999, 2, 16));
 178+  catchAndAssertEquals(function() {
 179+    WORKDAY();
 180+  }, ERRORS.NA_ERROR);
 181+  catchAndAssertEquals(function() {
 182+    WORKDAY(DATE(2012, 5, 29), 1000, [10], 11);
 183+  }, ERRORS.NA_ERROR);
 184+});
 185 
 186 
 187-// Test TIME
 188-assertEquals(TIME(10, 10, 10).toNumber(), 0.4237268518518518);
 189-assertEquals(TIME(34, 10, 10).toNumber(), 0.4237268518518518);
 190-assertEquals(TIME(29, 10, 10).toNumber(), 0.2153935185185185);
 191-assertEquals(TIME(13, 9, 6).toNumber(), 0.5479861111111111);
 192-assertEquals(TIME(3, 1, 14).toNumber(), 0.12585648148148149);
 193-assertEquals(TIME(0, 0, 0).toNumber(), 0);
 194-assertEquals(TIME(24, 0, 0).toNumber(), 0);
 195-assertEquals(TIME(23, 60, 0).toNumber(), 0);
 196-assertEquals(TIME(23, 59, 60).toNumber(), 0);
 197-assertEquals(TIME(18, 0, 0).toNumber(), 0.75);
 198-assertEquals(TIME(12, 0, 0).toNumber(), 0.5);
 199-assertEquals(TIME(6, 0, 0).toNumber(), 0.25);
 200-assertEquals(TIME(3, 0, 0).toNumber(), 0.125);
 201-assertEquals(TIME("3", ["0"], false).toNumber(), 0.125);
 202-catchAndAssertEquals(function() {
 203-  TIME();
 204-}, ERRORS.NA_ERROR);
 205-catchAndAssertEquals(function() {
 206-  TIME(1, 1);
 207-}, ERRORS.NA_ERROR);
 208-catchAndAssertEquals(function() {
 209-  TIME(1, 1, 1, 1);
 210-}, ERRORS.NA_ERROR);
 211-catchAndAssertEquals(function() {
 212-  TIME(-29, 10, 10);
 213-}, ERRORS.NUM_ERROR);
 214-catchAndAssertEquals(function() {
 215-  TIME(1, 1, []);
 216-}, ERRORS.REF_ERROR);
 217+test("TIME", function () {
 218+  assertEquals(TIME(10, 10, 10).toNumber(), 0.4237268518518518);
 219+  assertEquals(TIME(34, 10, 10).toNumber(), 0.4237268518518518);
 220+  assertEquals(TIME(29, 10, 10).toNumber(), 0.2153935185185185);
 221+  assertEquals(TIME(13, 9, 6).toNumber(), 0.5479861111111111);
 222+  assertEquals(TIME(3, 1, 14).toNumber(), 0.12585648148148149);
 223+  assertEquals(TIME(0, 0, 0).toNumber(), 0);
 224+  assertEquals(TIME(24, 0, 0).toNumber(), 0);
 225+  assertEquals(TIME(23, 60, 0).toNumber(), 0);
 226+  assertEquals(TIME(23, 59, 60).toNumber(), 0);
 227+  assertEquals(TIME(18, 0, 0).toNumber(), 0.75);
 228+  assertEquals(TIME(12, 0, 0).toNumber(), 0.5);
 229+  assertEquals(TIME(6, 0, 0).toNumber(), 0.25);
 230+  assertEquals(TIME(3, 0, 0).toNumber(), 0.125);
 231+  assertEquals(TIME("3", ["0"], false).toNumber(), 0.125);
 232+  catchAndAssertEquals(function() {
 233+    TIME();
 234+  }, ERRORS.NA_ERROR);
 235+  catchAndAssertEquals(function() {
 236+    TIME(1, 1);
 237+  }, ERRORS.NA_ERROR);
 238+  catchAndAssertEquals(function() {
 239+    TIME(1, 1, 1, 1);
 240+  }, ERRORS.NA_ERROR);
 241+  catchAndAssertEquals(function() {
 242+    TIME(-29, 10, 10);
 243+  }, ERRORS.NUM_ERROR);
 244+  catchAndAssertEquals(function() {
 245+    TIME(1, 1, []);
 246+  }, ERRORS.REF_ERROR);
 247+});
 248 
 249 
 250-// Test NETWORKDAYS$INTL
 251-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30"), 22);
 252-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1"), 263);
 253-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4"), 264);
 254-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5"), 265);
 255-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6"), 266);
 256-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7"), 267);
 257-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8"), 268);
 258-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9"), 268);
 259-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "0000011"), 22);
 260-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1", "0000011"), 263);
 261-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4", "0000011"), 264);
 262-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5", "0000011"), 265);
 263-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6", "0000011"), 266);
 264-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7", "0000011"), 267);
 265-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8", "0000011"), 268);
 266-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9", "0000011"), 268);
 267-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", 1), 22);
 268-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1", 1), 263);
 269-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4", 1), 264);
 270-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5", 1), 265);
 271-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6", 1), 266);
 272-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7", 1), 267);
 273-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8", 1), 268);
 274-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9", 1), 268);
 275-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-6", "1110011"), 2);
 276-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-14", "1110011"), 4);
 277-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "1110011"), 9);
 278-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "0001110"), 17);
 279-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", "0001110"), 29);
 280-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-2-22", "0001110"), 239);
 281-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", "0000110"), 37);
 282-assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", 1, [DATE(1992, 1, 10), DATE(1992, 1, 11), DATE(1992, 1, 12), DATE(1992, 1, 13), DATE(1992, 1, 14)]), 35);
 283-assertEquals(NETWORKDAYS$INTL(["1992-1-1"], ["1992-1-30"], ["0000011"]), 22);
 284-catchAndAssertEquals(function() {
 285-  NETWORKDAYS$INTL(12, 12, [12], false, 1);
 286-}, ERRORS.NA_ERROR);
 287-catchAndAssertEquals(function() {
 288-  NETWORKDAYS$INTL(12);
 289-}, ERRORS.NA_ERROR);
 290-catchAndAssertEquals(function() {
 291-  NETWORKDAYS$INTL("1992-1-1", "str");
 292-}, ERRORS.VALUE_ERROR);
 293-catchAndAssertEquals(function() {
 294-  NETWORKDAYS$INTL(12, 12, 1, ["1992-11-1"]);
 295-}, ERRORS.VALUE_ERROR);
 296-catchAndAssertEquals(function() {
 297-  NETWORKDAYS$INTL("1992-1-1", "1992-1-1", []);
 298-}, ERRORS.REF_ERROR);
 299-catchAndAssertEquals(function() {
 300-  NETWORKDAYS$INTL("1992-1-1", "1994-1-1", "000");
 301-}, ERRORS.NUM_ERROR);
 302-catchAndAssertEquals(function() {
 303-  NETWORKDAYS$INTL("1992-1-1", "1994-1-1", 9);
 304-}, ERRORS.NUM_ERROR);
 305-catchAndAssertEquals(function() {
 306-  NETWORKDAYS$INTL("1992-1-1", "1994-1-1", false);
 307-}, ERRORS.VALUE_ERROR);
 308+test("NETWORKDAYS$INTL", function () {
 309+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30"), 22);
 310+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1"), 263);
 311+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4"), 264);
 312+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5"), 265);
 313+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6"), 266);
 314+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7"), 267);
 315+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8"), 268);
 316+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9"), 268);
 317+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "0000011"), 22);
 318+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1", "0000011"), 263);
 319+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4", "0000011"), 264);
 320+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5", "0000011"), 265);
 321+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6", "0000011"), 266);
 322+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7", "0000011"), 267);
 323+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8", "0000011"), 268);
 324+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9", "0000011"), 268);
 325+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", 1), 22);
 326+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-1", 1), 263);
 327+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-4", 1), 264);
 328+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-5", 1), 265);
 329+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-6", 1), 266);
 330+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-7", 1), 267);
 331+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-8", 1), 268);
 332+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-1-9", 1), 268);
 333+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-6", "1110011"), 2);
 334+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-14", "1110011"), 4);
 335+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "1110011"), 9);
 336+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-1-30", "0001110"), 17);
 337+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", "0001110"), 29);
 338+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1993-2-22", "0001110"), 239);
 339+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", "0000110"), 37);
 340+  assertEquals(NETWORKDAYS$INTL("1992-1-1", "1992-2-22", 1, [DATE(1992, 1, 10), DATE(1992, 1, 11), DATE(1992, 1, 12), DATE(1992, 1, 13), DATE(1992, 1, 14)]), 35);
 341+  assertEquals(NETWORKDAYS$INTL(["1992-1-1"], ["1992-1-30"], ["0000011"]), 22);
 342+  catchAndAssertEquals(function() {
 343+    NETWORKDAYS$INTL(12, 12, [12], false, 1);
 344+  }, ERRORS.NA_ERROR);
 345+  catchAndAssertEquals(function() {
 346+    NETWORKDAYS$INTL(12);
 347+  }, ERRORS.NA_ERROR);
 348+  catchAndAssertEquals(function() {
 349+    NETWORKDAYS$INTL("1992-1-1", "str");
 350+  }, ERRORS.VALUE_ERROR);
 351+  catchAndAssertEquals(function() {
 352+    NETWORKDAYS$INTL(12, 12, 1, ["1992-11-1"]);
 353+  }, ERRORS.VALUE_ERROR);
 354+  catchAndAssertEquals(function() {
 355+    NETWORKDAYS$INTL("1992-1-1", "1992-1-1", []);
 356+  }, ERRORS.REF_ERROR);
 357+  catchAndAssertEquals(function() {
 358+    NETWORKDAYS$INTL("1992-1-1", "1994-1-1", "000");
 359+  }, ERRORS.NUM_ERROR);
 360+  catchAndAssertEquals(function() {
 361+    NETWORKDAYS$INTL("1992-1-1", "1994-1-1", 9);
 362+  }, ERRORS.NUM_ERROR);
 363+  catchAndAssertEquals(function() {
 364+    NETWORKDAYS$INTL("1992-1-1", "1994-1-1", false);
 365+  }, ERRORS.VALUE_ERROR);
 366+});
 367 
 368 
 369-// Test NETWORKDAYS
 370-assertEquals(NETWORKDAYS("1992-1-1", "1992-1-30"), 22);
 371-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-1"), 263);
 372-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-4"), 264);
 373-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-5"), 265);
 374-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-6"), 266);
 375-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-7"), 267);
 376-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-8"), 268);
 377-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-9"), 268);
 378-assertEquals(NETWORKDAYS("1992-1-1", "2000-4-24"), 2169);
 379-assertEquals(NETWORKDAYS("1992-1-1", false), -24003);
 380-assertEquals(NETWORKDAYS("2020-12-12", 0), -31555);
 381-assertEquals(NETWORKDAYS(12, 1423), 1008);
 382-assertEquals(NETWORKDAYS(12, 12), 1);
 383-assertEquals(NETWORKDAYS(DATE(1900, 1, 11), 12), 1);
 384-assertEquals(NETWORKDAYS(DATE(1998, 1, 1), DATE(1999, 1, 22)), 277);
 385-// Single holiday test
 386-assertEquals(NETWORKDAYS("1992-1-1", "1992-1-30", [DATEVALUE("1992-1-22")]), 21);
 387-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-1", [DATEVALUE("1992-6-19")]), 262);
 388-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-4", [DATEVALUE("1992-6-19")]), 263);
 389-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-5", [DATEVALUE("1992-6-19")]), 264);
 390-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-6", [DATEVALUE("1992-6-19")]), 265);
 391-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-7", [DATEVALUE("1992-6-19"), DATEVALUE("1992-6-18")]), 265);
 392-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-8", [DATEVALUE("1992-6-19")]), 267);
 393-assertEquals(NETWORKDAYS("1992-1-1", "1993-1-9", [DATEVALUE("1992-6-19")]), 267);
 394-assertEquals(NETWORKDAYS("1992-1-1", "2000-4-24", [DATEVALUE("1992-6-19")]), 2168);
 395-assertEquals(NETWORKDAYS("1992-1-1", false, [DATEVALUE("1991-6-19")]), -24002);
 396-assertEquals(NETWORKDAYS("2020-12-12", 0, [DATEVALUE("1992-6-19")]), -31554);
 397-assertEquals(NETWORKDAYS(12, 1423, [22]), 1008);// weekend and holdiay overlapping
 398-assertEquals(NETWORKDAYS(12, 1423, [20]), 1007);
 399-assertEquals(NETWORKDAYS(12, 12, [12]), 0);
 400-assertEquals(NETWORKDAYS(DATE(1998, 1, 1), DATE(1999, 1, 22), [DATE(1999, 1, 20)]), 276);
 401-catchAndAssertEquals(function() {
 402-  NETWORKDAYS(12, 12, [12], false);
 403-}, ERRORS.NA_ERROR);
 404-catchAndAssertEquals(function() {
 405-  NETWORKDAYS(12);
 406-}, ERRORS.NA_ERROR);
 407-catchAndAssertEquals(function() {
 408-  NETWORKDAYS("1992-1-1", "str");
 409-}, ERRORS.VALUE_ERROR);
 410-catchAndAssertEquals(function() {
 411-  NETWORKDAYS(12, 12, ["1992-11-1"]);
 412-}, ERRORS.VALUE_ERROR);
 413-catchAndAssertEquals(function() {
 414-  NETWORKDAYS("1992-1-1", "1992-1-1", []);
 415-}, ERRORS.REF_ERROR);
 416+test("NETWORKDAYS", function(){
 417+  assertEquals(NETWORKDAYS("1992-1-1", "1992-1-30"), 22);
 418+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-1"), 263);
 419+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-4"), 264);
 420+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-5"), 265);
 421+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-6"), 266);
 422+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-7"), 267);
 423+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-8"), 268);
 424+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-9"), 268);
 425+  assertEquals(NETWORKDAYS("1992-1-1", "2000-4-24"), 2169);
 426+  assertEquals(NETWORKDAYS("1992-1-1", false), -24003);
 427+  assertEquals(NETWORKDAYS("2020-12-12", 0), -31555);
 428+  assertEquals(NETWORKDAYS(12, 1423), 1008);
 429+  assertEquals(NETWORKDAYS(12, 12), 1);
 430+  assertEquals(NETWORKDAYS(DATE(1900, 1, 11), 12), 1);
 431+  assertEquals(NETWORKDAYS(DATE(1998, 1, 1), DATE(1999, 1, 22)), 277);
 432+  // Single holiday test
 433+  assertEquals(NETWORKDAYS("1992-1-1", "1992-1-30", [DATEVALUE("1992-1-22")]), 21);
 434+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-1", [DATEVALUE("1992-6-19")]), 262);
 435+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-4", [DATEVALUE("1992-6-19")]), 263);
 436+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-5", [DATEVALUE("1992-6-19")]), 264);
 437+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-6", [DATEVALUE("1992-6-19")]), 265);
 438+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-7", [DATEVALUE("1992-6-19"), DATEVALUE("1992-6-18")]), 265);
 439+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-8", [DATEVALUE("1992-6-19")]), 267);
 440+  assertEquals(NETWORKDAYS("1992-1-1", "1993-1-9", [DATEVALUE("1992-6-19")]), 267);
 441+  assertEquals(NETWORKDAYS("1992-1-1", "2000-4-24", [DATEVALUE("1992-6-19")]), 2168);
 442+  assertEquals(NETWORKDAYS("1992-1-1", false, [DATEVALUE("1991-6-19")]), -24002);
 443+  assertEquals(NETWORKDAYS("2020-12-12", 0, [DATEVALUE("1992-6-19")]), -31554);
 444+  assertEquals(NETWORKDAYS(12, 1423, [22]), 1008);// weekend and holdiay overlapping
 445+  assertEquals(NETWORKDAYS(12, 1423, [20]), 1007);
 446+  assertEquals(NETWORKDAYS(12, 12, [12]), 0);
 447+  assertEquals(NETWORKDAYS(DATE(1998, 1, 1), DATE(1999, 1, 22), [DATE(1999, 1, 20)]), 276);
 448+  catchAndAssertEquals(function() {
 449+    NETWORKDAYS(12, 12, [12], false);
 450+  }, ERRORS.NA_ERROR);
 451+  catchAndAssertEquals(function() {
 452+    NETWORKDAYS(12);
 453+  }, ERRORS.NA_ERROR);
 454+  catchAndAssertEquals(function() {
 455+    NETWORKDAYS("1992-1-1", "str");
 456+  }, ERRORS.VALUE_ERROR);
 457+  catchAndAssertEquals(function() {
 458+    NETWORKDAYS(12, 12, ["1992-11-1"]);
 459+  }, ERRORS.VALUE_ERROR);
 460+  catchAndAssertEquals(function() {
 461+    NETWORKDAYS("1992-1-1", "1992-1-1", []);
 462+  }, ERRORS.REF_ERROR);
 463+});
 464 
 465 
 466+test("SECOND", function() {
 467+  assertEquals(SECOND("8:10"), 0);
 468+  assertEquals(SECOND("8:11"), 0);
 469+  assertEquals(SECOND("8:44"), 0);
 470+  assertEquals(SECOND("8:70"), 0);
 471+  assertEquals(SECOND("8:120"), 0);
 472+  assertEquals(SECOND("8:10:22"), 22);
 473+  assertEquals(SECOND("8:11:12"), 12);
 474+  assertEquals(SECOND("8:44:09"), 9);
 475+  assertEquals(SECOND("8:70:02"), 2);
 476+  assertEquals(SECOND("8:120:44"), 44);
 477+  assertEquals(SECOND("8:120:104"), 44);
 478+  assertEquals(SECOND("1992-1-1 8:120:104"), 44);
 479+  assertEquals(SECOND(0.511111111111), 0);
 480+  catchAndAssertEquals(function() {
 481+    SECOND("8:10", 5);
 482+  }, ERRORS.NA_ERROR);
 483+  catchAndAssertEquals(function() {
 484+    SECOND();
 485+  }, ERRORS.NA_ERROR);
 486+  catchAndAssertEquals(function() {
 487+    SECOND("str");
 488+  }, ERRORS.VALUE_ERROR);
 489+  catchAndAssertEquals(function() {
 490+    SECOND(" ");
 491+  }, ERRORS.VALUE_ERROR);
 492+  catchAndAssertEquals(function() {
 493+    SECOND([]);
 494+  }, ERRORS.REF_ERROR);
 495+});
 496 
 497-// Test SECOND
 498-assertEquals(SECOND("8:10"), 0);
 499-assertEquals(SECOND("8:11"), 0);
 500-assertEquals(SECOND("8:44"), 0);
 501-assertEquals(SECOND("8:70"), 0);
 502-assertEquals(SECOND("8:120"), 0);
 503-assertEquals(SECOND("8:10:22"), 22);
 504-assertEquals(SECOND("8:11:12"), 12);
 505-assertEquals(SECOND("8:44:09"), 9);
 506-assertEquals(SECOND("8:70:02"), 2);
 507-assertEquals(SECOND("8:120:44"), 44);
 508-assertEquals(SECOND("8:120:104"), 44);
 509-assertEquals(SECOND("1992-1-1 8:120:104"), 44);
 510-assertEquals(SECOND(0.511111111111), 0);
 511-catchAndAssertEquals(function() {
 512-  SECOND("8:10", 5);
 513-}, ERRORS.NA_ERROR);
 514-catchAndAssertEquals(function() {
 515-  SECOND();
 516-}, ERRORS.NA_ERROR);
 517-catchAndAssertEquals(function() {
 518-  SECOND("str");
 519-}, ERRORS.VALUE_ERROR);
 520-catchAndAssertEquals(function() {
 521-  SECOND(" ");
 522-}, ERRORS.VALUE_ERROR);
 523-catchAndAssertEquals(function() {
 524-  SECOND([]);
 525-}, ERRORS.REF_ERROR);
 526 
 527+test("MINUTE", function() {
 528+  assertEquals(MINUTE("8:10"), 10);
 529+  assertEquals(MINUTE("8:11"), 11);
 530+  assertEquals(MINUTE("8:44"), 44);
 531+  assertEquals(MINUTE("8:70"), 10);
 532+  assertEquals(MINUTE("8:120"), 0);
 533+  assertEquals(MINUTE("8:10000pm"), 40);
 534+  assertEquals(MINUTE("28:10000"), 40);
 535+  assertEquals(MINUTE("14:23232:9999991"), 58);
 536+  assertEquals(MINUTE(["8:10"]), 10);
 537+  assertEquals(MINUTE("11:21222:2111pm"), 17);
 538+  assertEquals(MINUTE("11:21222:2111am"), 17);
 539+  assertEquals(MINUTE(""), 0);
 540+  assertEquals(MINUTE(0), 0);
 541+  assertEquals(MINUTE(1), 0);
 542+  assertEquals(MINUTE(false), 0);
 543+  assertEquals(MINUTE(true), 0);
 544+  assertEquals(MINUTE(0.8), 12);
 545+  assertEquals(MINUTE(0.5), 0);
 546+  assertEquals(MINUTE(0.25), 0);
 547+  assertEquals(MINUTE(0.125), 0);
 548+  assertEquals(MINUTE(0.0625), 30);
 549+  assertEquals(MINUTE(1.5), 0);
 550+  assertEquals(MINUTE(99.5), 0);
 551+  assertEquals(MINUTE("1969-7-6 5:05am"), 5);
 552+  catchAndAssertEquals(function() {
 553+    MINUTE("8:10", 5);
 554+  }, ERRORS.NA_ERROR);
 555+  catchAndAssertEquals(function() {
 556+    MINUTE();
 557+  }, ERRORS.NA_ERROR);
 558+  catchAndAssertEquals(function() {
 559+    MINUTE("str");
 560+  }, ERRORS.VALUE_ERROR);
 561+  catchAndAssertEquals(function() {
 562+    MINUTE(" ");
 563+  }, ERRORS.VALUE_ERROR);
 564+  catchAndAssertEquals(function() {
 565+    MINUTE([]);
 566+  }, ERRORS.REF_ERROR);
 567+});
 568 
 569-// Test MINUTE
 570-assertEquals(MINUTE("8:10"), 10);
 571-assertEquals(MINUTE("8:11"), 11);
 572-assertEquals(MINUTE("8:44"), 44);
 573-assertEquals(MINUTE("8:70"), 10);
 574-assertEquals(MINUTE("8:120"), 0);
 575-assertEquals(MINUTE("8:10000pm"), 40);
 576-assertEquals(MINUTE("28:10000"), 40);
 577-assertEquals(MINUTE("14:23232:9999991"), 58);
 578-assertEquals(MINUTE(["8:10"]), 10);
 579-assertEquals(MINUTE("11:21222:2111pm"), 17);
 580-assertEquals(MINUTE("11:21222:2111am"), 17);
 581-assertEquals(MINUTE(""), 0);
 582-assertEquals(MINUTE(0), 0);
 583-assertEquals(MINUTE(1), 0);
 584-assertEquals(MINUTE(false), 0);
 585-assertEquals(MINUTE(true), 0);
 586-assertEquals(MINUTE(0.8), 12);
 587-assertEquals(MINUTE(0.5), 0);
 588-assertEquals(MINUTE(0.25), 0);
 589-assertEquals(MINUTE(0.125), 0);
 590-assertEquals(MINUTE(0.0625), 30);
 591-assertEquals(MINUTE(1.5), 0);
 592-assertEquals(MINUTE(99.5), 0);
 593-assertEquals(MINUTE("1969-7-6 5:05am"), 5);
 594-catchAndAssertEquals(function() {
 595-  MINUTE("8:10", 5);
 596-}, ERRORS.NA_ERROR);
 597-catchAndAssertEquals(function() {
 598-  MINUTE();
 599-}, ERRORS.NA_ERROR);
 600-catchAndAssertEquals(function() {
 601-  MINUTE("str");
 602-}, ERRORS.VALUE_ERROR);
 603-catchAndAssertEquals(function() {
 604-  MINUTE(" ");
 605-}, ERRORS.VALUE_ERROR);
 606-catchAndAssertEquals(function() {
 607-  MINUTE([]);
 608-}, ERRORS.REF_ERROR);
 609 
 610+test("HOUR", function() {
 611+  assertEquals(HOUR("8:10"), 8);
 612+  assertEquals(HOUR("8am"), 8);
 613+  assertEquals(HOUR("8:10pm"), 20);
 614+  assertEquals(HOUR("8:10000pm"), 18);
 615+  assertEquals(HOUR("28:10000"), 2);
 616+  assertEquals(HOUR("14:23232:9999991"), 10);
 617+  assertEquals(HOUR(["8:10"]), 8);
 618+  assertEquals(HOUR("11:21222:2111pm"), 17);
 619+  assertEquals(HOUR("11:21222:2111am"), 5);
 620+  assertEquals(HOUR(""), 0);
 621+  assertEquals(HOUR(0), 0);
 622+  assertEquals(HOUR(1), 0);
 623+  assertEquals(HOUR(false), 0);
 624+  assertEquals(HOUR(true), 0);
 625+  assertEquals(HOUR(0.8), 19);
 626+  assertEquals(HOUR(0.5), 12);
 627+  assertEquals(HOUR(0.25), 6);
 628+  assertEquals(HOUR(0.125), 3);
 629+  assertEquals(HOUR(0.0625), 1);
 630+  assertEquals(HOUR(1.5), 12);
 631+  assertEquals(HOUR(99.5), 12);
 632+  assertEquals(HOUR("0.8"), 19);
 633+  assertEquals(HOUR("0.5"), 12);
 634+  assertEquals(HOUR("0.25"), 6);
 635+  assertEquals(HOUR("0.125"), 3);
 636+  assertEquals(HOUR("0.0625"), 1);
 637+  assertEquals(HOUR("1969-7-6 5am"), 5);
 638+  catchAndAssertEquals(function() {
 639+    HOUR("8:10", 5);
 640+  }, ERRORS.NA_ERROR);
 641+  catchAndAssertEquals(function() {
 642+    HOUR();
 643+  }, ERRORS.NA_ERROR);
 644+  catchAndAssertEquals(function() {
 645+    HOUR("str");
 646+  }, ERRORS.VALUE_ERROR);
 647+  catchAndAssertEquals(function() {
 648+    HOUR(" ");
 649+  }, ERRORS.VALUE_ERROR);
 650+  catchAndAssertEquals(function() {
 651+    HOUR([]);
 652+  }, ERRORS.REF_ERROR);
 653+});
 654 
 655-// Test HOUR
 656-assertEquals(HOUR("8:10"), 8);
 657-assertEquals(HOUR("8am"), 8);
 658-assertEquals(HOUR("8:10pm"), 20);
 659-assertEquals(HOUR("8:10000pm"), 18);
 660-assertEquals(HOUR("28:10000"), 2);
 661-assertEquals(HOUR("14:23232:9999991"), 10);
 662-assertEquals(HOUR(["8:10"]), 8);
 663-assertEquals(HOUR("11:21222:2111pm"), 17);
 664-assertEquals(HOUR("11:21222:2111am"), 5);
 665-assertEquals(HOUR(""), 0);
 666-assertEquals(HOUR(0), 0);
 667-assertEquals(HOUR(1), 0);
 668-assertEquals(HOUR(false), 0);
 669-assertEquals(HOUR(true), 0);
 670-assertEquals(HOUR(0.8), 19);
 671-assertEquals(HOUR(0.5), 12);
 672-assertEquals(HOUR(0.25), 6);
 673-assertEquals(HOUR(0.125), 3);
 674-assertEquals(HOUR(0.0625), 1);
 675-assertEquals(HOUR(1.5), 12);
 676-assertEquals(HOUR(99.5), 12);
 677-assertEquals(HOUR("0.8"), 19);
 678-assertEquals(HOUR("0.5"), 12);
 679-assertEquals(HOUR("0.25"), 6);
 680-assertEquals(HOUR("0.125"), 3);
 681-assertEquals(HOUR("0.0625"), 1);
 682-assertEquals(HOUR("1969-7-6 5am"), 5);
 683-catchAndAssertEquals(function() {
 684-  HOUR("8:10", 5);
 685-}, ERRORS.NA_ERROR);
 686-catchAndAssertEquals(function() {
 687-  HOUR();
 688-}, ERRORS.NA_ERROR);
 689-catchAndAssertEquals(function() {
 690-  HOUR("str");
 691-}, ERRORS.VALUE_ERROR);
 692-catchAndAssertEquals(function() {
 693-  HOUR(" ");
 694-}, ERRORS.VALUE_ERROR);
 695-catchAndAssertEquals(function() {
 696-  HOUR([]);
 697-}, ERRORS.REF_ERROR);
 698 
 699+test("TIMEVALUE", function() {
 700+  assertEquals(TIMEVALUE("1969-7-6"), 0);
 701+  assertEquals(TIMEVALUE("1969-7-6 8am"), 0.3333333333333333);
 702+  assertEquals(TIMEVALUE("1969-7-28 8:10"), 0.3402777777777778);
 703+  assertEquals(TIMEVALUE("2100-7-6 8:10pm"), 0.8402777777777778);
 704+  assertEquals(TIMEVALUE("1999-1-1 8:10000pm"), 0.7777777777777778);
 705+  assertEquals(TIMEVALUE("2012/1/1 28:10000"), 0.1111111111111111);
 706+  assertEquals(TIMEVALUE("2012/1/1 14:23232:9999991"), 0.45730324074074075);
 707+  assertEquals(TIMEVALUE(["2012/1/1 8:10"]), 0.3402777777777778);
 708+  assertEquals(TIMEVALUE("2012/1/1 11:21222:2111pm"), 0.7202662037037038);
 709+  assertEquals(TIMEVALUE("2012/1/1 11:21222:2111am"), 0.2202662037037037);
 710+  assertEquals(TIMEVALUE("8am"), 0.3333333333333333);
 711+  assertEquals(TIMEVALUE("8:10"), 0.3402777777777778);
 712+  assertEquals(TIMEVALUE("8:10pm"), 0.8402777777777778);
 713+  assertEquals(TIMEVALUE("8:10000pm"), 0.7777777777777778);
 714+  assertEquals(TIMEVALUE("28:10000"), 0.1111111111111111);
 715+  assertEquals(TIMEVALUE("14:23232:9999991"), 0.45730324074074075);
 716+  assertEquals(TIMEVALUE(["8:10"]), 0.3402777777777778);
 717+  assertEquals(TIMEVALUE("11:21222:2111pm"), 0.7202662037037038);
 718+  assertEquals(TIMEVALUE("11:21222:2111am"), 0.2202662037037037);
 719+  catchAndAssertEquals(function() {
 720+    TIMEVALUE("8:10", 5);
 721+  }, ERRORS.NA_ERROR);
 722+  catchAndAssertEquals(function() {
 723+    TIMEVALUE();
 724+  }, ERRORS.NA_ERROR);
 725+  catchAndAssertEquals(function() {
 726+    TIMEVALUE("str");
 727+  }, ERRORS.VALUE_ERROR);
 728+  catchAndAssertEquals(function() {
 729+    TIMEVALUE([]);
 730+  }, ERRORS.REF_ERROR);
 731+});
 732 
 733-// Test TIMEVALUE
 734-assertEquals(TIMEVALUE("1969-7-6"), 0);
 735-assertEquals(TIMEVALUE("1969-7-6 8am"), 0.3333333333333333);
 736-assertEquals(TIMEVALUE("1969-7-28 8:10"), 0.3402777777777778);
 737-assertEquals(TIMEVALUE("2100-7-6 8:10pm"), 0.8402777777777778);
 738-assertEquals(TIMEVALUE("1999-1-1 8:10000pm"), 0.7777777777777778);
 739-assertEquals(TIMEVALUE("2012/1/1 28:10000"), 0.1111111111111111);
 740-assertEquals(TIMEVALUE("2012/1/1 14:23232:9999991"), 0.45730324074074075);
 741-assertEquals(TIMEVALUE(["2012/1/1 8:10"]), 0.3402777777777778);
 742-assertEquals(TIMEVALUE("2012/1/1 11:21222:2111pm"), 0.7202662037037038);
 743-assertEquals(TIMEVALUE("2012/1/1 11:21222:2111am"), 0.2202662037037037);
 744-assertEquals(TIMEVALUE("8am"), 0.3333333333333333);
 745-assertEquals(TIMEVALUE("8:10"), 0.3402777777777778);
 746-assertEquals(TIMEVALUE("8:10pm"), 0.8402777777777778);
 747-assertEquals(TIMEVALUE("8:10000pm"), 0.7777777777777778);
 748-assertEquals(TIMEVALUE("28:10000"), 0.1111111111111111);
 749-assertEquals(TIMEVALUE("14:23232:9999991"), 0.45730324074074075);
 750-assertEquals(TIMEVALUE(["8:10"]), 0.3402777777777778);
 751-assertEquals(TIMEVALUE("11:21222:2111pm"), 0.7202662037037038);
 752-assertEquals(TIMEVALUE("11:21222:2111am"), 0.2202662037037037);
 753-catchAndAssertEquals(function() {
 754-  TIMEVALUE("8:10", 5);
 755-}, ERRORS.NA_ERROR);
 756-catchAndAssertEquals(function() {
 757-  TIMEVALUE();
 758-}, ERRORS.NA_ERROR);
 759-catchAndAssertEquals(function() {
 760-  TIMEVALUE("str");
 761-}, ERRORS.VALUE_ERROR);
 762-catchAndAssertEquals(function() {
 763-  TIMEVALUE([]);
 764-}, ERRORS.REF_ERROR);
 765 
 766+test("YEARFRAC", function(){
 767+  assertEquals(YEARFRAC(1, 1461, 2), 4.055555555555555);
 768+  assertEquals(YEARFRAC(0, 365, 0), 1);
 769+  assertEquals(YEARFRAC(0, 365, 1), 1);
 770+  assertEquals(YEARFRAC(0, 365, 2), 1.0138888888888888);
 771+  assertEquals(YEARFRAC(0, 365, 3), 1);
 772+  assertEquals(YEARFRAC(0, 365, 4), 1);
 773+  assertEquals(YEARFRAC(0, 1000, 0), 2.738888888888889);
 774+  assertEquals(YEARFRAC(0, 1000, 1), 2.73972602739726);
 775+  assertEquals(YEARFRAC(0, 1000, 2), 2.7777777777777777);
 776+  assertEquals(YEARFRAC(0, 1000, 3), 2.73972602739726);
 777+  assertEquals(YEARFRAC(0, 1000, 4), 2.738888888888889);
 778+  assertEquals(YEARFRAC(10000, 20000, 0), 27.375);
 779+  assertEquals(YEARFRAC(10000, 20000, 1), 27.378507871321013); // gs: 27.37808219, ms: 27.37850787
 780+  assertEquals(YEARFRAC(10000, 20000, 2), 27.77777777777778);
 781+  assertEquals(YEARFRAC(10000, 20000, 3), 27.397260273972602);
 782+  assertEquals(YEARFRAC(10000, 20000, 4), 27.375);
 783+  assertEquals(YEARFRAC(100000, 200000, 0), 273.7944444444444);
 784+  assertEquals(YEARFRAC(100000, 200000, 1), 273.7925747453729); // gs: 273.7917808, ms: 273.7925747
 785+  assertEquals(YEARFRAC(100000, 200000, 2), 277.77777777777777);
 786+  assertEquals(YEARFRAC(100000, 200000, 3), 273.972602739726);
 787+  assertEquals(YEARFRAC(100000, 200000, 4), 273.7944444444444);
 788+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 0), 18.994444444444444);
 789+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 0), 19.044444444444444);
 790+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 0), 199.544444444444444);
 791+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 0), 199.041666666666667);
 792+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 0), 152.044444444444444);
 793+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 0), 0);
 794+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 0), 0.013888888888888888);
 795+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 0), 1);
 796+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 1), 18.99520876112252);
 797+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 1), 19.044490075290895);
 798+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 1), 199.54003477118098);
 799+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 1), 199.04173910662706);
 800+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 1), 152.04174793765546);
 801+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 1), 0);
 802+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 1), 0.01366120218579235);
 803+  assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 1), 1);
 804+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 1), 1);
 805+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 2), 19.322222222222223);
 806+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 2), 202.44722222222222);
 807+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 2), 201.94166666666666);
 808+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 2), 154.25833333333333);
 809+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 2), 0);
 810+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 2), 0.013888888888888888);
 811+  assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 2), 1.0138888888888888);
 812+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 2), 1.0166666666666666);
 813+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 3), 19.057534246575344);
 814+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 3), 199.67397260273972);
 815+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 3), 199.17534246575343);
 816+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 3), 152.14520547945204);
 817+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 3), 0);
 818+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 3), 0.0136986301369863);
 819+  assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 3), 1);
 820+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 3), 1.0027397260273974);
 821+  assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 4), 19.044444444444444);
 822+  assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 4), 199.54444444444445);
 823+  assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 4), 199.04166666666666);
 824+  assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 4), 152.04444444444445);
 825+  assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 4), 0);
 826+  assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 4), 0.013888888888888888);
 827+  assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 4), 1);
 828+  assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 4), 1);
 829+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 2), 19.272222222222222);
 830+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 3), 19.008219178082193);
 831+  assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 4), 18.994444444444444);
 832+  assertEquals(YEARFRAC(["1992-1-6", []], ["1993-1-6", "str"], [4]), 1);
 833+  catchAndAssertEquals(function() {
 834+    YEARFRAC("1996-6-19", "1992-6-19", 5);
 835+  }, ERRORS.NUM_ERROR);
 836+  catchAndAssertEquals(function() {
 837+    YEARFRAC();
 838+  }, ERRORS.NA_ERROR);
 839+  catchAndAssertEquals(function() {
 840+    YEARFRAC("1992-6-19", "1995-6-19", 1, 0);
 841+  }, ERRORS.NA_ERROR);
 842+  catchAndAssertEquals(function() {
 843+    YEARFRAC("str", "1995-6-19", 1);
 844+  }, ERRORS.VALUE_ERROR);
 845+  catchAndAssertEquals(function() {
 846+    YEARFRAC([], "1995-6-19", 1);
 847+  }, ERRORS.REF_ERROR);
 848+});
 849 
 850 
 851-// Test YEARFRAC
 852-assertEquals(YEARFRAC(1, 1461, 2), 4.055555555555555);
 853-assertEquals(YEARFRAC(0, 365, 0), 1);
 854-assertEquals(YEARFRAC(0, 365, 1), 1);
 855-assertEquals(YEARFRAC(0, 365, 2), 1.0138888888888888);
 856-assertEquals(YEARFRAC(0, 365, 3), 1);
 857-assertEquals(YEARFRAC(0, 365, 4), 1);
 858-assertEquals(YEARFRAC(0, 1000, 0), 2.738888888888889);
 859-assertEquals(YEARFRAC(0, 1000, 1), 2.73972602739726);
 860-assertEquals(YEARFRAC(0, 1000, 2), 2.7777777777777777);
 861-assertEquals(YEARFRAC(0, 1000, 3), 2.73972602739726);
 862-assertEquals(YEARFRAC(0, 1000, 4), 2.738888888888889);
 863-assertEquals(YEARFRAC(10000, 20000, 0), 27.375);
 864-assertEquals(YEARFRAC(10000, 20000, 1), 27.378507871321013); // gs: 27.37808219, ms: 27.37850787
 865-assertEquals(YEARFRAC(10000, 20000, 2), 27.77777777777778);
 866-assertEquals(YEARFRAC(10000, 20000, 3), 27.397260273972602);
 867-assertEquals(YEARFRAC(10000, 20000, 4), 27.375);
 868-assertEquals(YEARFRAC(100000, 200000, 0), 273.7944444444444);
 869-assertEquals(YEARFRAC(100000, 200000, 1), 273.7925747453729); // gs: 273.7917808, ms: 273.7925747
 870-assertEquals(YEARFRAC(100000, 200000, 2), 277.77777777777777);
 871-assertEquals(YEARFRAC(100000, 200000, 3), 273.972602739726);
 872-assertEquals(YEARFRAC(100000, 200000, 4), 273.7944444444444);
 873-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 0), 18.994444444444444);
 874-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 0), 19.044444444444444);
 875-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 0), 199.544444444444444);
 876-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 0), 199.041666666666667);
 877-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 0), 152.044444444444444);
 878-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 0), 0);
 879-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 0), 0.013888888888888888);
 880-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 0), 1);
 881-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 1), 18.99520876112252);
 882-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 1), 19.044490075290895);
 883-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 1), 199.54003477118098);
 884-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 1), 199.04173910662706);
 885-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 1), 152.04174793765546);
 886-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 1), 0);
 887-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 1), 0.01366120218579235);
 888-assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 1), 1);
 889-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 1), 1);
 890-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 2), 19.322222222222223);
 891-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 2), 202.44722222222222);
 892-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 2), 201.94166666666666);
 893-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 2), 154.25833333333333);
 894-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 2), 0);
 895-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 2), 0.013888888888888888);
 896-assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 2), 1.0138888888888888);
 897-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 2), 1.0166666666666666);
 898-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 3), 19.057534246575344);
 899-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 3), 199.67397260273972);
 900-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 3), 199.17534246575343);
 901-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 3), 152.14520547945204);
 902-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 3), 0);
 903-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 3), 0.0136986301369863);
 904-assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 3), 1);
 905-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 3), 1.0027397260273974);
 906-assertEquals(YEARFRAC("1969-7-6", "1988-7-22", 4), 19.044444444444444);
 907-assertEquals(YEARFRAC("1992-1-6", "2191-7-22", 4), 199.54444444444445);
 908-assertEquals(YEARFRAC("1992-1-6", "2191-1-21", 4), 199.04166666666666);
 909-assertEquals(YEARFRAC("1992-1-6", "2144-1-22", 4), 152.04444444444445);
 910-assertEquals(YEARFRAC("1992-1-6", "1992-1-6", 4), 0);
 911-assertEquals(YEARFRAC("1992-1-6", "1992-1-1", 4), 0.013888888888888888);
 912-assertEquals(YEARFRAC("1991-1-6", "1992-1-6", 4), 1);
 913-assertEquals(YEARFRAC("1992-1-6", "1993-1-6", 4), 1);
 914-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 2), 19.272222222222222);
 915-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 3), 19.008219178082193);
 916-assertEquals(YEARFRAC("1969-7-6", "1988-7-4", 4), 18.994444444444444);
 917-assertEquals(YEARFRAC(["1992-1-6", []], ["1993-1-6", "str"], [4]), 1);
 918-catchAndAssertEquals(function() {
 919-  YEARFRAC("1996-6-19", "1992-6-19", 5);
 920-}, ERRORS.NUM_ERROR);
 921-catchAndAssertEquals(function() {
 922-  YEARFRAC();
 923-}, ERRORS.NA_ERROR);
 924-catchAndAssertEquals(function() {
 925-  YEARFRAC("1992-6-19", "1995-6-19", 1, 0);
 926-}, ERRORS.NA_ERROR);
 927-catchAndAssertEquals(function() {
 928-  YEARFRAC("str", "1995-6-19", 1);
 929-}, ERRORS.VALUE_ERROR);
 930-catchAndAssertEquals(function() {
 931-  YEARFRAC([], "1995-6-19", 1);
 932-}, ERRORS.REF_ERROR);
 933+test("DATEDIF", function(){
 934+  assertEquals(DATEDIF("1992-6-19", "1996-6-19", "Y"), 4);
 935+  assertEquals(DATEDIF("1992-6-19", "1996-6-0", "Y"), 3);
 936+  assertEquals(DATEDIF("1992-6-19", "1992-8-1", "Y"), 0);
 937+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "Y"), 207);
 938+  assertEquals(DATEDIF("1992-6-19", "1996-6-19", "M"), 48);
 939+  assertEquals(DATEDIF("1992-6-19", "1996-6-1", "M"), 47);
 940+  assertEquals(DATEDIF("1992-6-19", "1992-8-1", "M"), 1);
 941+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "M"), 2485);
 942+  assertEquals(DATEDIF("1992-6-19", "1996-6-19", "D"), 1461);
 943+  assertEquals(DATEDIF("1992-6-19", "1996-6-1", "D"), 1443);
 944+  assertEquals(DATEDIF("1992-6-19", "1992-8-1", "D"), 43);
 945+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "D"), 75648);
 946+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "MD"), 13);
 947+  assertEquals(DATEDIF("1992-6-19", "2012-7-22", "MD"), 3);
 948+  assertEquals(DATEDIF("1992-6-19", "1993-8-1", "MD"), 13);
 949+  assertEquals(DATEDIF("1992-6-19", "2000-1-19", "MD"), 0);
 950+  assertEquals(DATEDIF("1992-6-19", "2000-1-20", "MD"), 1);
 951+  assertEquals(DATEDIF("1992-6-19", "2000-1-21", "MD"), 2);
 952+  assertEquals(DATEDIF("1992-6-19", "2000-1-22", "MD"), 3);
 953+  assertEquals(DATEDIF("1992-6-19", "2000-1-23", "MD"), 4);
 954+  assertEquals(DATEDIF("1992-6-19", "2000-1-24", "MD"), 5);
 955+  assertEquals(DATEDIF("1992-6-19", "2000-1-25", "MD"), 6);
 956+  assertEquals(DATEDIF("1992-6-20", "2000-1-25", "MD"), 5);
 957+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "YM"), 1);
 958+  assertEquals(DATEDIF("1992-6-19", "2012-7-22", "YM"), 1);
 959+  assertEquals(DATEDIF("1992-6-19", "1993-8-1", "YM"), 1);
 960+  assertEquals(DATEDIF("1992-6-19", "2000-1-19", "YM"), 7);
 961+  assertEquals(DATEDIF("1992-6-19", "2000-1-20", "YM"), 7);
 962+  assertEquals(DATEDIF("1992-6-19", "2000-1-21", "YM"), 7);
 963+  assertEquals(DATEDIF("1992-6-19", "2000-1-22", "YM"), 7);
 964+  assertEquals(DATEDIF("1992-6-19", "2000-1-23", "YM"), 7);
 965+  assertEquals(DATEDIF("1992-6-19", "2000-1-24", "YM"), 7);
 966+  assertEquals(DATEDIF("1992-6-19", "2000-1-25", "YM"), 7);
 967+  assertEquals(DATEDIF("1992-6-20", "2000-1-25", "YM"), 7);
 968+  assertEquals(DATEDIF("1992-6-19", "1992-6-19", "YM"), 0);
 969+  assertEquals(DATEDIF("1992-6-19", "1992-7-19", "YM"), 1);
 970+  assertEquals(DATEDIF("1992-6-19", "1993-7-19", "YM"), 1);
 971+  assertEquals(DATEDIF("1992-6-19", "1993-6-19", "YM"), 0);
 972+  assertEquals(DATEDIF("1992-6-19", "2199-8-1", "YD"), 43);
 973+  assertEquals(DATEDIF("1992-6-19", "2012-7-22", "YD"), 33);
 974+  assertEquals(DATEDIF("1992-6-19", "1993-8-1", "YD"), 43);
 975+  assertEquals(DATEDIF("1992-6-19", "2000-1-19", "YD"), 214);
 976+  assertEquals(DATEDIF("1992-6-19", "2000-1-20", "YD"), 215);
 977+  assertEquals(DATEDIF("1992-6-19", "2000-1-21", "YD"), 216);
 978+  assertEquals(DATEDIF("1992-6-19", "2000-1-22", "YD"), 217);
 979+  assertEquals(DATEDIF("1992-6-19", "2000-1-23", "YD"), 218);
 980+  assertEquals(DATEDIF("1992-6-19", "2000-1-24", "YD"), 219);
 981+  assertEquals(DATEDIF("1992-6-19", "2000-1-25", "YD"), 220);
 982+  assertEquals(DATEDIF("1992-6-19", "1992-6-19", "YD"), 0);
 983+  assertEquals(DATEDIF("1992-6-19", "1992-7-19", "YD"), 30);
 984+  assertEquals(DATEDIF("1992-6-19", "1993-7-19", "YD"), 30);
 985+  assertEquals(DATEDIF("1992-6-19", "1993-6-19", "YD"), 0);
 986+  assertEquals(DATEDIF("1992-6-19", "1993-6-19", "yd"), 0);
 987+  assertEquals(DATEDIF(["1992-6-19", "str"], ["1993-6-19", []], ["yd"]), 0);
 988+  catchAndAssertEquals(function() {
 989+    DATEDIF("1996-6-19", "1992-6-19", "Y");
 990+  }, ERRORS.NUM_ERROR);
 991+  catchAndAssertEquals(function() {
 992+    DATEDIF("1992-6-19", "1995-6-19", "Y ");
 993+  }, ERRORS.NUM_ERROR);
 994+  catchAndAssertEquals(function() {
 995+    DATEDIF("1992-6-19", "1995-6-19", "mm");
 996+  }, ERRORS.NUM_ERROR);
 997+  catchAndAssertEquals(function() {
 998+    DATEDIF();
 999+  }, ERRORS.NA_ERROR);
1000+  catchAndAssertEquals(function() {
1001+    DATEDIF("1992-6-19", "1995-6-19", "mm", 0);
1002+  }, ERRORS.NA_ERROR);
1003+  catchAndAssertEquals(function() {
1004+    DATEDIF("str", "1995-6-19", "mm");
1005+  }, ERRORS.VALUE_ERROR);
1006+  catchAndAssertEquals(function() {
1007+    DATEDIF([], "1995-6-19", "mm");
1008+  }, ERRORS.REF_ERROR);
1009+});
1010 
1011 
1012-// Test DATEDIF
1013-assertEquals(DATEDIF("1992-6-19", "1996-6-19", "Y"), 4);
1014-assertEquals(DATEDIF("1992-6-19", "1996-6-0", "Y"), 3);
1015-assertEquals(DATEDIF("1992-6-19", "1992-8-1", "Y"), 0);
1016-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "Y"), 207);
1017-assertEquals(DATEDIF("1992-6-19", "1996-6-19", "M"), 48);
1018-assertEquals(DATEDIF("1992-6-19", "1996-6-1", "M"), 47);
1019-assertEquals(DATEDIF("1992-6-19", "1992-8-1", "M"), 1);
1020-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "M"), 2485);
1021-assertEquals(DATEDIF("1992-6-19", "1996-6-19", "D"), 1461);
1022-assertEquals(DATEDIF("1992-6-19", "1996-6-1", "D"), 1443);
1023-assertEquals(DATEDIF("1992-6-19", "1992-8-1", "D"), 43);
1024-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "D"), 75648);
1025-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "MD"), 13);
1026-assertEquals(DATEDIF("1992-6-19", "2012-7-22", "MD"), 3);
1027-assertEquals(DATEDIF("1992-6-19", "1993-8-1", "MD"), 13);
1028-assertEquals(DATEDIF("1992-6-19", "2000-1-19", "MD"), 0);
1029-assertEquals(DATEDIF("1992-6-19", "2000-1-20", "MD"), 1);
1030-assertEquals(DATEDIF("1992-6-19", "2000-1-21", "MD"), 2);
1031-assertEquals(DATEDIF("1992-6-19", "2000-1-22", "MD"), 3);
1032-assertEquals(DATEDIF("1992-6-19", "2000-1-23", "MD"), 4);
1033-assertEquals(DATEDIF("1992-6-19", "2000-1-24", "MD"), 5);
1034-assertEquals(DATEDIF("1992-6-19", "2000-1-25", "MD"), 6);
1035-assertEquals(DATEDIF("1992-6-20", "2000-1-25", "MD"), 5);
1036-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "YM"), 1);
1037-assertEquals(DATEDIF("1992-6-19", "2012-7-22", "YM"), 1);
1038-assertEquals(DATEDIF("1992-6-19", "1993-8-1", "YM"), 1);
1039-assertEquals(DATEDIF("1992-6-19", "2000-1-19", "YM"), 7);
1040-assertEquals(DATEDIF("1992-6-19", "2000-1-20", "YM"), 7);
1041-assertEquals(DATEDIF("1992-6-19", "2000-1-21", "YM"), 7);
1042-assertEquals(DATEDIF("1992-6-19", "2000-1-22", "YM"), 7);
1043-assertEquals(DATEDIF("1992-6-19", "2000-1-23", "YM"), 7);
1044-assertEquals(DATEDIF("1992-6-19", "2000-1-24", "YM"), 7);
1045-assertEquals(DATEDIF("1992-6-19", "2000-1-25", "YM"), 7);
1046-assertEquals(DATEDIF("1992-6-20", "2000-1-25", "YM"), 7);
1047-assertEquals(DATEDIF("1992-6-19", "1992-6-19", "YM"), 0);
1048-assertEquals(DATEDIF("1992-6-19", "1992-7-19", "YM"), 1);
1049-assertEquals(DATEDIF("1992-6-19", "1993-7-19", "YM"), 1);
1050-assertEquals(DATEDIF("1992-6-19", "1993-6-19", "YM"), 0);
1051-assertEquals(DATEDIF("1992-6-19", "2199-8-1", "YD"), 43);
1052-assertEquals(DATEDIF("1992-6-19", "2012-7-22", "YD"), 33);
1053-assertEquals(DATEDIF("1992-6-19", "1993-8-1", "YD"), 43);
1054-assertEquals(DATEDIF("1992-6-19", "2000-1-19", "YD"), 214);
1055-assertEquals(DATEDIF("1992-6-19", "2000-1-20", "YD"), 215);
1056-assertEquals(DATEDIF("1992-6-19", "2000-1-21", "YD"), 216);
1057-assertEquals(DATEDIF("1992-6-19", "2000-1-22", "YD"), 217);
1058-assertEquals(DATEDIF("1992-6-19", "2000-1-23", "YD"), 218);
1059-assertEquals(DATEDIF("1992-6-19", "2000-1-24", "YD"), 219);
1060-assertEquals(DATEDIF("1992-6-19", "2000-1-25", "YD"), 220);
1061-assertEquals(DATEDIF("1992-6-19", "1992-6-19", "YD"), 0);
1062-assertEquals(DATEDIF("1992-6-19", "1992-7-19", "YD"), 30);
1063-assertEquals(DATEDIF("1992-6-19", "1993-7-19", "YD"), 30);
1064-assertEquals(DATEDIF("1992-6-19", "1993-6-19", "YD"), 0);
1065-assertEquals(DATEDIF("1992-6-19", "1993-6-19", "yd"), 0);
1066-assertEquals(DATEDIF(["1992-6-19", "str"], ["1993-6-19", []], ["yd"]), 0);
1067-catchAndAssertEquals(function() {
1068-  DATEDIF("1996-6-19", "1992-6-19", "Y");
1069-}, ERRORS.NUM_ERROR);
1070-catchAndAssertEquals(function() {
1071-  DATEDIF("1992-6-19", "1995-6-19", "Y ");
1072-}, ERRORS.NUM_ERROR);
1073-catchAndAssertEquals(function() {
1074-  DATEDIF("1992-6-19", "1995-6-19", "mm");
1075-}, ERRORS.NUM_ERROR);
1076-catchAndAssertEquals(function() {
1077-  DATEDIF();
1078-}, ERRORS.NA_ERROR);
1079-catchAndAssertEquals(function() {
1080-  DATEDIF("1992-6-19", "1995-6-19", "mm", 0);
1081-}, ERRORS.NA_ERROR);
1082-catchAndAssertEquals(function() {
1083-  DATEDIF("str", "1995-6-19", "mm");
1084-}, ERRORS.VALUE_ERROR);
1085-catchAndAssertEquals(function() {
1086-  DATEDIF([], "1995-6-19", "mm");
1087-}, ERRORS.REF_ERROR);
1088+test("WEEKNUM", function(){
1089+  assertEquals(WEEKNUM(DATE(1992, 6, 19)), 25);
1090+  assertEquals(WEEKNUM(DATE(1992, 6, 20)), 25);
1091+  assertEquals(WEEKNUM(DATE(1992, 6, 21)), 26);
1092+  assertEquals(WEEKNUM(0), 52);
1093+  assertEquals(WEEKNUM(false), 52);
1094+  assertEquals(WEEKNUM(1), 53);
1095+  assertEquals(WEEKNUM(true), 53);
1096+  assertEquals(WEEKNUM(2), 1);
1097+  assertEquals(WEEKNUM(3), 1);
1098+  assertEquals(WEEKNUM(4), 1);
1099+  assertEquals(WEEKNUM(5), 1);
1100+  assertEquals(WEEKNUM(6), 1);
1101+  assertEquals(WEEKNUM(7), 1);
1102+  assertEquals(WEEKNUM(8), 2);
1103+  assertEquals(WEEKNUM(9), 2);
1104+  assertEquals(WEEKNUM(10), 2);
1105+  assertEquals(WEEKNUM(11), 2);
1106+  assertEquals(WEEKNUM(12), 2);
1107+  assertEquals(WEEKNUM(13), 2);
1108+  assertEquals(WEEKNUM(14), 2);
1109+  assertEquals(WEEKNUM(15), 3);
1110+  assertEquals(WEEKNUM(16), 3);
1111+  assertEquals(WEEKNUM(17), 3);
1112+  assertEquals(WEEKNUM(18), 3);
1113+  assertEquals(WEEKNUM(23734), 52);
1114+  assertEquals(WEEKNUM(23735), 52);
1115+  assertEquals(WEEKNUM(23736), 52);
1116+  assertEquals(WEEKNUM(23737), 52);
1117+  assertEquals(WEEKNUM(23738), 53);
1118+  assertEquals(WEEKNUM(23739), 53);
1119+  assertEquals(WEEKNUM(23740), 53);
1120+  assertEquals(WEEKNUM(23741), 53);
1121+  assertEquals(WEEKNUM(23742), 53);
1122+  assertEquals(WEEKNUM(23743), 1);
1123+  assertEquals(WEEKNUM(23744), 1);
1124+  assertEquals(WEEKNUM(23745), 2);
1125+  assertEquals(WEEKNUM(23746), 2);
1126+  assertEquals(WEEKNUM(23747), 2);
1127+  assertEquals(WEEKNUM(23748), 2);
1128+  assertEquals(WEEKNUM(23749), 2);
1129+  assertEquals(WEEKNUM(23750), 2);
1130+  assertEquals(WEEKNUM(23751), 2);
1131+  assertEquals(WEEKNUM(23752), 3);
1132+  // type=2
1133+  assertEquals(WEEKNUM(23737, 2), 52);
1134+  assertEquals(WEEKNUM(23738, 2), 52);
1135+  assertEquals(WEEKNUM(23739, 2), 53);
1136+  assertEquals(WEEKNUM(23740, 2), 53);
1137+  assertEquals(WEEKNUM(23741, 2), 53);
1138+  assertEquals(WEEKNUM(23742, 2), 53);
1139+  assertEquals(WEEKNUM(23743, 2), 1);
1140+  assertEquals(WEEKNUM(23744, 2), 1);
1141+  assertEquals(WEEKNUM(23745, 2), 1);
1142+  assertEquals(WEEKNUM(23746, 2), 2);
1143+  assertEquals(WEEKNUM(23747, 2), 2);
1144+  assertEquals(WEEKNUM(23748, 2), 2);
1145+  assertEquals(WEEKNUM(23749, 2), 2);
1146+  assertEquals(WEEKNUM(23750, 2), 2);
1147+  assertEquals(WEEKNUM(23751, 2), 2);
1148+  assertEquals(WEEKNUM(23752, 2), 2);
1149+  assertEquals(WEEKNUM(23753, 2), 3);
1150+  assertEquals(WEEKNUM(23754, 2), 3);
1151+  assertEquals(WEEKNUM(23755, 2), 3);
1152+  assertEquals(WEEKNUM(23756, 2), 3);
1153+  assertEquals(WEEKNUM(23757, 2), 3);
1154+  assertEquals(WEEKNUM(23758, 2), 3);
1155+  assertEquals(WEEKNUM(23759, 2), 3);
1156+  assertEquals(WEEKNUM(23760, 2), 4);
1157+  //type=11
1158+  assertEquals(WEEKNUM(23737, 11), 52);
1159+  assertEquals(WEEKNUM(23738, 11), 52);
1160+  assertEquals(WEEKNUM(23739, 11), 53);
1161+  assertEquals(WEEKNUM(23740, 11), 53);
1162+  assertEquals(WEEKNUM(23741, 11), 53);
1163+  assertEquals(WEEKNUM(23742, 11), 53);
1164+  assertEquals(WEEKNUM(23743, 11), 1);
1165+  assertEquals(WEEKNUM(23744, 11), 1);
1166+  assertEquals(WEEKNUM(23745, 11), 1);
1167+  assertEquals(WEEKNUM(23746, 11), 2);
1168+  assertEquals(WEEKNUM(23747, 11), 2);
1169+  assertEquals(WEEKNUM(23748, 11), 2);
1170+  assertEquals(WEEKNUM(23749, 11), 2);
1171+  assertEquals(WEEKNUM(23750, 11), 2);
1172+  assertEquals(WEEKNUM(23751, 11), 2);
1173+  assertEquals(WEEKNUM(23752, 11), 2);
1174+  assertEquals(WEEKNUM(23753, 11), 3);
1175+  assertEquals(WEEKNUM(23754, 11), 3);
1176+  assertEquals(WEEKNUM(23755, 11), 3);
1177+  assertEquals(WEEKNUM(23756, 11), 3);
1178+  assertEquals(WEEKNUM(23757, 11), 3);
1179+  assertEquals(WEEKNUM(23758, 11), 3);
1180+  assertEquals(WEEKNUM(23759, 11), 3);
1181+  assertEquals(WEEKNUM(23760, 11), 4);
1182+  //type=12
1183+  assertEquals(WEEKNUM(23737, 12), 52);
1184+  assertEquals(WEEKNUM(23738, 12), 52);
1185+  assertEquals(WEEKNUM(23739, 12), 52);
1186+  assertEquals(WEEKNUM(23740, 12), 53);
1187+  assertEquals(WEEKNUM(23741, 12), 53);
1188+  assertEquals(WEEKNUM(23742, 12), 53);
1189+  assertEquals(WEEKNUM(23743, 12), 1);
1190+  assertEquals(WEEKNUM(23744, 12), 1);
1191+  assertEquals(WEEKNUM(23745, 12), 1);
1192+  assertEquals(WEEKNUM(23746, 12), 1);
1193+  assertEquals(WEEKNUM(23747, 12), 2);
1194+  assertEquals(WEEKNUM(23748, 12), 2);
1195+  assertEquals(WEEKNUM(23749, 12), 2);
1196+  assertEquals(WEEKNUM(23750, 12), 2);
1197+  assertEquals(WEEKNUM(23751, 12), 2);
1198+  assertEquals(WEEKNUM(23752, 12), 2);
1199+  assertEquals(WEEKNUM(23753, 12), 2);
1200+  assertEquals(WEEKNUM(23754, 12), 3);
1201+  assertEquals(WEEKNUM(23755, 12), 3);
1202+  assertEquals(WEEKNUM(23756, 12), 3);
1203+  assertEquals(WEEKNUM(23757, 12), 3);
1204+  assertEquals(WEEKNUM(23758, 12), 3);
1205+  assertEquals(WEEKNUM(23759, 12), 3);
1206+  assertEquals(WEEKNUM(23760, 12), 3);
1207+  //type=13
1208+  assertEquals(WEEKNUM(23737, 13), 52);
1209+  assertEquals(WEEKNUM(23738, 13), 52);
1210+  assertEquals(WEEKNUM(23739, 13), 52);
1211+  assertEquals(WEEKNUM(23740, 13), 52);
1212+  assertEquals(WEEKNUM(23741, 13), 53);
1213+  assertEquals(WEEKNUM(23742, 13), 53);
1214+  assertEquals(WEEKNUM(23743, 13), 1);
1215+  assertEquals(WEEKNUM(23744, 13), 1);
1216+  assertEquals(WEEKNUM(23745, 13), 1);
1217+  assertEquals(WEEKNUM(23746, 13), 1);
1218+  assertEquals(WEEKNUM(23747, 13), 1);
1219+  assertEquals(WEEKNUM(23748, 13), 2);
1220+  assertEquals(WEEKNUM(23749, 13), 2);
1221+  assertEquals(WEEKNUM(23750, 13), 2);
1222+  assertEquals(WEEKNUM(23751, 13), 2);
1223+  assertEquals(WEEKNUM(23752, 13), 2);
1224+  assertEquals(WEEKNUM(23753, 13), 2);
1225+  assertEquals(WEEKNUM(23754, 13), 2);
1226+  assertEquals(WEEKNUM(23755, 13), 3);
1227+  assertEquals(WEEKNUM(23756, 13), 3);
1228+  assertEquals(WEEKNUM(23757, 13), 3);
1229+  assertEquals(WEEKNUM(23758, 13), 3);
1230+  assertEquals(WEEKNUM(23759, 13), 3);
1231+  assertEquals(WEEKNUM(23760, 13), 3);
1232+  //type=14
1233+  assertEquals(WEEKNUM(23734, 14), 52);
1234+  assertEquals(WEEKNUM(23735, 14), 53);
1235+  assertEquals(WEEKNUM(23736, 14), 53);
1236+  assertEquals(WEEKNUM(23737, 14), 53);
1237+  assertEquals(WEEKNUM(23738, 14), 53);
1238+  assertEquals(WEEKNUM(23739, 14), 53);
1239+  assertEquals(WEEKNUM(23740, 14), 53);
1240+  assertEquals(WEEKNUM(23741, 14), 53);
1241+  assertEquals(WEEKNUM(23742, 14), 54);
1242+  assertEquals(WEEKNUM(23743, 14), 1);
1243+  assertEquals(WEEKNUM(23744, 14), 1);
1244+  assertEquals(WEEKNUM(23745, 14), 1);
1245+  assertEquals(WEEKNUM(23746, 14), 1);
1246+  assertEquals(WEEKNUM(23747, 14), 1);
1247+  assertEquals(WEEKNUM(23748, 14), 1);
1248+  assertEquals(WEEKNUM(23749, 14), 2);
1249+  assertEquals(WEEKNUM(23750, 14), 2);
1250+  assertEquals(WEEKNUM(23751, 14), 2);
1251+  assertEquals(WEEKNUM(23752, 14), 2);
1252+  assertEquals(WEEKNUM(23753, 14), 2);
1253+  assertEquals(WEEKNUM(23754, 14), 2);
1254+  assertEquals(WEEKNUM(23755, 14), 2);
1255+  assertEquals(WEEKNUM(23756, 14), 3);
1256+  assertEquals(WEEKNUM(23757, 14), 3);
1257+  assertEquals(WEEKNUM(23758, 14), 3);
1258+  assertEquals(WEEKNUM(23759, 14), 3);
1259+  assertEquals(WEEKNUM(23760, 14), 3);
1260+  //type=14 again
1261+  assertEquals(WEEKNUM(355, 14), 52);
1262+  assertEquals(WEEKNUM(356, 14), 52);
1263+  assertEquals(WEEKNUM(357, 14), 52);
1264+  assertEquals(WEEKNUM(358, 14), 52);
1265+  assertEquals(WEEKNUM(359, 14), 52);
1266+  assertEquals(WEEKNUM(360, 14), 52);
1267+  assertEquals(WEEKNUM(361, 14), 52);
1268+  assertEquals(WEEKNUM(362, 14), 53);
1269+  assertEquals(WEEKNUM(363, 14), 53);
1270+  assertEquals(WEEKNUM(364, 14), 53);
1271+  assertEquals(WEEKNUM(365, 14), 53);
1272+  assertEquals(WEEKNUM(366, 14), 53);
1273+  assertEquals(WEEKNUM(367, 14), 1);
1274+  assertEquals(WEEKNUM(368, 14), 1);
1275+  assertEquals(WEEKNUM(369, 14), 2);
1276+  assertEquals(WEEKNUM(370, 14), 2);
1277+  assertEquals(WEEKNUM(371, 14), 2);
1278+  assertEquals(WEEKNUM(372, 14), 2);
1279+  assertEquals(WEEKNUM(373, 14), 2);
1280+  assertEquals(WEEKNUM(374, 14), 2);
1281+  assertEquals(WEEKNUM(375, 14), 2);
1282+  assertEquals(WEEKNUM(376, 14), 3);
1283+  assertEquals(WEEKNUM(377, 14), 3);
1284+  assertEquals(WEEKNUM(378, 14), 3);
1285+  assertEquals(WEEKNUM(379, 14), 3);
1286+  assertEquals(WEEKNUM(380, 14), 3);
1287+  assertEquals(WEEKNUM(381, 14), 3);
1288+  //type=14 again
1289+  assertEquals(WEEKNUM(730, 14), 53);
1290+  assertEquals(WEEKNUM(731, 14), 53);
1291+  assertEquals(WEEKNUM(732, 14), 1);
1292+  assertEquals(WEEKNUM(733, 14), 2);
1293+  assertEquals(WEEKNUM(734, 14), 2);
1294+  assertEquals(WEEKNUM(735, 14), 2);
1295+  assertEquals(WEEKNUM(736, 14), 2);
1296+  assertEquals(WEEKNUM(737, 14), 2);
1297+  assertEquals(WEEKNUM(738, 14), 2);
1298+  assertEquals(WEEKNUM(739, 14), 2);
1299+  assertEquals(WEEKNUM(740, 14), 3);
1300+  assertEquals(WEEKNUM(741, 14), 3);
1301+  assertEquals(WEEKNUM(742, 14), 3);
1302+  assertEquals(WEEKNUM(743, 14), 3);
1303+  assertEquals(WEEKNUM(744, 14), 3);
1304+  assertEquals(WEEKNUM(745, 14), 3);
1305+  assertEquals(WEEKNUM(746, 14), 3);
1306+  //type=15
1307+  assertEquals(WEEKNUM(23734, 15), 52);
1308+  assertEquals(WEEKNUM(23735, 15), 52);
1309+  assertEquals(WEEKNUM(23736, 15), 53);
1310+  assertEquals(WEEKNUM(23737, 15), 53);
1311+  assertEquals(WEEKNUM(23738, 15), 53);
1312+  assertEquals(WEEKNUM(23739, 15), 53);
1313+  assertEquals(WEEKNUM(23740, 15), 53);
1314+  assertEquals(WEEKNUM(23741, 15), 53);
1315+  assertEquals(WEEKNUM(23742, 15), 53);
1316+  assertEquals(WEEKNUM(23743, 15), 1);
1317+  assertEquals(WEEKNUM(23744, 15), 1);
1318+  assertEquals(WEEKNUM(23745, 15), 1);
1319+  assertEquals(WEEKNUM(23746, 15), 1);
1320+  assertEquals(WEEKNUM(23747, 15), 1);
1321+  assertEquals(WEEKNUM(23748, 15), 1);
1322+  assertEquals(WEEKNUM(23749, 15), 1);
1323+  assertEquals(WEEKNUM(23750, 15), 2);
1324+  assertEquals(WEEKNUM(23751, 15), 2);
1325+  assertEquals(WEEKNUM(23752, 15), 2);
1326+  assertEquals(WEEKNUM(23753, 15), 2);
1327+  assertEquals(WEEKNUM(23754, 15), 2);
1328+  assertEquals(WEEKNUM(23755, 15), 2);
1329+  assertEquals(WEEKNUM(23756, 15), 2);
1330+  assertEquals(WEEKNUM(23757, 15), 3);
1331+  assertEquals(WEEKNUM(23758, 15), 3);
1332+  assertEquals(WEEKNUM(23759, 15), 3);
1333+  assertEquals(WEEKNUM(23760, 15), 3);
1334+  //type=15 again
1335+  assertEquals(WEEKNUM(355, 15), 51);
1336+  assertEquals(WEEKNUM(356, 15), 52);
1337+  assertEquals(WEEKNUM(357, 15), 52);
1338+  assertEquals(WEEKNUM(358, 15), 52);
1339+  assertEquals(WEEKNUM(359, 15), 52);
1340+  assertEquals(WEEKNUM(360, 15), 52);
1341+  assertEquals(WEEKNUM(361, 15), 52);
1342+  assertEquals(WEEKNUM(362, 15), 52);
1343+  assertEquals(WEEKNUM(363, 15), 53);
1344+  assertEquals(WEEKNUM(364, 15), 53);
1345+  assertEquals(WEEKNUM(365, 15), 53);
1346+  assertEquals(WEEKNUM(366, 15), 53);
1347+  assertEquals(WEEKNUM(367, 15), 1);
1348+  assertEquals(WEEKNUM(368, 15), 1);
1349+  assertEquals(WEEKNUM(369, 15), 1);
1350+  assertEquals(WEEKNUM(370, 15), 2);
1351+  assertEquals(WEEKNUM(371, 15), 2);
1352+  assertEquals(WEEKNUM(372, 15), 2);
1353+  assertEquals(WEEKNUM(373, 15), 2);
1354+  assertEquals(WEEKNUM(374, 15), 2);
1355+  assertEquals(WEEKNUM(375, 15), 2);
1356+  assertEquals(WEEKNUM(376, 15), 2);
1357+  assertEquals(WEEKNUM(377, 15), 3);
1358+  assertEquals(WEEKNUM(378, 15), 3);
1359+  assertEquals(WEEKNUM(379, 15), 3);
1360+  assertEquals(WEEKNUM(380, 15), 3);
1361+  assertEquals(WEEKNUM(381, 15), 3);
1362+  //type=15 again
1363+  assertEquals(WEEKNUM(730, 15), 53);
1364+  assertEquals(WEEKNUM(731, 15), 53);
1365+  assertEquals(WEEKNUM(732, 15), 1);
1366+  assertEquals(WEEKNUM(733, 15), 1);
1367+  assertEquals(WEEKNUM(734, 15), 2);
1368+  assertEquals(WEEKNUM(735, 15), 2);
1369+  assertEquals(WEEKNUM(736, 15), 2);
1370+  assertEquals(WEEKNUM(737, 15), 2);
1371+  assertEquals(WEEKNUM(738, 15), 2);
1372+  assertEquals(WEEKNUM(739, 15), 2);
1373+  assertEquals(WEEKNUM(740, 15), 2);
1374+  assertEquals(WEEKNUM(741, 15), 3);
1375+  assertEquals(WEEKNUM(742, 15), 3);
1376+  assertEquals(WEEKNUM(743, 15), 3);
1377+  assertEquals(WEEKNUM(744, 15), 3);
1378+  assertEquals(WEEKNUM(745, 15), 3);
1379+  assertEquals(WEEKNUM(746, 15), 3);
1380+  //type=16
1381+  assertEquals(WEEKNUM(23734, 16), 52);
1382+  assertEquals(WEEKNUM(23735, 16), 52);
1383+  assertEquals(WEEKNUM(23736, 16), 52);
1384+  assertEquals(WEEKNUM(23737, 16), 53);
1385+  assertEquals(WEEKNUM(23738, 16), 53);
1386+  assertEquals(WEEKNUM(23739, 16), 53);
1387+  assertEquals(WEEKNUM(23740, 16), 53);
1388+  assertEquals(WEEKNUM(23741, 16), 53);
1389+  assertEquals(WEEKNUM(23742, 16), 53);
1390+  assertEquals(WEEKNUM(23743, 16), 1);
1391+  assertEquals(WEEKNUM(23744, 16), 2);
1392+  assertEquals(WEEKNUM(23745, 16), 2);
1393+  assertEquals(WEEKNUM(23746, 16), 2);
1394+  assertEquals(WEEKNUM(23747, 16), 2);
1395+  assertEquals(WEEKNUM(23748, 16), 2);
1396+  assertEquals(WEEKNUM(23749, 16), 2);
1397+  assertEquals(WEEKNUM(23750, 16), 2);
1398+  assertEquals(WEEKNUM(23751, 16), 3);
1399+  assertEquals(WEEKNUM(23752, 16), 3);
1400+  assertEquals(WEEKNUM(23753, 16), 3);
1401+  assertEquals(WEEKNUM(23754, 16), 3);
1402+  assertEquals(WEEKNUM(23755, 16), 3);
1403+  assertEquals(WEEKNUM(23756, 16), 3);
1404+  assertEquals(WEEKNUM(23757, 16), 3);
1405+  assertEquals(WEEKNUM(23758, 16), 4);
1406+  assertEquals(WEEKNUM(23759, 16), 4);
1407+  assertEquals(WEEKNUM(23760, 16), 4);
1408+  // //type=16 again
1409+  assertEquals(WEEKNUM(355, 16), 51);
1410+  assertEquals(WEEKNUM(356, 16), 51);
1411+  assertEquals(WEEKNUM(357, 16), 52);
1412+  assertEquals(WEEKNUM(358, 16), 52);
1413+  assertEquals(WEEKNUM(359, 16), 52);
1414+  assertEquals(WEEKNUM(360, 16), 52);
1415+  assertEquals(WEEKNUM(361, 16), 52);
1416+  assertEquals(WEEKNUM(362, 16), 52);
1417+  assertEquals(WEEKNUM(363, 16), 52);
1418+  assertEquals(WEEKNUM(364, 16), 53);
1419+  assertEquals(WEEKNUM(365, 16), 53);
1420+  assertEquals(WEEKNUM(366, 16), 53);
1421+  assertEquals(WEEKNUM(367, 16), 1);
1422+  assertEquals(WEEKNUM(368, 16), 1);
1423+  assertEquals(WEEKNUM(369, 16), 1);
1424+  assertEquals(WEEKNUM(370, 16), 1);
1425+  assertEquals(WEEKNUM(371, 16), 2);
1426+  assertEquals(WEEKNUM(372, 16), 2);
1427+  assertEquals(WEEKNUM(373, 16), 2);
1428+  assertEquals(WEEKNUM(374, 16), 2);
1429+  assertEquals(WEEKNUM(375, 16), 2);
1430+  assertEquals(WEEKNUM(376, 16), 2);
1431+  assertEquals(WEEKNUM(377, 16), 2);
1432+  assertEquals(WEEKNUM(378, 16), 3);
1433+  assertEquals(WEEKNUM(379, 16), 3);
1434+  assertEquals(WEEKNUM(380, 16), 3);
1435+  assertEquals(WEEKNUM(381, 16), 3);
1436+  //type=16 again
1437+  assertEquals(WEEKNUM(730, 16), 53);
1438+  assertEquals(WEEKNUM(731, 16), 53);
1439+  assertEquals(WEEKNUM(732, 16), 1);
1440+  assertEquals(WEEKNUM(733, 16), 1);
1441+  assertEquals(WEEKNUM(734, 16), 1);
1442+  assertEquals(WEEKNUM(735, 16), 2);
1443+  assertEquals(WEEKNUM(736, 16), 2);
1444+  assertEquals(WEEKNUM(737, 16), 2);
1445+  assertEquals(WEEKNUM(738, 16), 2);
1446+  assertEquals(WEEKNUM(739, 16), 2);
1447+  assertEquals(WEEKNUM(740, 16), 2);
1448+  assertEquals(WEEKNUM(741, 16), 2);
1449+  assertEquals(WEEKNUM(742, 16), 3);
1450+  assertEquals(WEEKNUM(743, 16), 3);
1451+  assertEquals(WEEKNUM(744, 16), 3);
1452+  assertEquals(WEEKNUM(745, 16), 3);
1453+  assertEquals(WEEKNUM(746, 16), 3);
1454+  //type=17
1455+  assertEquals(WEEKNUM(23734, 17), 52);
1456+  assertEquals(WEEKNUM(23735, 17), 52);
1457+  assertEquals(WEEKNUM(23736, 17), 52);
1458+  assertEquals(WEEKNUM(23737, 17), 52);
1459+  assertEquals(WEEKNUM(23738, 17), 53);
1460+  assertEquals(WEEKNUM(23739, 17), 53);
1461+  assertEquals(WEEKNUM(23740, 17), 53);
1462+  assertEquals(WEEKNUM(23741, 17), 53);
1463+  assertEquals(WEEKNUM(23742, 17), 53);
1464+  assertEquals(WEEKNUM(23743, 17), 1);
1465+  assertEquals(WEEKNUM(23744, 17), 1);
1466+  assertEquals(WEEKNUM(23745, 17), 2);
1467+  assertEquals(WEEKNUM(23746, 17), 2);
1468+  assertEquals(WEEKNUM(23747, 17), 2);
1469+  assertEquals(WEEKNUM(23748, 17), 2);
1470+  assertEquals(WEEKNUM(23749, 17), 2);
1471+  assertEquals(WEEKNUM(23750, 17), 2);
1472+  assertEquals(WEEKNUM(23751, 17), 2);
1473+  assertEquals(WEEKNUM(23752, 17), 3);
1474+  assertEquals(WEEKNUM(23753, 17), 3);
1475+  assertEquals(WEEKNUM(23754, 17), 3);
1476+  assertEquals(WEEKNUM(23755, 17), 3);
1477+  assertEquals(WEEKNUM(23756, 17), 3);
1478+  assertEquals(WEEKNUM(23757, 17), 3);
1479+  assertEquals(WEEKNUM(23758, 17), 3);
1480+  assertEquals(WEEKNUM(23759, 17), 4);
1481+  assertEquals(WEEKNUM(23760, 17), 4);
1482+  // //type=17 again
1483+  assertEquals(WEEKNUM(355, 17), 51);
1484+  assertEquals(WEEKNUM(356, 17), 51);
1485+  assertEquals(WEEKNUM(357, 17), 51);
1486+  assertEquals(WEEKNUM(358, 17), 52);
1487+  assertEquals(WEEKNUM(359, 17), 52);
1488+  assertEquals(WEEKNUM(360, 17), 52);
1489+  assertEquals(WEEKNUM(361, 17), 52);
1490+  assertEquals(WEEKNUM(362, 17), 52);
1491+  assertEquals(WEEKNUM(363, 17), 52);
1492+  assertEquals(WEEKNUM(364, 17), 52);
1493+  assertEquals(WEEKNUM(365, 17), 53);
1494+  assertEquals(WEEKNUM(366, 17), 53);
1495+  assertEquals(WEEKNUM(367, 17), 1);
1496+  assertEquals(WEEKNUM(368, 17), 1);
1497+  assertEquals(WEEKNUM(369, 17), 1);
1498+  assertEquals(WEEKNUM(370, 17), 1);
1499+  assertEquals(WEEKNUM(371, 17), 1);
1500+  assertEquals(WEEKNUM(372, 17), 2);
1501+  assertEquals(WEEKNUM(373, 17), 2);
1502+  assertEquals(WEEKNUM(374, 17), 2);
1503+  assertEquals(WEEKNUM(375, 17), 2);
1504+  assertEquals(WEEKNUM(376, 17), 2);
1505+  assertEquals(WEEKNUM(377, 17), 2);
1506+  assertEquals(WEEKNUM(378, 17), 2);
1507+  assertEquals(WEEKNUM(379, 17), 3);
1508+  assertEquals(WEEKNUM(380, 17), 3);
1509+  assertEquals(WEEKNUM(381, 17), 3);
1510+  //type=17 again
1511+  assertEquals(WEEKNUM(730, 17), 53);
1512+  assertEquals(WEEKNUM(731, 17), 53);
1513+  assertEquals(WEEKNUM(732, 17), 1);
1514+  assertEquals(WEEKNUM(733, 17), 1);
1515+  assertEquals(WEEKNUM(734, 17), 1);
1516+  assertEquals(WEEKNUM(735, 17), 1);
1517+  assertEquals(WEEKNUM(736, 17), 2);
1518+  assertEquals(WEEKNUM(737, 17), 2);
1519+  assertEquals(WEEKNUM(738, 17), 2);
1520+  assertEquals(WEEKNUM(739, 17), 2);
1521+  assertEquals(WEEKNUM(740, 17), 2);
1522+  assertEquals(WEEKNUM(741, 17), 2);
1523+  assertEquals(WEEKNUM(742, 17), 2);
1524+  assertEquals(WEEKNUM(743, 17), 3);
1525+  assertEquals(WEEKNUM(744, 17), 3);
1526+  assertEquals(WEEKNUM(745, 17), 3);
1527+  assertEquals(WEEKNUM(746, 17), 3);
1528+  //type=21
1529+  assertEquals(WEEKNUM(23730, 21), 51);
1530+  assertEquals(WEEKNUM(23731, 21), 51);
1531+  assertEquals(WEEKNUM(23732, 21), 52);
1532+  assertEquals(WEEKNUM(23733, 21), 52);
1533+  assertEquals(WEEKNUM(23734, 21), 52);
1534+  assertEquals(WEEKNUM(23735, 21), 52);
1535+  assertEquals(WEEKNUM(23736, 21), 52);
1536+  assertEquals(WEEKNUM(23737, 21), 52);
1537+  assertEquals(WEEKNUM(23738, 21), 52);
1538+  assertEquals(WEEKNUM(23739, 21), 53);
1539+  assertEquals(WEEKNUM(23740, 21), 53);
1540+  assertEquals(WEEKNUM(23741, 21), 53);
1541+  assertEquals(WEEKNUM(23742, 21), 53);
1542+  assertEquals(WEEKNUM(23743, 21), 53);
1543+  assertEquals(WEEKNUM(23744, 21), 53);
1544+  assertEquals(WEEKNUM(23745, 21), 53);
1545+  assertEquals(WEEKNUM(23746, 21), 1);
1546+  assertEquals(WEEKNUM(23747, 21), 1);
1547+  assertEquals(WEEKNUM(23748, 21), 1);
1548+  assertEquals(WEEKNUM(23749, 21), 1);
1549+  assertEquals(WEEKNUM(23750, 21), 1);
1550+  assertEquals(WEEKNUM(23751, 21), 1);
1551+  assertEquals(WEEKNUM(23752, 21), 1);
1552+  assertEquals(WEEKNUM(23753, 21), 2);
1553+  assertEquals(WEEKNUM(23754, 21), 2);
1554+  assertEquals(WEEKNUM(23755, 21), 2);
1555+  assertEquals(WEEKNUM(23756, 21), 2);
1556+  assertEquals(WEEKNUM(23757, 21), 2);
1557+  assertEquals(WEEKNUM(23758, 21), 2);
1558+  assertEquals(WEEKNUM(23759, 21), 2);
1559+  assertEquals(WEEKNUM(23760, 21), 3);
1560+  // //type=21 again
1561+  assertEquals(WEEKNUM(355, 21), 51);
1562+  assertEquals(WEEKNUM(356, 21), 51);
1563+  assertEquals(WEEKNUM(357, 21), 51);
1564+  assertEquals(WEEKNUM(358, 21), 51);
1565+  assertEquals(WEEKNUM(359, 21), 52);
1566+  assertEquals(WEEKNUM(360, 21), 52);
1567+  assertEquals(WEEKNUM(361, 21), 52);
1568+  assertEquals(WEEKNUM(362, 21), 52);
1569+  assertEquals(WEEKNUM(363, 21), 52);
1570+  assertEquals(WEEKNUM(364, 21), 52);
1571+  assertEquals(WEEKNUM(365, 21), 52);
1572+  assertEquals(WEEKNUM(366, 21), 1);
1573+  assertEquals(WEEKNUM(367, 21), 1);
1574+  assertEquals(WEEKNUM(368, 21), 1);
1575+  assertEquals(WEEKNUM(369, 21), 1);
1576+  assertEquals(WEEKNUM(370, 21), 1);
1577+  assertEquals(WEEKNUM(371, 21), 1);
1578+  assertEquals(WEEKNUM(372, 21), 1);
1579+  assertEquals(WEEKNUM(373, 21), 2);
1580+  assertEquals(WEEKNUM(374, 21), 2);
1581+  assertEquals(WEEKNUM(375, 21), 2);
1582+  assertEquals(WEEKNUM(376, 21), 2);
1583+  assertEquals(WEEKNUM(377, 21), 2);
1584+  assertEquals(WEEKNUM(378, 21), 2);
1585+  assertEquals(WEEKNUM(379, 21), 2);
1586+  assertEquals(WEEKNUM(380, 21), 3);
1587+  assertEquals(WEEKNUM(381, 21), 3);
1588+  // //type=21 again
1589+  assertEquals(WEEKNUM(728, 21), 52);
1590+  assertEquals(WEEKNUM(729, 21), 52);
1591+  assertEquals(WEEKNUM(730, 21), 1);
1592+  assertEquals(WEEKNUM(731, 21), 1);
1593+  assertEquals(WEEKNUM(732, 21), 1);
1594+  assertEquals(WEEKNUM(733, 21), 1);
1595+  assertEquals(WEEKNUM(734, 21), 1);
1596+  assertEquals(WEEKNUM(735, 21), 1);
1597+  assertEquals(WEEKNUM(736, 21), 1);
1598+  assertEquals(WEEKNUM(737, 21), 2);
1599+  assertEquals(WEEKNUM(738, 21), 2);
1600+  assertEquals(WEEKNUM(739, 21), 2);
1601+  assertEquals(WEEKNUM(740, 21), 2);
1602+  assertEquals(WEEKNUM(741, 21), 2);
1603+  assertEquals(WEEKNUM(742, 21), 2);
1604+  assertEquals(WEEKNUM(743, 21), 2);
1605+  assertEquals(WEEKNUM(744, 21), 3);
1606+  assertEquals(WEEKNUM(745, 21), 3);
1607+  assertEquals(WEEKNUM(746, 21), 3);
1608+  catchAndAssertEquals(function() {
1609+    WEEKNUM();
1610+  }, ERRORS.NA_ERROR);
1611+  catchAndAssertEquals(function() {
1612+    WEEKNUM(213123, 1, 1);
1613+  }, ERRORS.NA_ERROR);
1614+  catchAndAssertEquals(function() {
1615+    WEEKNUM("str");
1616+  }, ERRORS.VALUE_ERROR);
1617+  catchAndAssertEquals(function() {
1618+    WEEKNUM([]);
1619+  }, ERRORS.REF_ERROR);
1620+  catchAndAssertEquals(function() {
1621+    WEEKNUM(-10);
1622+  }, ERRORS.NUM_ERROR);
1623+  catchAndAssertEquals(function() {
1624+    WEEKNUM(10, 4);
1625+  }, ERRORS.NUM_ERROR);
1626+  catchAndAssertEquals(function() {
1627+    WEEKNUM(10, 22);
1628+  }, ERRORS.NUM_ERROR);
1629+});
1630 
1631 
1632-// Test WEEKNUM
1633-assertEquals(WEEKNUM(DATE(1992, 6, 19)), 25);
1634-assertEquals(WEEKNUM(DATE(1992, 6, 20)), 25);
1635-assertEquals(WEEKNUM(DATE(1992, 6, 21)), 26);
1636-assertEquals(WEEKNUM(0), 52);
1637-assertEquals(WEEKNUM(false), 52);
1638-assertEquals(WEEKNUM(1), 53);
1639-assertEquals(WEEKNUM(true), 53);
1640-assertEquals(WEEKNUM(2), 1);
1641-assertEquals(WEEKNUM(3), 1);
1642-assertEquals(WEEKNUM(4), 1);
1643-assertEquals(WEEKNUM(5), 1);
1644-assertEquals(WEEKNUM(6), 1);
1645-assertEquals(WEEKNUM(7), 1);
1646-assertEquals(WEEKNUM(8), 2);
1647-assertEquals(WEEKNUM(9), 2);
1648-assertEquals(WEEKNUM(10), 2);
1649-assertEquals(WEEKNUM(11), 2);
1650-assertEquals(WEEKNUM(12), 2);
1651-assertEquals(WEEKNUM(13), 2);
1652-assertEquals(WEEKNUM(14), 2);
1653-assertEquals(WEEKNUM(15), 3);
1654-assertEquals(WEEKNUM(16), 3);
1655-assertEquals(WEEKNUM(17), 3);
1656-assertEquals(WEEKNUM(18), 3);
1657-assertEquals(WEEKNUM(23734), 52);
1658-assertEquals(WEEKNUM(23735), 52);
1659-assertEquals(WEEKNUM(23736), 52);
1660-assertEquals(WEEKNUM(23737), 52);
1661-assertEquals(WEEKNUM(23738), 53);
1662-assertEquals(WEEKNUM(23739), 53);
1663-assertEquals(WEEKNUM(23740), 53);
1664-assertEquals(WEEKNUM(23741), 53);
1665-assertEquals(WEEKNUM(23742), 53);
1666-assertEquals(WEEKNUM(23743), 1);
1667-assertEquals(WEEKNUM(23744), 1);
1668-assertEquals(WEEKNUM(23745), 2);
1669-assertEquals(WEEKNUM(23746), 2);
1670-assertEquals(WEEKNUM(23747), 2);
1671-assertEquals(WEEKNUM(23748), 2);
1672-assertEquals(WEEKNUM(23749), 2);
1673-assertEquals(WEEKNUM(23750), 2);
1674-assertEquals(WEEKNUM(23751), 2);
1675-assertEquals(WEEKNUM(23752), 3);
1676-// type=2
1677-assertEquals(WEEKNUM(23737, 2), 52);
1678-assertEquals(WEEKNUM(23738, 2), 52);
1679-assertEquals(WEEKNUM(23739, 2), 53);
1680-assertEquals(WEEKNUM(23740, 2), 53);
1681-assertEquals(WEEKNUM(23741, 2), 53);
1682-assertEquals(WEEKNUM(23742, 2), 53);
1683-assertEquals(WEEKNUM(23743, 2), 1);
1684-assertEquals(WEEKNUM(23744, 2), 1);
1685-assertEquals(WEEKNUM(23745, 2), 1);
1686-assertEquals(WEEKNUM(23746, 2), 2);
1687-assertEquals(WEEKNUM(23747, 2), 2);
1688-assertEquals(WEEKNUM(23748, 2), 2);
1689-assertEquals(WEEKNUM(23749, 2), 2);
1690-assertEquals(WEEKNUM(23750, 2), 2);
1691-assertEquals(WEEKNUM(23751, 2), 2);
1692-assertEquals(WEEKNUM(23752, 2), 2);
1693-assertEquals(WEEKNUM(23753, 2), 3);
1694-assertEquals(WEEKNUM(23754, 2), 3);
1695-assertEquals(WEEKNUM(23755, 2), 3);
1696-assertEquals(WEEKNUM(23756, 2), 3);
1697-assertEquals(WEEKNUM(23757, 2), 3);
1698-assertEquals(WEEKNUM(23758, 2), 3);
1699-assertEquals(WEEKNUM(23759, 2), 3);
1700-assertEquals(WEEKNUM(23760, 2), 4);
1701-//type=11
1702-assertEquals(WEEKNUM(23737, 11), 52);
1703-assertEquals(WEEKNUM(23738, 11), 52);
1704-assertEquals(WEEKNUM(23739, 11), 53);
1705-assertEquals(WEEKNUM(23740, 11), 53);
1706-assertEquals(WEEKNUM(23741, 11), 53);
1707-assertEquals(WEEKNUM(23742, 11), 53);
1708-assertEquals(WEEKNUM(23743, 11), 1);
1709-assertEquals(WEEKNUM(23744, 11), 1);
1710-assertEquals(WEEKNUM(23745, 11), 1);
1711-assertEquals(WEEKNUM(23746, 11), 2);
1712-assertEquals(WEEKNUM(23747, 11), 2);
1713-assertEquals(WEEKNUM(23748, 11), 2);
1714-assertEquals(WEEKNUM(23749, 11), 2);
1715-assertEquals(WEEKNUM(23750, 11), 2);
1716-assertEquals(WEEKNUM(23751, 11), 2);
1717-assertEquals(WEEKNUM(23752, 11), 2);
1718-assertEquals(WEEKNUM(23753, 11), 3);
1719-assertEquals(WEEKNUM(23754, 11), 3);
1720-assertEquals(WEEKNUM(23755, 11), 3);
1721-assertEquals(WEEKNUM(23756, 11), 3);
1722-assertEquals(WEEKNUM(23757, 11), 3);
1723-assertEquals(WEEKNUM(23758, 11), 3);
1724-assertEquals(WEEKNUM(23759, 11), 3);
1725-assertEquals(WEEKNUM(23760, 11), 4);
1726-//type=12
1727-assertEquals(WEEKNUM(23737, 12), 52);
1728-assertEquals(WEEKNUM(23738, 12), 52);
1729-assertEquals(WEEKNUM(23739, 12), 52);
1730-assertEquals(WEEKNUM(23740, 12), 53);
1731-assertEquals(WEEKNUM(23741, 12), 53);
1732-assertEquals(WEEKNUM(23742, 12), 53);
1733-assertEquals(WEEKNUM(23743, 12), 1);
1734-assertEquals(WEEKNUM(23744, 12), 1);
1735-assertEquals(WEEKNUM(23745, 12), 1);
1736-assertEquals(WEEKNUM(23746, 12), 1);
1737-assertEquals(WEEKNUM(23747, 12), 2);
1738-assertEquals(WEEKNUM(23748, 12), 2);
1739-assertEquals(WEEKNUM(23749, 12), 2);
1740-assertEquals(WEEKNUM(23750, 12), 2);
1741-assertEquals(WEEKNUM(23751, 12), 2);
1742-assertEquals(WEEKNUM(23752, 12), 2);
1743-assertEquals(WEEKNUM(23753, 12), 2);
1744-assertEquals(WEEKNUM(23754, 12), 3);
1745-assertEquals(WEEKNUM(23755, 12), 3);
1746-assertEquals(WEEKNUM(23756, 12), 3);
1747-assertEquals(WEEKNUM(23757, 12), 3);
1748-assertEquals(WEEKNUM(23758, 12), 3);
1749-assertEquals(WEEKNUM(23759, 12), 3);
1750-assertEquals(WEEKNUM(23760, 12), 3);
1751-//type=13
1752-assertEquals(WEEKNUM(23737, 13), 52);
1753-assertEquals(WEEKNUM(23738, 13), 52);
1754-assertEquals(WEEKNUM(23739, 13), 52);
1755-assertEquals(WEEKNUM(23740, 13), 52);
1756-assertEquals(WEEKNUM(23741, 13), 53);
1757-assertEquals(WEEKNUM(23742, 13), 53);
1758-assertEquals(WEEKNUM(23743, 13), 1);
1759-assertEquals(WEEKNUM(23744, 13), 1);
1760-assertEquals(WEEKNUM(23745, 13), 1);
1761-assertEquals(WEEKNUM(23746, 13), 1);
1762-assertEquals(WEEKNUM(23747, 13), 1);
1763-assertEquals(WEEKNUM(23748, 13), 2);
1764-assertEquals(WEEKNUM(23749, 13), 2);
1765-assertEquals(WEEKNUM(23750, 13), 2);
1766-assertEquals(WEEKNUM(23751, 13), 2);
1767-assertEquals(WEEKNUM(23752, 13), 2);
1768-assertEquals(WEEKNUM(23753, 13), 2);
1769-assertEquals(WEEKNUM(23754, 13), 2);
1770-assertEquals(WEEKNUM(23755, 13), 3);
1771-assertEquals(WEEKNUM(23756, 13), 3);
1772-assertEquals(WEEKNUM(23757, 13), 3);
1773-assertEquals(WEEKNUM(23758, 13), 3);
1774-assertEquals(WEEKNUM(23759, 13), 3);
1775-assertEquals(WEEKNUM(23760, 13), 3);
1776-//type=14
1777-assertEquals(WEEKNUM(23734, 14), 52);
1778-assertEquals(WEEKNUM(23735, 14), 53);
1779-assertEquals(WEEKNUM(23736, 14), 53);
1780-assertEquals(WEEKNUM(23737, 14), 53);
1781-assertEquals(WEEKNUM(23738, 14), 53);
1782-assertEquals(WEEKNUM(23739, 14), 53);
1783-assertEquals(WEEKNUM(23740, 14), 53);
1784-assertEquals(WEEKNUM(23741, 14), 53);
1785-assertEquals(WEEKNUM(23742, 14), 54);
1786-assertEquals(WEEKNUM(23743, 14), 1);
1787-assertEquals(WEEKNUM(23744, 14), 1);
1788-assertEquals(WEEKNUM(23745, 14), 1);
1789-assertEquals(WEEKNUM(23746, 14), 1);
1790-assertEquals(WEEKNUM(23747, 14), 1);
1791-assertEquals(WEEKNUM(23748, 14), 1);
1792-assertEquals(WEEKNUM(23749, 14), 2);
1793-assertEquals(WEEKNUM(23750, 14), 2);
1794-assertEquals(WEEKNUM(23751, 14), 2);
1795-assertEquals(WEEKNUM(23752, 14), 2);
1796-assertEquals(WEEKNUM(23753, 14), 2);
1797-assertEquals(WEEKNUM(23754, 14), 2);
1798-assertEquals(WEEKNUM(23755, 14), 2);
1799-assertEquals(WEEKNUM(23756, 14), 3);
1800-assertEquals(WEEKNUM(23757, 14), 3);
1801-assertEquals(WEEKNUM(23758, 14), 3);
1802-assertEquals(WEEKNUM(23759, 14), 3);
1803-assertEquals(WEEKNUM(23760, 14), 3);
1804-//type=14 again
1805-assertEquals(WEEKNUM(355, 14), 52);
1806-assertEquals(WEEKNUM(356, 14), 52);
1807-assertEquals(WEEKNUM(357, 14), 52);
1808-assertEquals(WEEKNUM(358, 14), 52);
1809-assertEquals(WEEKNUM(359, 14), 52);
1810-assertEquals(WEEKNUM(360, 14), 52);
1811-assertEquals(WEEKNUM(361, 14), 52);
1812-assertEquals(WEEKNUM(362, 14), 53);
1813-assertEquals(WEEKNUM(363, 14), 53);
1814-assertEquals(WEEKNUM(364, 14), 53);
1815-assertEquals(WEEKNUM(365, 14), 53);
1816-assertEquals(WEEKNUM(366, 14), 53);
1817-assertEquals(WEEKNUM(367, 14), 1);
1818-assertEquals(WEEKNUM(368, 14), 1);
1819-assertEquals(WEEKNUM(369, 14), 2);
1820-assertEquals(WEEKNUM(370, 14), 2);
1821-assertEquals(WEEKNUM(371, 14), 2);
1822-assertEquals(WEEKNUM(372, 14), 2);
1823-assertEquals(WEEKNUM(373, 14), 2);
1824-assertEquals(WEEKNUM(374, 14), 2);
1825-assertEquals(WEEKNUM(375, 14), 2);
1826-assertEquals(WEEKNUM(376, 14), 3);
1827-assertEquals(WEEKNUM(377, 14), 3);
1828-assertEquals(WEEKNUM(378, 14), 3);
1829-assertEquals(WEEKNUM(379, 14), 3);
1830-assertEquals(WEEKNUM(380, 14), 3);
1831-assertEquals(WEEKNUM(381, 14), 3);
1832-//type=14 again
1833-assertEquals(WEEKNUM(730, 14), 53);
1834-assertEquals(WEEKNUM(731, 14), 53);
1835-assertEquals(WEEKNUM(732, 14), 1);
1836-assertEquals(WEEKNUM(733, 14), 2);
1837-assertEquals(WEEKNUM(734, 14), 2);
1838-assertEquals(WEEKNUM(735, 14), 2);
1839-assertEquals(WEEKNUM(736, 14), 2);
1840-assertEquals(WEEKNUM(737, 14), 2);
1841-assertEquals(WEEKNUM(738, 14), 2);
1842-assertEquals(WEEKNUM(739, 14), 2);
1843-assertEquals(WEEKNUM(740, 14), 3);
1844-assertEquals(WEEKNUM(741, 14), 3);
1845-assertEquals(WEEKNUM(742, 14), 3);
1846-assertEquals(WEEKNUM(743, 14), 3);
1847-assertEquals(WEEKNUM(744, 14), 3);
1848-assertEquals(WEEKNUM(745, 14), 3);
1849-assertEquals(WEEKNUM(746, 14), 3);
1850-//type=15
1851-assertEquals(WEEKNUM(23734, 15), 52);
1852-assertEquals(WEEKNUM(23735, 15), 52);
1853-assertEquals(WEEKNUM(23736, 15), 53);
1854-assertEquals(WEEKNUM(23737, 15), 53);
1855-assertEquals(WEEKNUM(23738, 15), 53);
1856-assertEquals(WEEKNUM(23739, 15), 53);
1857-assertEquals(WEEKNUM(23740, 15), 53);
1858-assertEquals(WEEKNUM(23741, 15), 53);
1859-assertEquals(WEEKNUM(23742, 15), 53);
1860-assertEquals(WEEKNUM(23743, 15), 1);
1861-assertEquals(WEEKNUM(23744, 15), 1);
1862-assertEquals(WEEKNUM(23745, 15), 1);
1863-assertEquals(WEEKNUM(23746, 15), 1);
1864-assertEquals(WEEKNUM(23747, 15), 1);
1865-assertEquals(WEEKNUM(23748, 15), 1);
1866-assertEquals(WEEKNUM(23749, 15), 1);
1867-assertEquals(WEEKNUM(23750, 15), 2);
1868-assertEquals(WEEKNUM(23751, 15), 2);
1869-assertEquals(WEEKNUM(23752, 15), 2);
1870-assertEquals(WEEKNUM(23753, 15), 2);
1871-assertEquals(WEEKNUM(23754, 15), 2);
1872-assertEquals(WEEKNUM(23755, 15), 2);
1873-assertEquals(WEEKNUM(23756, 15), 2);
1874-assertEquals(WEEKNUM(23757, 15), 3);
1875-assertEquals(WEEKNUM(23758, 15), 3);
1876-assertEquals(WEEKNUM(23759, 15), 3);
1877-assertEquals(WEEKNUM(23760, 15), 3);
1878-//type=15 again
1879-assertEquals(WEEKNUM(355, 15), 51);
1880-assertEquals(WEEKNUM(356, 15), 52);
1881-assertEquals(WEEKNUM(357, 15), 52);
1882-assertEquals(WEEKNUM(358, 15), 52);
1883-assertEquals(WEEKNUM(359, 15), 52);
1884-assertEquals(WEEKNUM(360, 15), 52);
1885-assertEquals(WEEKNUM(361, 15), 52);
1886-assertEquals(WEEKNUM(362, 15), 52);
1887-assertEquals(WEEKNUM(363, 15), 53);
1888-assertEquals(WEEKNUM(364, 15), 53);
1889-assertEquals(WEEKNUM(365, 15), 53);
1890-assertEquals(WEEKNUM(366, 15), 53);
1891-assertEquals(WEEKNUM(367, 15), 1);
1892-assertEquals(WEEKNUM(368, 15), 1);
1893-assertEquals(WEEKNUM(369, 15), 1);
1894-assertEquals(WEEKNUM(370, 15), 2);
1895-assertEquals(WEEKNUM(371, 15), 2);
1896-assertEquals(WEEKNUM(372, 15), 2);
1897-assertEquals(WEEKNUM(373, 15), 2);
1898-assertEquals(WEEKNUM(374, 15), 2);
1899-assertEquals(WEEKNUM(375, 15), 2);
1900-assertEquals(WEEKNUM(376, 15), 2);
1901-assertEquals(WEEKNUM(377, 15), 3);
1902-assertEquals(WEEKNUM(378, 15), 3);
1903-assertEquals(WEEKNUM(379, 15), 3);
1904-assertEquals(WEEKNUM(380, 15), 3);
1905-assertEquals(WEEKNUM(381, 15), 3);
1906-//type=15 again
1907-assertEquals(WEEKNUM(730, 15), 53);
1908-assertEquals(WEEKNUM(731, 15), 53);
1909-assertEquals(WEEKNUM(732, 15), 1);
1910-assertEquals(WEEKNUM(733, 15), 1);
1911-assertEquals(WEEKNUM(734, 15), 2);
1912-assertEquals(WEEKNUM(735, 15), 2);
1913-assertEquals(WEEKNUM(736, 15), 2);
1914-assertEquals(WEEKNUM(737, 15), 2);
1915-assertEquals(WEEKNUM(738, 15), 2);
1916-assertEquals(WEEKNUM(739, 15), 2);
1917-assertEquals(WEEKNUM(740, 15), 2);
1918-assertEquals(WEEKNUM(741, 15), 3);
1919-assertEquals(WEEKNUM(742, 15), 3);
1920-assertEquals(WEEKNUM(743, 15), 3);
1921-assertEquals(WEEKNUM(744, 15), 3);
1922-assertEquals(WEEKNUM(745, 15), 3);
1923-assertEquals(WEEKNUM(746, 15), 3);
1924-//type=16
1925-assertEquals(WEEKNUM(23734, 16), 52);
1926-assertEquals(WEEKNUM(23735, 16), 52);
1927-assertEquals(WEEKNUM(23736, 16), 52);
1928-assertEquals(WEEKNUM(23737, 16), 53);
1929-assertEquals(WEEKNUM(23738, 16), 53);
1930-assertEquals(WEEKNUM(23739, 16), 53);
1931-assertEquals(WEEKNUM(23740, 16), 53);
1932-assertEquals(WEEKNUM(23741, 16), 53);
1933-assertEquals(WEEKNUM(23742, 16), 53);
1934-assertEquals(WEEKNUM(23743, 16), 1);
1935-assertEquals(WEEKNUM(23744, 16), 2);
1936-assertEquals(WEEKNUM(23745, 16), 2);
1937-assertEquals(WEEKNUM(23746, 16), 2);
1938-assertEquals(WEEKNUM(23747, 16), 2);
1939-assertEquals(WEEKNUM(23748, 16), 2);
1940-assertEquals(WEEKNUM(23749, 16), 2);
1941-assertEquals(WEEKNUM(23750, 16), 2);
1942-assertEquals(WEEKNUM(23751, 16), 3);
1943-assertEquals(WEEKNUM(23752, 16), 3);
1944-assertEquals(WEEKNUM(23753, 16), 3);
1945-assertEquals(WEEKNUM(23754, 16), 3);
1946-assertEquals(WEEKNUM(23755, 16), 3);
1947-assertEquals(WEEKNUM(23756, 16), 3);
1948-assertEquals(WEEKNUM(23757, 16), 3);
1949-assertEquals(WEEKNUM(23758, 16), 4);
1950-assertEquals(WEEKNUM(23759, 16), 4);
1951-assertEquals(WEEKNUM(23760, 16), 4);
1952-// //type=16 again
1953-assertEquals(WEEKNUM(355, 16), 51);
1954-assertEquals(WEEKNUM(356, 16), 51);
1955-assertEquals(WEEKNUM(357, 16), 52);
1956-assertEquals(WEEKNUM(358, 16), 52);
1957-assertEquals(WEEKNUM(359, 16), 52);
1958-assertEquals(WEEKNUM(360, 16), 52);
1959-assertEquals(WEEKNUM(361, 16), 52);
1960-assertEquals(WEEKNUM(362, 16), 52);
1961-assertEquals(WEEKNUM(363, 16), 52);
1962-assertEquals(WEEKNUM(364, 16), 53);
1963-assertEquals(WEEKNUM(365, 16), 53);
1964-assertEquals(WEEKNUM(366, 16), 53);
1965-assertEquals(WEEKNUM(367, 16), 1);
1966-assertEquals(WEEKNUM(368, 16), 1);
1967-assertEquals(WEEKNUM(369, 16), 1);
1968-assertEquals(WEEKNUM(370, 16), 1);
1969-assertEquals(WEEKNUM(371, 16), 2);
1970-assertEquals(WEEKNUM(372, 16), 2);
1971-assertEquals(WEEKNUM(373, 16), 2);
1972-assertEquals(WEEKNUM(374, 16), 2);
1973-assertEquals(WEEKNUM(375, 16), 2);
1974-assertEquals(WEEKNUM(376, 16), 2);
1975-assertEquals(WEEKNUM(377, 16), 2);
1976-assertEquals(WEEKNUM(378, 16), 3);
1977-assertEquals(WEEKNUM(379, 16), 3);
1978-assertEquals(WEEKNUM(380, 16), 3);
1979-assertEquals(WEEKNUM(381, 16), 3);
1980-//type=16 again
1981-assertEquals(WEEKNUM(730, 16), 53);
1982-assertEquals(WEEKNUM(731, 16), 53);
1983-assertEquals(WEEKNUM(732, 16), 1);
1984-assertEquals(WEEKNUM(733, 16), 1);
1985-assertEquals(WEEKNUM(734, 16), 1);
1986-assertEquals(WEEKNUM(735, 16), 2);
1987-assertEquals(WEEKNUM(736, 16), 2);
1988-assertEquals(WEEKNUM(737, 16), 2);
1989-assertEquals(WEEKNUM(738, 16), 2);
1990-assertEquals(WEEKNUM(739, 16), 2);
1991-assertEquals(WEEKNUM(740, 16), 2);
1992-assertEquals(WEEKNUM(741, 16), 2);
1993-assertEquals(WEEKNUM(742, 16), 3);
1994-assertEquals(WEEKNUM(743, 16), 3);
1995-assertEquals(WEEKNUM(744, 16), 3);
1996-assertEquals(WEEKNUM(745, 16), 3);
1997-assertEquals(WEEKNUM(746, 16), 3);
1998-//type=17
1999-assertEquals(WEEKNUM(23734, 17), 52);
2000-assertEquals(WEEKNUM(23735, 17), 52);
2001-assertEquals(WEEKNUM(23736, 17), 52);
2002-assertEquals(WEEKNUM(23737, 17), 52);
2003-assertEquals(WEEKNUM(23738, 17), 53);
2004-assertEquals(WEEKNUM(23739, 17), 53);
2005-assertEquals(WEEKNUM(23740, 17), 53);
2006-assertEquals(WEEKNUM(23741, 17), 53);
2007-assertEquals(WEEKNUM(23742, 17), 53);
2008-assertEquals(WEEKNUM(23743, 17), 1);
2009-assertEquals(WEEKNUM(23744, 17), 1);
2010-assertEquals(WEEKNUM(23745, 17), 2);
2011-assertEquals(WEEKNUM(23746, 17), 2);
2012-assertEquals(WEEKNUM(23747, 17), 2);
2013-assertEquals(WEEKNUM(23748, 17), 2);
2014-assertEquals(WEEKNUM(23749, 17), 2);
2015-assertEquals(WEEKNUM(23750, 17), 2);
2016-assertEquals(WEEKNUM(23751, 17), 2);
2017-assertEquals(WEEKNUM(23752, 17), 3);
2018-assertEquals(WEEKNUM(23753, 17), 3);
2019-assertEquals(WEEKNUM(23754, 17), 3);
2020-assertEquals(WEEKNUM(23755, 17), 3);
2021-assertEquals(WEEKNUM(23756, 17), 3);
2022-assertEquals(WEEKNUM(23757, 17), 3);
2023-assertEquals(WEEKNUM(23758, 17), 3);
2024-assertEquals(WEEKNUM(23759, 17), 4);
2025-assertEquals(WEEKNUM(23760, 17), 4);
2026-// //type=17 again
2027-assertEquals(WEEKNUM(355, 17), 51);
2028-assertEquals(WEEKNUM(356, 17), 51);
2029-assertEquals(WEEKNUM(357, 17), 51);
2030-assertEquals(WEEKNUM(358, 17), 52);
2031-assertEquals(WEEKNUM(359, 17), 52);
2032-assertEquals(WEEKNUM(360, 17), 52);
2033-assertEquals(WEEKNUM(361, 17), 52);
2034-assertEquals(WEEKNUM(362, 17), 52);
2035-assertEquals(WEEKNUM(363, 17), 52);
2036-assertEquals(WEEKNUM(364, 17), 52);
2037-assertEquals(WEEKNUM(365, 17), 53);
2038-assertEquals(WEEKNUM(366, 17), 53);
2039-assertEquals(WEEKNUM(367, 17), 1);
2040-assertEquals(WEEKNUM(368, 17), 1);
2041-assertEquals(WEEKNUM(369, 17), 1);
2042-assertEquals(WEEKNUM(370, 17), 1);
2043-assertEquals(WEEKNUM(371, 17), 1);
2044-assertEquals(WEEKNUM(372, 17), 2);
2045-assertEquals(WEEKNUM(373, 17), 2);
2046-assertEquals(WEEKNUM(374, 17), 2);
2047-assertEquals(WEEKNUM(375, 17), 2);
2048-assertEquals(WEEKNUM(376, 17), 2);
2049-assertEquals(WEEKNUM(377, 17), 2);
2050-assertEquals(WEEKNUM(378, 17), 2);
2051-assertEquals(WEEKNUM(379, 17), 3);
2052-assertEquals(WEEKNUM(380, 17), 3);
2053-assertEquals(WEEKNUM(381, 17), 3);
2054-//type=17 again
2055-assertEquals(WEEKNUM(730, 17), 53);
2056-assertEquals(WEEKNUM(731, 17), 53);
2057-assertEquals(WEEKNUM(732, 17), 1);
2058-assertEquals(WEEKNUM(733, 17), 1);
2059-assertEquals(WEEKNUM(734, 17), 1);
2060-assertEquals(WEEKNUM(735, 17), 1);
2061-assertEquals(WEEKNUM(736, 17), 2);
2062-assertEquals(WEEKNUM(737, 17), 2);
2063-assertEquals(WEEKNUM(738, 17), 2);
2064-assertEquals(WEEKNUM(739, 17), 2);
2065-assertEquals(WEEKNUM(740, 17), 2);
2066-assertEquals(WEEKNUM(741, 17), 2);
2067-assertEquals(WEEKNUM(742, 17), 2);
2068-assertEquals(WEEKNUM(743, 17), 3);
2069-assertEquals(WEEKNUM(744, 17), 3);
2070-assertEquals(WEEKNUM(745, 17), 3);
2071-assertEquals(WEEKNUM(746, 17), 3);
2072+test("WEEKDAY", function(){
2073+  assertEquals(WEEKDAY(DATE(1992, 6, 20)), 7);
2074+  assertEquals(WEEKDAY(DATE(1992, 6, 21)), 1);
2075+  assertEquals(WEEKDAY(DATE(1992, 6, 24)), 4);
2076+  assertEquals(WEEKDAY(DATE(1992, 6, 25)), 5);
2077+  assertEquals(WEEKDAY(1312211), 5);
2078+  assertEquals(WEEKDAY(1312212), 6);
2079+  assertEquals(WEEKDAY(1312213), 7);
2080+  assertEquals(WEEKDAY(0), 7);
2081+  assertEquals(WEEKDAY(false), 7);
2082+  assertEquals(WEEKDAY(1), 1);
2083+  assertEquals(WEEKDAY(true), 1);
2084+  assertEquals(WEEKDAY(40909, 1), 1);
2085+  assertEquals(WEEKDAY(40909, 2), 7);
2086+  assertEquals(WEEKDAY(40909, 3), 6);
2087+  assertEquals(WEEKDAY(411, 1), 5);
2088+  assertEquals(WEEKDAY(411, 2), 4);
2089+  assertEquals(WEEKDAY(411, 3), 3);
2090+  assertEquals(WEEKDAY(40909, 1), 1);
2091+  assertEquals(WEEKDAY(40910, 1), 2);
2092+  assertEquals(WEEKDAY(40911, 1), 3);
2093+  assertEquals(WEEKDAY(40912, 1), 4);
2094+  assertEquals(WEEKDAY(40913, 1), 5);
2095+  assertEquals(WEEKDAY(40914, 1), 6);
2096+  assertEquals(WEEKDAY(40915, 1), 7);
2097+  assertEquals(WEEKDAY(40916, 1), 1);
2098+  assertEquals(WEEKDAY(40909, 2), 7);
2099+  assertEquals(WEEKDAY(40910, 2), 1);
2100+  assertEquals(WEEKDAY(40911, 2), 2);
2101+  assertEquals(WEEKDAY(40912, 2), 3);
2102+  assertEquals(WEEKDAY(40913, 2), 4);
2103+  assertEquals(WEEKDAY(40914, 2), 5);
2104+  assertEquals(WEEKDAY(40915, 2), 6);
2105+  assertEquals(WEEKDAY(40916, 2), 7);
2106+  assertEquals(WEEKDAY(40909, 3), 6);
2107+  assertEquals(WEEKDAY(40910, 3), 0);
2108+  assertEquals(WEEKDAY(40911, 3), 1);
2109+  assertEquals(WEEKDAY(40912, 3), 2);
2110+  assertEquals(WEEKDAY(40913, 3), 3);
2111+  assertEquals(WEEKDAY(40914, 3), 4);
2112+  assertEquals(WEEKDAY(40915, 3), 5);
2113+  assertEquals(WEEKDAY(40916, 3), 6);
2114+  catchAndAssertEquals(function() {
2115+    WEEKDAY();
2116+  }, ERRORS.NA_ERROR);
2117+  catchAndAssertEquals(function() {
2118+    WEEKDAY(213123, 1, 1);
2119+  }, ERRORS.NA_ERROR);
2120+  catchAndAssertEquals(function() {
2121+    WEEKDAY("str");
2122+  }, ERRORS.VALUE_ERROR);
2123+  catchAndAssertEquals(function() {
2124+    WEEKDAY([]);
2125+  }, ERRORS.REF_ERROR);
2126+  catchAndAssertEquals(function() {
2127+    WEEKDAY(-10);
2128+  }, ERRORS.NUM_ERROR);
2129+  catchAndAssertEquals(function() {
2130+    WEEKDAY(10, 4);
2131+  }, ERRORS.NUM_ERROR);
2132+});
2133 
2134-//type=21
2135-assertEquals(WEEKNUM(23730, 21), 51);
2136-assertEquals(WEEKNUM(23731, 21), 51);
2137-assertEquals(WEEKNUM(23732, 21), 52);
2138-assertEquals(WEEKNUM(23733, 21), 52);
2139-assertEquals(WEEKNUM(23734, 21), 52);
2140-assertEquals(WEEKNUM(23735, 21), 52);
2141-assertEquals(WEEKNUM(23736, 21), 52);
2142-assertEquals(WEEKNUM(23737, 21), 52);
2143-assertEquals(WEEKNUM(23738, 21), 52);
2144-assertEquals(WEEKNUM(23739, 21), 53);
2145-assertEquals(WEEKNUM(23740, 21), 53);
2146-assertEquals(WEEKNUM(23741, 21), 53);
2147-assertEquals(WEEKNUM(23742, 21), 53);
2148-assertEquals(WEEKNUM(23743, 21), 53);
2149-assertEquals(WEEKNUM(23744, 21), 53);
2150-assertEquals(WEEKNUM(23745, 21), 53);
2151-assertEquals(WEEKNUM(23746, 21), 1);
2152-assertEquals(WEEKNUM(23747, 21), 1);
2153-assertEquals(WEEKNUM(23748, 21), 1);
2154-assertEquals(WEEKNUM(23749, 21), 1);
2155-assertEquals(WEEKNUM(23750, 21), 1);
2156-assertEquals(WEEKNUM(23751, 21), 1);
2157-assertEquals(WEEKNUM(23752, 21), 1);
2158-assertEquals(WEEKNUM(23753, 21), 2);
2159-assertEquals(WEEKNUM(23754, 21), 2);
2160-assertEquals(WEEKNUM(23755, 21), 2);
2161-assertEquals(WEEKNUM(23756, 21), 2);
2162-assertEquals(WEEKNUM(23757, 21), 2);
2163-assertEquals(WEEKNUM(23758, 21), 2);
2164-assertEquals(WEEKNUM(23759, 21), 2);
2165-assertEquals(WEEKNUM(23760, 21), 3);
2166-// //type=21 again
2167-assertEquals(WEEKNUM(355, 21), 51);
2168-assertEquals(WEEKNUM(356, 21), 51);
2169-assertEquals(WEEKNUM(357, 21), 51);
2170-assertEquals(WEEKNUM(358, 21), 51);
2171-assertEquals(WEEKNUM(359, 21), 52);
2172-assertEquals(WEEKNUM(360, 21), 52);
2173-assertEquals(WEEKNUM(361, 21), 52);
2174-assertEquals(WEEKNUM(362, 21), 52);
2175-assertEquals(WEEKNUM(363, 21), 52);
2176-assertEquals(WEEKNUM(364, 21), 52);
2177-assertEquals(WEEKNUM(365, 21), 52);
2178-assertEquals(WEEKNUM(366, 21), 1);
2179-assertEquals(WEEKNUM(367, 21), 1);
2180-assertEquals(WEEKNUM(368, 21), 1);
2181-assertEquals(WEEKNUM(369, 21), 1);
2182-assertEquals(WEEKNUM(370, 21), 1);
2183-assertEquals(WEEKNUM(371, 21), 1);
2184-assertEquals(WEEKNUM(372, 21), 1);
2185-assertEquals(WEEKNUM(373, 21), 2);
2186-assertEquals(WEEKNUM(374, 21), 2);
2187-assertEquals(WEEKNUM(375, 21), 2);
2188-assertEquals(WEEKNUM(376, 21), 2);
2189-assertEquals(WEEKNUM(377, 21), 2);
2190-assertEquals(WEEKNUM(378, 21), 2);
2191-assertEquals(WEEKNUM(379, 21), 2);
2192-assertEquals(WEEKNUM(380, 21), 3);
2193-assertEquals(WEEKNUM(381, 21), 3);
2194-// //type=21 again
2195-assertEquals(WEEKNUM(728, 21), 52);
2196-assertEquals(WEEKNUM(729, 21), 52);
2197-assertEquals(WEEKNUM(730, 21), 1);
2198-assertEquals(WEEKNUM(731, 21), 1);
2199-assertEquals(WEEKNUM(732, 21), 1);
2200-assertEquals(WEEKNUM(733, 21), 1);
2201-assertEquals(WEEKNUM(734, 21), 1);
2202-assertEquals(WEEKNUM(735, 21), 1);
2203-assertEquals(WEEKNUM(736, 21), 1);
2204-assertEquals(WEEKNUM(737, 21), 2);
2205-assertEquals(WEEKNUM(738, 21), 2);
2206-assertEquals(WEEKNUM(739, 21), 2);
2207-assertEquals(WEEKNUM(740, 21), 2);
2208-assertEquals(WEEKNUM(741, 21), 2);
2209-assertEquals(WEEKNUM(742, 21), 2);
2210-assertEquals(WEEKNUM(743, 21), 2);
2211-assertEquals(WEEKNUM(744, 21), 3);
2212-assertEquals(WEEKNUM(745, 21), 3);
2213-assertEquals(WEEKNUM(746, 21), 3);
2214-catchAndAssertEquals(function() {
2215-  WEEKNUM();
2216-}, ERRORS.NA_ERROR);
2217-catchAndAssertEquals(function() {
2218-  WEEKNUM(213123, 1, 1);
2219-}, ERRORS.NA_ERROR);
2220-catchAndAssertEquals(function() {
2221-  WEEKNUM("str");
2222-}, ERRORS.VALUE_ERROR);
2223-catchAndAssertEquals(function() {
2224-  WEEKNUM([]);
2225-}, ERRORS.REF_ERROR);
2226-catchAndAssertEquals(function() {
2227-  WEEKNUM(-10);
2228-}, ERRORS.NUM_ERROR);
2229-catchAndAssertEquals(function() {
2230-  WEEKNUM(10, 4);
2231-}, ERRORS.NUM_ERROR);
2232-catchAndAssertEquals(function() {
2233-  WEEKNUM(10, 22);
2234-}, ERRORS.NUM_ERROR);
2235 
2236+test("YEAR", function(){
2237+  assertEquals(YEAR(DATE(1992, 6, 24)), 1992);
2238+  assertEquals(YEAR(DATE(2000, 6, 24)), 2000);
2239+  assertEquals(YEAR(DATE(100, 6, 24)), 2000);
2240+  assertEquals(YEAR(DATE(44, 6, 24)), 1944);
2241+  assertEquals(YEAR(1312212), 5492);
2242+  assertEquals(YEAR(9), 1900);
2243+  assertEquals(YEAR(0), 1899);
2244+  assertEquals(YEAR(false), 1899);
2245+  assertEquals(YEAR(1), 1899);
2246+  assertEquals(YEAR(true), 1899);
2247+  assertEquals(YEAR([1, "str"]), 1899);
2248+  catchAndAssertEquals(function() {
2249+    YEAR();
2250+  }, ERRORS.NA_ERROR);
2251+  catchAndAssertEquals(function() {
2252+    YEAR(213123, 123123);
2253+  }, ERRORS.NA_ERROR);
2254+  catchAndAssertEquals(function() {
2255+    YEAR("str");
2256+  }, ERRORS.VALUE_ERROR);
2257+  catchAndAssertEquals(function() {
2258+    YEAR([]);
2259+  }, ERRORS.REF_ERROR);
2260+  catchAndAssertEquals(function() {
2261+    YEAR(-10);
2262+  }, ERRORS.NUM_ERROR);
2263+});
2264 
2265-// Test WEEKDAY
2266-assertEquals(WEEKDAY(DATE(1992, 6, 20)), 7);
2267-assertEquals(WEEKDAY(DATE(1992, 6, 21)), 1);
2268-assertEquals(WEEKDAY(DATE(1992, 6, 24)), 4);
2269-assertEquals(WEEKDAY(DATE(1992, 6, 25)), 5);
2270-assertEquals(WEEKDAY(1312211), 5);
2271-assertEquals(WEEKDAY(1312212), 6);
2272-assertEquals(WEEKDAY(1312213), 7);
2273-assertEquals(WEEKDAY(0), 7);
2274-assertEquals(WEEKDAY(false), 7);
2275-assertEquals(WEEKDAY(1), 1);
2276-assertEquals(WEEKDAY(true), 1);
2277-assertEquals(WEEKDAY(40909, 1), 1);
2278-assertEquals(WEEKDAY(40909, 2), 7);
2279-assertEquals(WEEKDAY(40909, 3), 6);
2280-assertEquals(WEEKDAY(411, 1), 5);
2281-assertEquals(WEEKDAY(411, 2), 4);
2282-assertEquals(WEEKDAY(411, 3), 3);
2283-assertEquals(WEEKDAY(40909, 1), 1);
2284-assertEquals(WEEKDAY(40910, 1), 2);
2285-assertEquals(WEEKDAY(40911, 1), 3);
2286-assertEquals(WEEKDAY(40912, 1), 4);
2287-assertEquals(WEEKDAY(40913, 1), 5);
2288-assertEquals(WEEKDAY(40914, 1), 6);
2289-assertEquals(WEEKDAY(40915, 1), 7);
2290-assertEquals(WEEKDAY(40916, 1), 1);
2291-assertEquals(WEEKDAY(40909, 2), 7);
2292-assertEquals(WEEKDAY(40910, 2), 1);
2293-assertEquals(WEEKDAY(40911, 2), 2);
2294-assertEquals(WEEKDAY(40912, 2), 3);
2295-assertEquals(WEEKDAY(40913, 2), 4);
2296-assertEquals(WEEKDAY(40914, 2), 5);
2297-assertEquals(WEEKDAY(40915, 2), 6);
2298-assertEquals(WEEKDAY(40916, 2), 7);
2299-assertEquals(WEEKDAY(40909, 3), 6);
2300-assertEquals(WEEKDAY(40910, 3), 0);
2301-assertEquals(WEEKDAY(40911, 3), 1);
2302-assertEquals(WEEKDAY(40912, 3), 2);
2303-assertEquals(WEEKDAY(40913, 3), 3);
2304-assertEquals(WEEKDAY(40914, 3), 4);
2305-assertEquals(WEEKDAY(40915, 3), 5);
2306-assertEquals(WEEKDAY(40916, 3), 6);
2307-catchAndAssertEquals(function() {
2308-  WEEKDAY();
2309-}, ERRORS.NA_ERROR);
2310-catchAndAssertEquals(function() {
2311-  WEEKDAY(213123, 1, 1);
2312-}, ERRORS.NA_ERROR);
2313-catchAndAssertEquals(function() {
2314-  WEEKDAY("str");
2315-}, ERRORS.VALUE_ERROR);
2316-catchAndAssertEquals(function() {
2317-  WEEKDAY([]);
2318-}, ERRORS.REF_ERROR);
2319-catchAndAssertEquals(function() {
2320-  WEEKDAY(-10);
2321-}, ERRORS.NUM_ERROR);
2322-catchAndAssertEquals(function() {
2323-  WEEKDAY(10, 4);
2324-}, ERRORS.NUM_ERROR);
2325 
2326+test("MONTH", function(){
2327+  assertEquals(MONTH(DATE(1992, 6, 24)), 6);
2328+  assertEquals(MONTH(1312212), 9);
2329+  assertEquals(MONTH(13122121), 2);
2330+  catchAndAssertEquals(function() {
2331+    MONTH();
2332+  }, ERRORS.NA_ERROR);
2333+  catchAndAssertEquals(function() {
2334+    MONTH(213123, 123123);
2335+  }, ERRORS.NA_ERROR);
2336+  catchAndAssertEquals(function() {
2337+    MONTH("str");
2338+  }, ERRORS.VALUE_ERROR);
2339+  catchAndAssertEquals(function() {
2340+    MONTH([]);
2341+  }, ERRORS.REF_ERROR);
2342+  catchAndAssertEquals(function() {
2343+    MONTH(-10);
2344+  }, ERRORS.NUM_ERROR);
2345+});
2346 
2347-// Test YEAR
2348-assertEquals(YEAR(DATE(1992, 6, 24)), 1992);
2349-assertEquals(YEAR(DATE(2000, 6, 24)), 2000);
2350-assertEquals(YEAR(DATE(100, 6, 24)), 2000);
2351-assertEquals(YEAR(DATE(44, 6, 24)), 1944);
2352-assertEquals(YEAR(1312212), 5492);
2353-assertEquals(YEAR(9), 1900);
2354-assertEquals(YEAR(0), 1899);
2355-assertEquals(YEAR(false), 1899);
2356-assertEquals(YEAR(1), 1899);
2357-assertEquals(YEAR(true), 1899);
2358-assertEquals(YEAR([1, "str"]), 1899);
2359-catchAndAssertEquals(function() {
2360-  YEAR();
2361-}, ERRORS.NA_ERROR);
2362-catchAndAssertEquals(function() {
2363-  YEAR(213123, 123123);
2364-}, ERRORS.NA_ERROR);
2365-catchAndAssertEquals(function() {
2366-  YEAR("str");
2367-}, ERRORS.VALUE_ERROR);
2368-catchAndAssertEquals(function() {
2369-  YEAR([]);
2370-}, ERRORS.REF_ERROR);
2371-catchAndAssertEquals(function() {
2372-  YEAR(-10);
2373-}, ERRORS.NUM_ERROR);
2374 
2375+test("DAYS360", function(){
2376+  assertEquals(DAYS360(DATE(1992, 6, 24), DATE(1992, 6, 25)), 1);
2377+  assertEquals(DAYS360(DATE(1992, 6, 25), DATE(1992, 6, 24)), -1);
2378+  assertEquals(DAYS360(DATE(1992, 6, 25), DATE(1992, 6, 23)), -2);
2379+  assertEquals(DAYS360(DATE(1992, 6, 24), DATE(1991, 6, 24)), -360);
2380+  assertEquals(DAYS360(DATE(1993, 6, 24), DATE(1992, 6, 24)), -360);
2381+  assertEquals(DAYS360(DATEVALUE("1993-6-24"), 1), -33653);
2382+  assertEquals(DAYS360(DATEVALUE("1993-6-24"), true), -33653);
2383+  assertEquals(DAYS360(DATEVALUE("1993-6-24"), 0), -33654);
2384+  assertEquals(DAYS360(DATEVALUE("1993-6-24"), false), -33654);
2385+  assertEquals(DAYS360("2191-6-24", "1992-6-24"), -71640);
2386+  assertEquals(DAYS360("2191-6-24", "1992-6-24", true), -71640);
2387+  assertEquals(DAYS360(1, 390, 1), 384);
2388+  assertEquals(DAYS360(1, 390), 384);
2389+  assertEquals(DAYS360(33779, 33780), 1);
2390+  assertEquals(DAYS360([1, "str"], [390, "str"]), 384);
2391+  catchAndAssertEquals(function() {
2392+    DAYS360();
2393+  }, ERRORS.NA_ERROR);
2394+  catchAndAssertEquals(function() {
2395+    DAYS360(100);
2396+  }, ERRORS.NA_ERROR);
2397+  catchAndAssertEquals(function() {
2398+    DAYS360(100, 200, true, "str");
2399+  }, ERRORS.NA_ERROR);
2400+  catchAndAssertEquals(function() {
2401+    DAYS360("str", 100);
2402+  }, ERRORS.VALUE_ERROR);
2403+  catchAndAssertEquals(function() {
2404+    DAYS360("false", "true");
2405+  }, ERRORS.VALUE_ERROR);
2406+  catchAndAssertEquals(function() {
2407+    DAYS360([[], 100], 22);
2408+  }, ERRORS.REF_ERROR);
2409+});
2410 
2411-// Test MONTH
2412-assertEquals(MONTH(DATE(1992, 6, 24)), 6);
2413-assertEquals(MONTH(1312212), 9);
2414-assertEquals(MONTH(13122121), 2);
2415-catchAndAssertEquals(function() {
2416-  MONTH();
2417-}, ERRORS.NA_ERROR);
2418-catchAndAssertEquals(function() {
2419-  MONTH(213123, 123123);
2420-}, ERRORS.NA_ERROR);
2421-catchAndAssertEquals(function() {
2422-  MONTH("str");
2423-}, ERRORS.VALUE_ERROR);
2424-catchAndAssertEquals(function() {
2425-  MONTH([]);
2426-}, ERRORS.REF_ERROR);
2427-catchAndAssertEquals(function() {
2428-  MONTH(-10);
2429-}, ERRORS.NUM_ERROR);
2430 
2431+test("DAYS", function(){
2432+  assertEquals(DAYS(DATE(1992, 6, 24), DATE(1992, 6, 25)), -1);
2433+  assertEquals(DAYS(DATE(1992, 6, 25), DATE(1992, 6, 24)), 1);
2434+  assertEquals(DAYS(DATE(1992, 6, 25), DATE(1992, 6, 23)), 2);
2435+  assertEquals(DAYS(DATE(1992, 6, 24), DATE(1991, 6, 24)), 366);
2436+  assertEquals(DAYS(DATE(1993, 6, 24), DATE(1992, 6, 24)), 365);
2437+  assertEquals(DAYS("2191-6-24", "1992-6-24"), 72683);
2438+  assertEquals(DAYS(0, 1), -1);
2439+  assertEquals(DAYS(false, true), -1);
2440+  assertEquals(DAYS(0, 100), -100);
2441+  assertEquals(DAYS(-100, 100), -200);
2442+  assertEquals(DAYS(100, -100), 200);
2443+  assertEquals(DAYS(100, 0), 100);
2444+  assertEquals(DAYS([0, "str"], [100, "str"]), -100);
2445+  assertEquals(DAYS("1992, 6, 25", "1992, 6, 24"), 1);
2446+  catchAndAssertEquals(function() {
2447+    DAYS();
2448+  }, ERRORS.NA_ERROR);
2449+  catchAndAssertEquals(function() {
2450+    DAYS(100);
2451+  }, ERRORS.NA_ERROR);
2452+  catchAndAssertEquals(function() {
2453+    DAYS(100, 200, 300);
2454+  }, ERRORS.NA_ERROR);
2455+  catchAndAssertEquals(function() {
2456+    DAYS([[], 100], 22);
2457+  }, ERRORS.REF_ERROR);
2458+  catchAndAssertEquals(function() {
2459+    DAYS("str", 100);
2460+  }, ERRORS.VALUE_ERROR);
2461+  catchAndAssertEquals(function() {
2462+    DAYS("false", "true");
2463+  }, ERRORS.VALUE_ERROR);
2464+});
2465 
2466-// Test DAYS360
2467-assertEquals(DAYS360(DATE(1992, 6, 24), DATE(1992, 6, 25)), 1);
2468-assertEquals(DAYS360(DATE(1992, 6, 25), DATE(1992, 6, 24)), -1);
2469-assertEquals(DAYS360(DATE(1992, 6, 25), DATE(1992, 6, 23)), -2);
2470-assertEquals(DAYS360(DATE(1992, 6, 24), DATE(1991, 6, 24)), -360);
2471-assertEquals(DAYS360(DATE(1993, 6, 24), DATE(1992, 6, 24)), -360);
2472-assertEquals(DAYS360(DATEVALUE("1993-6-24"), 1), -33653);
2473-assertEquals(DAYS360(DATEVALUE("1993-6-24"), true), -33653);
2474-assertEquals(DAYS360(DATEVALUE("1993-6-24"), 0), -33654);
2475-assertEquals(DAYS360(DATEVALUE("1993-6-24"), false), -33654);
2476-assertEquals(DAYS360("2191-6-24", "1992-6-24"), -71640);
2477-assertEquals(DAYS360("2191-6-24", "1992-6-24", true), -71640);
2478-assertEquals(DAYS360(1, 390, 1), 384);
2479-assertEquals(DAYS360(1, 390), 384);
2480-assertEquals(DAYS360(33779, 33780), 1);
2481-assertEquals(DAYS360([1, "str"], [390, "str"]), 384);
2482-catchAndAssertEquals(function() {
2483-  DAYS360();
2484-}, ERRORS.NA_ERROR);
2485-catchAndAssertEquals(function() {
2486-  DAYS360(100);
2487-}, ERRORS.NA_ERROR);
2488-catchAndAssertEquals(function() {
2489-  DAYS360(100, 200, true, "str");
2490-}, ERRORS.NA_ERROR);
2491-catchAndAssertEquals(function() {
2492-  DAYS360("str", 100);
2493-}, ERRORS.VALUE_ERROR);
2494-catchAndAssertEquals(function() {
2495-  DAYS360("false", "true");
2496-}, ERRORS.VALUE_ERROR);
2497-catchAndAssertEquals(function() {
2498-  DAYS360([[], 100], 22);
2499-}, ERRORS.REF_ERROR);
2500 
2501+test("DAY", function(){
2502+  assertEquals(DAY(DATE(1992, 6, 24)), 24);
2503+  assertEquals(DAY(DATE(1992, 5, 10)), 10);
2504+  assertEquals(DAY(DATE(1992, 5, 22)), 22);
2505+  assertEquals(DAY(DATE(1992, 6, 1)), 1);
2506+  assertEquals(DAY(DATE(2008, 1, 31)), 31);
2507+  assertEquals(DAY("1992, 6, 24"), 24);
2508+  assertEquals(DAY(["1992, 6, 24"]), 24);
2509+  assertEquals(DAY(0), 30);
2510+  assertEquals(DAY(false), 30);
2511+  assertEquals(DAY(1), 31);
2512+  assertEquals(DAY(true), 31);
2513+  assertEquals(DAY(33779), 24);
2514+  assertEquals(DAY([33779]), 24);
2515+  assertEquals(DAY([33779, "str"]), 24);
2516+  catchAndAssertEquals(function() {
2517+    DAY("str");
2518+  }, ERRORS.VALUE_ERROR);
2519+  catchAndAssertEquals(function() {
2520+    DAY();
2521+  }, ERRORS.NA_ERROR);
2522+  catchAndAssertEquals(function() {
2523+    DAY(DATE(1992, 6, 24), 4);
2524+  }, ERRORS.NA_ERROR);
2525+  catchAndAssertEquals(function() {
2526+    DAY(-1);
2527+  }, ERRORS.NUM_ERROR);
2528+});
2529 
2530-// Test DAYS
2531-assertEquals(DAYS(DATE(1992, 6, 24), DATE(1992, 6, 25)), -1);
2532-assertEquals(DAYS(DATE(1992, 6, 25), DATE(1992, 6, 24)), 1);
2533-assertEquals(DAYS(DATE(1992, 6, 25), DATE(1992, 6, 23)), 2);
2534-assertEquals(DAYS(DATE(1992, 6, 24), DATE(1991, 6, 24)), 366);
2535-assertEquals(DAYS(DATE(1993, 6, 24), DATE(1992, 6, 24)), 365);
2536-assertEquals(DAYS("2191-6-24", "1992-6-24"), 72683);
2537-assertEquals(DAYS(0, 1), -1);
2538-assertEquals(DAYS(false, true), -1);
2539-assertEquals(DAYS(0, 100), -100);
2540-assertEquals(DAYS(-100, 100), -200);
2541-assertEquals(DAYS(100, -100), 200);
2542-assertEquals(DAYS(100, 0), 100);
2543-assertEquals(DAYS([0, "str"], [100, "str"]), -100);
2544-assertEquals(DAYS("1992, 6, 25", "1992, 6, 24"), 1);
2545-catchAndAssertEquals(function() {
2546-  DAYS();
2547-}, ERRORS.NA_ERROR);
2548-catchAndAssertEquals(function() {
2549-  DAYS(100);
2550-}, ERRORS.NA_ERROR);
2551-catchAndAssertEquals(function() {
2552-  DAYS(100, 200, 300);
2553-}, ERRORS.NA_ERROR);
2554-catchAndAssertEquals(function() {
2555-  DAYS([[], 100], 22);
2556-}, ERRORS.REF_ERROR);
2557-catchAndAssertEquals(function() {
2558-  DAYS("str", 100);
2559-}, ERRORS.VALUE_ERROR);
2560-catchAndAssertEquals(function() {
2561-  DAYS("false", "true");
2562-}, ERRORS.VALUE_ERROR);
2563 
2564+test("EDATE", function(){
2565+  assertEquals(EDATE(DATE(1992, 6, 24), 1), DATE(1992, 7, 24));
2566+  assertEquals(EDATE(DATE(1992, 5, 24), 2), DATE(1992, 7, 24));
2567+  assertEquals(EDATE(DATE(1992, 5, 24), 2.2), DATE(1992, 7, 24));
2568+  assertEquals(EDATE(DATE(1992, 6, 24), 0), DATE(1992, 6, 24));
2569+  assertEquals(EDATE(DATE(1992, 6, 24), false), DATE(1992, 6, 24));
2570+  assertEquals(EDATE("1992, 5, 24", 2), DATE(1992, 7, 24));
2571+  assertEquals(EDATE("6/24/92", 1), DATE(1992, 7, 24));
2572+  assertEquals(EDATE([DATE(1992, 6, 24), "str"], [1, "str"]), DATE(1992, 7, 24));
2573+  assertEquals(EDATE(0, 1), DATE(1900, 1, 30));
2574+  assertEquals(EDATE(false, 1), DATE(1900, 1, 30));
2575+  catchAndAssertEquals(function() {
2576+    EDATE("str", 2);
2577+  }, ERRORS.VALUE_ERROR);
2578+  catchAndAssertEquals(function() {
2579+    EDATE(DATE(1992, 6, 24));
2580+  }, ERRORS.NA_ERROR);
2581+  catchAndAssertEquals(function() {
2582+    EDATE(DATE(1992, 6, 24), 4, 4);
2583+  }, ERRORS.NA_ERROR);
2584+  catchAndAssertEquals(function() {
2585+    EDATE(-1, 1);
2586+  }, ERRORS.NUM_ERROR);
2587+  catchAndAssertEquals(function() {
2588+    EDATE(DATEVALUE("01/13/0101"), 1);
2589+  }, ERRORS.NUM_ERROR);
2590+});
2591 
2592-// Test DAY
2593-assertEquals(DAY(DATE(1992, 6, 24)), 24);
2594-assertEquals(DAY(DATE(1992, 5, 10)), 10);
2595-assertEquals(DAY(DATE(1992, 5, 22)), 22);
2596-assertEquals(DAY(DATE(1992, 6, 1)), 1);
2597-assertEquals(DAY(DATE(2008, 1, 31)), 31);
2598-assertEquals(DAY("1992, 6, 24"), 24);
2599-assertEquals(DAY(["1992, 6, 24"]), 24);
2600-assertEquals(DAY(0), 30);
2601-assertEquals(DAY(false), 30);
2602-assertEquals(DAY(1), 31);
2603-assertEquals(DAY(true), 31);
2604-assertEquals(DAY(33779), 24);
2605-assertEquals(DAY([33779]), 24);
2606-assertEquals(DAY([33779, "str"]), 24);
2607-catchAndAssertEquals(function() {
2608-  DAY("str");
2609-}, ERRORS.VALUE_ERROR);
2610-catchAndAssertEquals(function() {
2611-  DAY();
2612-}, ERRORS.NA_ERROR);
2613-catchAndAssertEquals(function() {
2614-  DAY(DATE(1992, 6, 24), 4);
2615-}, ERRORS.NA_ERROR);
2616-catchAndAssertEquals(function() {
2617-  DAY(-1);
2618-}, ERRORS.NUM_ERROR);
2619 
2620+test("EOMONTH", function(){
2621+  assertEquals(EOMONTH(DATE(1992, 6, 24), 0), DATE(1992, 6, 30));
2622+  assertEquals(EOMONTH(DATE(1992, 6, 24), false), DATE(1992, 6, 30));
2623+  assertEquals(EOMONTH(DATE(1992, 6, 24), 1), DATE(1992, 7, 31));
2624+  assertEquals(EOMONTH(DATE(1992, 6, 24), 2), DATE(1992, 8, 31));
2625+  assertEquals(EOMONTH(DATE(2012, 6, 24), 2), DATE(2012, 8, 31));
2626+  assertEquals(EOMONTH(DATE(2049, 1, 1), 2), DATE(2049, 3, 31));
2627+  assertEquals(EOMONTH(DATE(1990, 2, 24), 400), DATE(2023, 6, 30));
2628+  assertEquals(EOMONTH("1992, 6, 24", 2), DATE(1992, 8, 31));
2629+  //leap years
2630+  assertEquals(EOMONTH(DATE(2004, 2, 24), 0), DATE(2004, 2, 29));
2631+  assertEquals(EOMONTH(DATE(2008, 2, 24), 0), DATE(2008, 2, 29));
2632+  // misc.
2633+  assertEquals(EOMONTH([DATE(1992, 6, 24), "str"], [2, "str"]), DATE(1992, 8, 31));
2634+  assertEquals(EOMONTH(0, 1), DATE(1900, 1, 31));
2635+  assertEquals(EOMONTH(false, 1), DATE(1900, 1, 31));
2636+  assertEquals(EOMONTH(1, 1), DATE(1900, 1, 31));
2637+  assertEquals(EOMONTH(true, 1), DATE(1900, 1, 31));
2638+  catchAndAssertEquals(function() {
2639+    EOMONTH("str", 2);
2640+  }, ERRORS.VALUE_ERROR);
2641+  catchAndAssertEquals(function() {
2642+    EOMONTH(-1, 2);
2643+  }, ERRORS.NUM_ERROR);
2644+});
2645 
2646-// Test EDATE
2647-assertEquals(EDATE(DATE(1992, 6, 24), 1), DATE(1992, 7, 24));
2648-assertEquals(EDATE(DATE(1992, 5, 24), 2), DATE(1992, 7, 24));
2649-assertEquals(EDATE(DATE(1992, 5, 24), 2.2), DATE(1992, 7, 24));
2650-assertEquals(EDATE(DATE(1992, 6, 24), 0), DATE(1992, 6, 24));
2651-assertEquals(EDATE(DATE(1992, 6, 24), false), DATE(1992, 6, 24));
2652-assertEquals(EDATE("1992, 5, 24", 2), DATE(1992, 7, 24));
2653-assertEquals(EDATE("6/24/92", 1), DATE(1992, 7, 24));
2654-assertEquals(EDATE([DATE(1992, 6, 24), "str"], [1, "str"]), DATE(1992, 7, 24));
2655-assertEquals(EDATE(0, 1), DATE(1900, 1, 30));
2656-assertEquals(EDATE(false, 1), DATE(1900, 1, 30));
2657-catchAndAssertEquals(function() {
2658-  EDATE("str", 2);
2659-}, ERRORS.VALUE_ERROR);
2660-catchAndAssertEquals(function() {
2661-  EDATE(DATE(1992, 6, 24));
2662-}, ERRORS.NA_ERROR);
2663-catchAndAssertEquals(function() {
2664-  EDATE(DATE(1992, 6, 24), 4, 4);
2665-}, ERRORS.NA_ERROR);
2666-catchAndAssertEquals(function() {
2667-  EDATE(-1, 1);
2668-}, ERRORS.NUM_ERROR);
2669-catchAndAssertEquals(function() {
2670-  EDATE(DATEVALUE("01/13/0101"), 1);
2671-}, ERRORS.NUM_ERROR);
2672 
2673+test("DATE", function(){
2674+  assertEquals(DATE(1900, 1, 2).toNumber(), 3);
2675+  assertEquals(DATE(1900, 1, 1).toNumber(), 2);
2676+  assertEquals(DATE(1900, 1, 4).toNumber(), 5);
2677+  catchAndAssertEquals(function() {
2678+    DATE(1900, 0, 5);
2679+  }, ERRORS.NUM_ERROR);
2680+  catchAndAssertEquals(function() {
2681+    DATE(1900, 0, 5, 22);
2682+  }, ERRORS.NA_ERROR);
2683+  catchAndAssertEquals(function() {
2684+    DATE(1900, 0);
2685+  }, ERRORS.NA_ERROR);
2686+  assertEquals(DATE(1992, 6, 24).toNumber(), 33779);
2687+  assertEquals(DATE(2017, 2, 26).toNumber(), 42792);
2688+  assertEquals(DATE(1999, 1, 13).toNumber(), 36173);
2689+  // Leap day stuff
2690+  assertEquals(DATE(2004, 2, 28).toNumber(), 38045);
2691+  assertEquals(DATE(2004, 2, 29).toNumber(), 38046);
2692+  assertEquals(DATE(2004, 3, 1).toNumber(), 38047);
2693+  // Overflow values
2694+  assertEquals(DATE(1992, 6, 44).toNumber(), 33799);
2695+  assertEquals(DATE(2, 33, 44).toNumber(), 1749);
2696+  assertEquals(DATE(1777, 33, 44).toNumber(), 650055);
2697+  assertEquals(DATE(1976, 2, -10).toNumber(), 27780);
2698+  assertEquals(DATE(-1900, 1, 1).toNumber(), 2);
2699+  assertEquals(DATE(1992, 1, 10).toNumber(), 33613);
2700+});
2701 
2702-// Test EOMONTH
2703-assertEquals(EOMONTH(DATE(1992, 6, 24), 0), DATE(1992, 6, 30));
2704-assertEquals(EOMONTH(DATE(1992, 6, 24), false), DATE(1992, 6, 30));
2705-assertEquals(EOMONTH(DATE(1992, 6, 24), 1), DATE(1992, 7, 31));
2706-assertEquals(EOMONTH(DATE(1992, 6, 24), 2), DATE(1992, 8, 31));
2707-assertEquals(EOMONTH(DATE(2012, 6, 24), 2), DATE(2012, 8, 31));
2708-assertEquals(EOMONTH(DATE(2049, 1, 1), 2), DATE(2049, 3, 31));
2709-assertEquals(EOMONTH(DATE(1990, 2, 24), 400), DATE(2023, 6, 30));
2710-assertEquals(EOMONTH("1992, 6, 24", 2), DATE(1992, 8, 31));
2711-//leap years
2712-assertEquals(EOMONTH(DATE(2004, 2, 24), 0), DATE(2004, 2, 29));
2713-assertEquals(EOMONTH(DATE(2008, 2, 24), 0), DATE(2008, 2, 29));
2714-// misc.
2715-assertEquals(EOMONTH([DATE(1992, 6, 24), "str"], [2, "str"]), DATE(1992, 8, 31));
2716-assertEquals(EOMONTH(0, 1), DATE(1900, 1, 31));
2717-assertEquals(EOMONTH(false, 1), DATE(1900, 1, 31));
2718-assertEquals(EOMONTH(1, 1), DATE(1900, 1, 31));
2719-assertEquals(EOMONTH(true, 1), DATE(1900, 1, 31));
2720-catchAndAssertEquals(function() {
2721-  EOMONTH("str", 2);
2722-}, ERRORS.VALUE_ERROR);
2723-catchAndAssertEquals(function() {
2724-  EOMONTH(-1, 2);
2725-}, ERRORS.NUM_ERROR);
2726 
2727-
2728-// Test DATE
2729-assertEquals(DATE(1900, 1, 2).toNumber(), 3);
2730-assertEquals(DATE(1900, 1, 1).toNumber(), 2);
2731-assertEquals(DATE(1900, 1, 4).toNumber(), 5);
2732-catchAndAssertEquals(function() {
2733-  DATE(1900, 0, 5);
2734-}, ERRORS.NUM_ERROR);
2735-catchAndAssertEquals(function() {
2736-  DATE(1900, 0, 5, 22);
2737-}, ERRORS.NA_ERROR);
2738-catchAndAssertEquals(function() {
2739-  DATE(1900, 0);
2740-}, ERRORS.NA_ERROR);
2741-assertEquals(DATE(1992, 6, 24).toNumber(), 33779);
2742-assertEquals(DATE(2017, 2, 26).toNumber(), 42792);
2743-assertEquals(DATE(1999, 1, 13).toNumber(), 36173);
2744-// Leap day stuff
2745-assertEquals(DATE(2004, 2, 28).toNumber(), 38045);
2746-assertEquals(DATE(2004, 2, 29).toNumber(), 38046);
2747-assertEquals(DATE(2004, 3, 1).toNumber(), 38047);
2748-// Overflow values
2749-assertEquals(DATE(1992, 6, 44).toNumber(), 33799);
2750-assertEquals(DATE(2, 33, 44).toNumber(), 1749);
2751-assertEquals(DATE(1777, 33, 44).toNumber(), 650055);
2752-assertEquals(DATE(1976, 2, -10).toNumber(), 27780);
2753-assertEquals(DATE(-1900, 1, 1).toNumber(), 2);
2754-assertEquals(DATE(1992, 1, 10).toNumber(), 33613);
2755-
2756-
2757-
2758-// Test DATEVALUE
2759-assertEquals(DATEVALUE("6/24/92"), 33779);
2760-assertEquals(DATEVALUE(["6/24/92", false]), 33779);
2761-catchAndAssertEquals(function() {
2762-  DATEVALUE("6/24/92", 10);
2763-}, ERRORS.NA_ERROR);
2764-catchAndAssertEquals(function() {
2765-  DATEVALUE();
2766-}, ERRORS.NA_ERROR);
2767-catchAndAssertEquals(function() {
2768-  DATEVALUE(false);
2769-}, ERRORS.VALUE_ERROR);
2770-// MONTHDIG_DAY_YEAR, MM(fd)DD(fd)YYYY =================================================================================
2771-assertEquals(DATEVALUE("6/24/92"), 33779);
2772-assertEquals(DATEVALUE("6/24/1992"), 33779);
2773-assertEquals(DATEVALUE("06/24/1992"), 33779);
2774-assertEquals(DATEVALUE("1/01/1999"), 36161);
2775-assertEquals(DATEVALUE("1/01/99"), 36161);
2776-assertEquals(DATEVALUE("1/01/2222"), 117610);
2777-assertEquals(DATEVALUE("9/02/1902"), 976);
2778-assertEquals(DATEVALUE("9/2/1902"), 976);
2779-assertEquals(DATEVALUE("11/3/4243"), 856071);
2780-assertEquals(DATEVALUE("  04/19/1992  "), 33713);
2781-assertEquals(DATEVALUE("5/20/1992"), 33744);
2782-assertEquals(DATEVALUE("6/21/1992"), 33776);
2783-assertEquals(DATEVALUE("9/29/1992"), 33876);
2784-assertEquals(DATEVALUE("1/24/1992"), 33627);
2785-assertEquals(DATEVALUE("12/21/1992"), 33959);
2786-assertEquals(DATEVALUE("01/31/1992"), 33634);
2787-assertEquals(DATEVALUE("1/13/1992"), 33616);
2788-assertEquals(DATEVALUE("2/29/2004"), 38046);
2789-assertEquals(DATEVALUE("2/28/2004"), 38045);
2790-assertEquals(DATEVALUE("2/28/004"), 38045);
2791-assertEquals(DATEVALUE("2/28/04"), 38045);
2792-assertEquals(DATEVALUE("2/28/4"), 38045);
2793-assertEquals(DATEVALUE("1/13/1999"), 36173);
2794-assertEquals(DATEVALUE("01/13/1999"), 36173);
2795-assertEquals(DATEVALUE("01/13/0999"), -329069);
2796-assertEquals(DATEVALUE("01/13/1200"), -255656);
2797-assertEquals(DATEVALUE("01/13/0029"), 47131);
2798-assertEquals(DATEVALUE("01/13/0030"), 10971);
2799-assertEquals(DATEVALUE("01/13/0044"), 16084);
2800-assertEquals(DATEVALUE("01/13/0050"), 18276);
2801-assertEquals(DATEVALUE("01/13/0097"), 35443);
2802-assertEquals(DATEVALUE("01/13/0099"), 36173);
2803-assertEquals(DATEVALUE("01/13/0000"), 36538);
2804-assertEquals(DATEVALUE("01/13/0101"), -657057);
2805-assertEquals(DATEVALUE("01/13/0100"), -657422);
2806-assertEquals(DATEVALUE("12/31/100"), -657070);
2807-assertEquals(DATEVALUE("11/10/122"), -649086);
2808-assertEquals(DATEVALUE("1/22/2222"), 117631);
2809-assertEquals(DATEVALUE("1/22/222"), -612854);
2810-// delimiter tests
2811-assertEquals(DATEVALUE("6-24-92"), 33779);
2812-assertEquals(DATEVALUE("6/24/92"), 33779);
2813-assertEquals(DATEVALUE("6 24 92"), 33779);
2814-assertEquals(DATEVALUE("6.24.92"), 33779);
2815-assertEquals(DATEVALUE("6 . 24 . 92"), 33779);
2816-assertEquals(DATEVALUE("6 / 24 / 92"), 33779);
2817-assertEquals(DATEVALUE("6, 24, 92"), 33779);
2818-// flex delimiter should not allow a comma without a space after it.
2819-catchAndAssertEquals(function() {
2820-  DATEVALUE("Sunday,6/24/92");
2821-}, ERRORS.VALUE_ERROR);
2822-// Leap day on non-leap years
2823-catchAndAssertEquals(function() {
2824-  DATEVALUE("2/29/2005");
2825-}, ERRORS.VALUE_ERROR);
2826-catchAndAssertEquals(function() {
2827-  DATEVALUE("2/29/2001");
2828-}, ERRORS.VALUE_ERROR);
2829-// Out of range day for any month
2830-catchAndAssertEquals(function() {
2831-  DATEVALUE("1/44/2005");
2832-}, ERRORS.VALUE_ERROR);
2833-// timestamp test
2834-assertEquals(DATEVALUE("6-24-92 10am"), 33779);
2835-assertEquals(DATEVALUE("6-24-92 10:10"), 33779);
2836-assertEquals(DATEVALUE("6-24-92 10:10am"), 33779);
2837-assertEquals(DATEVALUE("6-24-92 10:10:10"), 33779);
2838-assertEquals(DATEVALUE("6-24-92 10:10:10am"), 33779);
2839-assertEquals(DATEVALUE("6-24-92  10  am"), 33779);
2840-assertEquals(DATEVALUE("6-24-92 10: 10 "), 33779);
2841-assertEquals(DATEVALUE("6-24-92 10: 10 pm"), 33779);
2842-assertEquals(DATEVALUE("6-24-92 10: 10: 10"), 33779);
2843-assertEquals(DATEVALUE("6-24-92  10: 10: 10    am  "), 33779);
2844-assertEquals(DATEVALUE("1992/6/24 00:00"), 33779);
2845-assertEquals(DATEVALUE("1992/6/24 0:00"), 33779);
2846-assertEquals(DATEVALUE("1992/6/24 10:10"), 33779);
2847-assertEquals(DATEVALUE("1992/6/24 16:22"), 33779);
2848-assertEquals(DATEVALUE("1992/6/24 25:10"), 33780);
2849-assertEquals(DATEVALUE("1992/6/24 23:60"), 33780);
2850-assertEquals(DATEVALUE("1992/6/24 24:00"), 33780);
2851-assertEquals(DATEVALUE("1992/6/24 23:59"), 33779);
2852-assertEquals(DATEVALUE("1999/1/13 10:11111111"), 43889);
2853-assertEquals(DATEVALUE("1999/1/13 25000:22"), 37214);
2854-assertEquals(DATEVALUE("1999/1/13 25000:    22"), 37214);
2855-assertEquals(DATEVALUE("1992/6/24 00:00am"), 33779);
2856-assertEquals(DATEVALUE("1992/06/24 01:44am "), 33779);
2857-assertEquals(DATEVALUE("1999/1/01 02:59pm"), 36161);
2858-assertEquals(DATEVALUE("2222/1/01 03:33pm"), 117610);
2859-assertEquals(DATEVALUE("1902/9/02 12:33pm"), 976);
2860-assertEquals(DATEVALUE("1902/9/2 12:33pm"), 976);
2861-assertEquals(DATEVALUE("4243/11/3 12:33pm"), 856071);
2862-assertEquals(DATEVALUE("  1992/04/19   12:  33pm   "), 33713);
2863-assertEquals(DATEVALUE("1992/5/20 01:33am"), 33744);
2864-assertEquals(DATEVALUE("1992/6/21  3:33pm"), 33776);
2865-assertEquals(DATEVALUE("1992/9/29 3:33pm"), 33876);
2866-assertEquals(DATEVALUE("1992/1/24 3:33pm"), 33627);
2867-assertEquals(DATEVALUE("1992/12/21 3:33pm"), 33959);
2868-assertEquals(DATEVALUE("1992/01/31 3:33pm"), 33634);
2869-assertEquals(DATEVALUE("1992/1/13 3:33pm"), 33616);
2870-assertEquals(DATEVALUE("2004/2/29 3:33pm"), 38046);
2871-assertEquals(DATEVALUE("2004/2/28  3:33pm "), 38045);
2872-assertEquals(DATEVALUE("1999/1/13 3:33pm"), 36173);
2873-assertEquals(DATEVALUE("1999/01/13 3:33pm"), 36173);
2874-assertEquals(DATEVALUE("0999/01/13 3:33pm"), -329069);
2875-assertEquals(DATEVALUE("1200/01/13 3:33pm"), -255656);
2876-assertEquals(DATEVALUE("0029/01/13 3:33pm"), 47131);
2877-assertEquals(DATEVALUE("0030/01/13 3:33pm"), 10971);
2878-assertEquals(DATEVALUE("0044/01/13 3:33pm"), 16084);
2879-assertEquals(DATEVALUE("0050/01/13 3:33pm"), 18276);
2880-assertEquals(DATEVALUE("0097/01/13 00:33pm"), 35443);
2881-assertEquals(DATEVALUE("0099/01/13 3:33pm"), 36173);
2882-assertEquals(DATEVALUE("0000/01/13 3:33pm"), 36538);
2883-assertEquals(DATEVALUE("0101/01/13 3:33pm"), -657057);
2884-assertEquals(DATEVALUE("0100/01/13 3:33pm"), -657422);
2885-assertEquals(DATEVALUE("100/12/31 3:33pm"), -657070);
2886-assertEquals(DATEVALUE("122/11/10 3:33pm"), -649086);
2887-assertEquals(DATEVALUE("2222/1/22 3:33pm"), 117631);
2888-assertEquals(DATEVALUE("222/1/22 3:33pm"), -612854);
2889-assertEquals(DATEVALUE("1992/1/13 6:22222222am"), 49048); // overload minutes
2890-assertEquals(DATEVALUE("1992/1/13 12:720pm"), 33617); // overload minutes
2891-assertEquals(DATEVALUE("1992/1/13 00:720pm"), 33617); // overload minutes
2892-assertEquals(DATEVALUE("1992/1/13 12:719pm"), 33616); // overload minutes
2893-assertEquals(DATEVALUE("1992/1/13 00:720am"), 33616); // overload minutes
2894-assertEquals(DATEVALUE("1992/1/13 00:01pm"), 33616); // overload minutes
2895-assertEquals(DATEVALUE("1992/1/13 12:66669pm"), 33662); // overload minutes
2896-assertEquals(DATEVALUE("1992/1/13 12:66669am"), 33662); // overload minutes
2897-assertEquals(DATEVALUE("1992/1/13 12:66249pm"), 33662); // overload minutes
2898-assertEquals(DATEVALUE("1992/1/13 12:66249am"), 33662); // overload minutes
2899-assertEquals(DATEVALUE("1992/1/13 12:666669am"), 34078); // overload minutes
2900-assertEquals(DATEVALUE("1992/1/13 12:666669pm"), 34079); // overload minutes
2901-assertEquals(DATEVALUE("1992/1/13 12:100000000am"), 103060); // overload minutes
2902-assertEquals(DATEVALUE("1992/1/13 12:0912347287am"), 667190); // overload minutes
2903-assertEquals(DATEVALUE("1992/1/13 12:00000912347287am"), 667190); // overload minutes
2904-assertEquals(DATEVALUE("1992/1/13 12:1989198298am"), 1415003); // overload minutes
2905-assertEquals(DATEVALUE("1992/6/24 0:0:0"), 33779);
2906-assertEquals(DATEVALUE("1992/6/24 0000:0000:0000"), 33779);
2907-assertEquals(DATEVALUE("0000/01/13 3:33:999999999"), 48112); // overload seconds
2908-assertEquals(DATEVALUE("1992/1/13 6:22222222:0"), 49048); // overload minutes
2909-assertEquals(DATEVALUE("1992/1/13 12:912347287:10"), 667191); // overload minutes
2910-assertEquals(DATEVALUE("1992/1/13 12:100000000:10"), 103060); // overload minutes
2911-assertEquals(DATEVALUE("1992/1/13 23:720:10"), 33617); // overload minutes
2912-assertEquals(DATEVALUE("1992/1/13 23:719:60"), 33617); // overload minutes, seconds
2913-assertEquals(DATEVALUE("1992/6/24 24:00:00"), 33780); // overload hours
2914-assertEquals(DATEVALUE("1999/1/01 200000000:999999999:923231312"), 9074624); // overload hours, minutes, seconds
2915-assertEquals(DATEVALUE("  1992/04/19   12:  33: 11  "), 33713);
2916-assertEquals(DATEVALUE("0000/01/13 3:33:33"), 36538);
2917-assertEquals(DATEVALUE("4243/11/3 200000000:33:444"), 9189404);
2918-assertEquals(DATEVALUE("1999/1/13 10:10:10pm"), 36173);
2919-assertEquals(DATEVALUE("1992/6/24 0:0:0pm"), 33779);
2920-assertEquals(DATEVALUE("1992/6/24 00:0000:0000pm"), 33779);
2921-assertEquals(DATEVALUE("0000/01/13 3:33:999999999pm"), 48112); // overload seconds
2922-assertEquals(DATEVALUE("1992/1/13 6:22222222:0pm"), 49048); // overload minutes
2923-assertEquals(DATEVALUE("1992/1/13 12:912347287:10pm"), 667191); // overload minutes
2924-assertEquals(DATEVALUE("1992/1/13 12:100000000:10pm"), 103060); // overload minutes
2925-assertEquals(DATEVALUE("1992/6/24 00:00:00am"), 33779);
2926-assertEquals(DATEVALUE("1992/06/24 01:44:00am "), 33779);
2927-assertEquals(DATEVALUE("1999/1/01 02:59:00pm"), 36161);
2928-assertEquals(DATEVALUE("2222/1/01 03:33:00pm"), 117610);
2929-assertEquals(DATEVALUE("1902/9/02 12:33:00pm"), 976);
2930-assertEquals(DATEVALUE("1902/9/2 12:33:00pm"), 976);
2931-assertEquals(DATEVALUE("4243/11/3 12:33:00pm"), 856071);
2932-assertEquals(DATEVALUE("  1992/04/19   12:  33:  00  pm   "), 33713);
2933-assertEquals(DATEVALUE("1992/5/20 01:33:44am"), 33744);
2934-assertEquals(DATEVALUE("1992/6/21  3:33:44pm"), 33776);
2935-assertEquals(DATEVALUE("1992/9/29 3:33:44pm"), 33876);
2936-assertEquals(DATEVALUE("1992/1/24 3:33:44pm"), 33627);
2937-assertEquals(DATEVALUE("1992/12/21 3:33:44pm"), 33959);
2938-assertEquals(DATEVALUE("1992/01/31 3:33:44pm"), 33634);
2939-assertEquals(DATEVALUE("1992/1/13 3:33:44pm"), 33616);
2940-assertEquals(DATEVALUE("2004/2/29 3:33:44pm"), 38046);
2941-assertEquals(DATEVALUE("2004/2/28  3:33:44pm "), 38045);
2942-assertEquals(DATEVALUE("1999/1/13 3:33:44pm"), 36173);
2943-assertEquals(DATEVALUE("1999/01/13 3:33:44pm"), 36173);
2944-assertEquals(DATEVALUE("0999/01/13 3:33:44pm"), -329069);
2945-assertEquals(DATEVALUE("1200/01/13 3:33:44pm"), -255656);
2946-assertEquals(DATEVALUE("0029/01/13 3:33:44pm"), 47131);
2947-assertEquals(DATEVALUE("0030/01/13 3:33:44pm"), 10971);
2948-assertEquals(DATEVALUE("0044/01/13 3:33:44pm"), 16084);
2949-assertEquals(DATEVALUE("0050/01/13 3:33:44pm"), 18276);
2950-assertEquals(DATEVALUE("0097/01/13 00:33:44pm"), 35443);
2951-assertEquals(DATEVALUE("0099/01/13 3:33:44pm"), 36173);
2952-assertEquals(DATEVALUE("0000/01/13 3:33:44pm"), 36538);
2953-assertEquals(DATEVALUE("0101/01/13 3:33:44pm"), -657057);
2954-assertEquals(DATEVALUE("0100/01/13 3:33:44pm"), -657422);
2955-assertEquals(DATEVALUE("100/12/31 3:33:44pm"), -657070);
2956-assertEquals(DATEVALUE("122/11/10 3:33:44pm"), -649086);
2957-assertEquals(DATEVALUE("2222/1/22 3:33:44pm"), 117631);
2958-assertEquals(DATEVALUE("222/1/22 3:33:44pm"), -612854);
2959-assertEquals(DATEVALUE("1992/1/13 6:22222222:44am"), 49048); // overload minutes
2960-assertEquals(DATEVALUE("1992/1/13 12:720:00pm"), 33617); // overload minutes
2961-assertEquals(DATEVALUE("1992/1/13 00:720:00pm"), 33617); // overload minutes
2962-assertEquals(DATEVALUE("1992/1/13 12:719:00pm"), 33616); // overload minutes
2963-assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
2964-assertEquals(DATEVALUE("1992/1/13 12:719:60pm"), 33617); // overload minutes
2965-assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
2966-assertEquals(DATEVALUE("1992/1/13 00:01:00pm"), 33616); // overload minutes
2967-assertEquals(DATEVALUE("1992/1/13 12:66669:00pm"), 33662); // overload minutes
2968-assertEquals(DATEVALUE("1992/1/13 12:66669:00am"), 33662); // overload minutes
2969-assertEquals(DATEVALUE("1992/1/13 12:66249:00pm"), 33662); // overload minutes
2970-assertEquals(DATEVALUE("1992/1/13 12:66249:00am"), 33662); // overload minutes
2971-assertEquals(DATEVALUE("1992/1/13 12:666669:00am"), 34078); // overload minutes
2972-assertEquals(DATEVALUE("1992/1/13 12:666669:00pm"), 34079); // overload minutes
2973-assertEquals(DATEVALUE("1992/1/13 12:100000000:00am"), 103060); // overload minutes
2974-assertEquals(DATEVALUE("1992/1/13 12:912347287:00am"), 667190); // overload minutes
2975-// YEAR_MONTHDIG_DAY, YYYY(fd)MM(fd)DD =================================================================================
2976-assertEquals(DATEVALUE("1992/6/24"), 33779);
2977-assertEquals(DATEVALUE("1992/06/24"), 33779);
2978-assertEquals(DATEVALUE("1999/1/01"), 36161);
2979-assertEquals(DATEVALUE("2222/1/01"), 117610);
2980-assertEquals(DATEVALUE("1902/9/02"), 976);
2981-assertEquals(DATEVALUE("1902/9/2"), 976);
2982-assertEquals(DATEVALUE("4243/11/3"), 856071);
2983-assertEquals(DATEVALUE("  1992/04/19  "), 33713);
2984-assertEquals(DATEVALUE("  1992 /  04/ 19  "), 33713);
2985-assertEquals(DATEVALUE("1992/5/20"), 33744);
2986-assertEquals(DATEVALUE("1992/6/21"), 33776);
2987-assertEquals(DATEVALUE("1992/9/29"), 33876);
2988-assertEquals(DATEVALUE("1992/1/24"), 33627);
2989-assertEquals(DATEVALUE("1992/12/21"), 33959);
2990-assertEquals(DATEVALUE("1992/01/31"), 33634);
2991-assertEquals(DATEVALUE("1992/1/13"), 33616);
2992-assertEquals(DATEVALUE("2004/2/29"), 38046);
2993-assertEquals(DATEVALUE("2004/2/28"), 38045);
2994-assertEquals(DATEVALUE("1999/1/13"), 36173);
2995-assertEquals(DATEVALUE("1999/01/13"), 36173);
2996-assertEquals(DATEVALUE("0999/01/13"), -329069);
2997-assertEquals(DATEVALUE("1200/01/13"), -255656);
2998-assertEquals(DATEVALUE("0029/01/13"), 47131);
2999-assertEquals(DATEVALUE("0030/01/13"), 10971);
3000-assertEquals(DATEVALUE("0044/01/13"), 16084);
3001-assertEquals(DATEVALUE("0050/01/13"), 18276);
3002-assertEquals(DATEVALUE("0097/01/13"), 35443);
3003-assertEquals(DATEVALUE("0099/01/13"), 36173);
3004-assertEquals(DATEVALUE("0000/01/13"), 36538);
3005-assertEquals(DATEVALUE("0101/01/13"), -657057);
3006-assertEquals(DATEVALUE("0100/01/13"), -657422);
3007-assertEquals(DATEVALUE("100/12/31"), -657070);
3008-assertEquals(DATEVALUE("122/11/10"), -649086);
3009-assertEquals(DATEVALUE("2222/1/22"), 117631);
3010-assertEquals(DATEVALUE("222/1/22"), -612854);
3011-assertEquals(DATEVALUE("Sunday 1992/6/24"), 33779);
3012-assertEquals(DATEVALUE("Monday 1992/6/24"), 33779);
3013-assertEquals(DATEVALUE("Tuesday 1992/6/24"), 33779);
3014-assertEquals(DATEVALUE("Wednesday 1992/6/24"), 33779);
3015-assertEquals(DATEVALUE("Thursday 1992/6/24"), 33779);
3016-assertEquals(DATEVALUE("Friday 1992/6/24"), 33779);
3017-assertEquals(DATEVALUE("Saturday 1992/6/24"), 33779);
3018-assertEquals(DATEVALUE("Sun 1992/6/24"), 33779);
3019-assertEquals(DATEVALUE("Mon 1992/6/24"), 33779);
3020-assertEquals(DATEVALUE("Tue 1992/6/24"), 33779);
3021-assertEquals(DATEVALUE("Wed 1992/6/24"), 33779);
3022-assertEquals(DATEVALUE("Thu 1992/6/24"), 33779);
3023-assertEquals(DATEVALUE("Fri 1992/6/24"), 33779);
3024-assertEquals(DATEVALUE("Sat 1992/6/24"), 33779);
3025-assertEquals(DATEVALUE("Sunday, 1992/6/24"), 33779);
3026-// delimiter tests
3027-assertEquals(DATEVALUE("1992-6-24"), 33779);
3028-assertEquals(DATEVALUE("1992/6/24"), 33779);
3029-assertEquals(DATEVALUE("1992 6 24"), 33779);
3030-assertEquals(DATEVALUE("1992 6 24"), 33779);
3031-assertEquals(DATEVALUE("1992 . 6 . 24"), 33779);
3032-assertEquals(DATEVALUE("1992 / 6 / 24"), 33779);
3033-assertEquals(DATEVALUE("1992, 6, 24"), 33779);
3034-// flex delimiter should not allow a comma without a space after it.
3035-catchAndAssertEquals(function() {
3036-  DATEVALUE("Sunday,1992/6/24");
3037-}, ERRORS.VALUE_ERROR);
3038-// Leap day on non-leap years
3039-catchAndAssertEquals(function() {
3040-  DATEVALUE("2005/2/29");
3041-}, ERRORS.VALUE_ERROR);
3042-catchAndAssertEquals(function() {
3043-  DATEVALUE("2001/2/29");
3044-}, ERRORS.VALUE_ERROR);
3045-// Out of range day for any month
3046-catchAndAssertEquals(function() {
3047-  DATEVALUE("2005/1/44");
3048-}, ERRORS.VALUE_ERROR);
3049-// timestamp test
3050-assertEquals(DATEVALUE("1992-6-24 10am"), 33779);
3051-assertEquals(DATEVALUE("1992-6-24 10:10"), 33779);
3052-assertEquals(DATEVALUE("1992-6-24 10:10am"), 33779);
3053-assertEquals(DATEVALUE("1992-6-24 10:10:10"), 33779);
3054-assertEquals(DATEVALUE("1992-6-24 10:10:10am"), 33779);
3055-assertEquals(DATEVALUE("1992-6-24  10  am"), 33779);
3056-assertEquals(DATEVALUE("1992-6-24 10: 10 "), 33779);
3057-assertEquals(DATEVALUE("1992-6-24 10: 10 pm"), 33779);
3058-assertEquals(DATEVALUE("1992-6-24 10: 10: 10"), 33779);
3059-assertEquals(DATEVALUE("1992-6-24  10: 10: 10    am   "), 33779);
3060-assertEquals(DATEVALUE("1992/6/24 00am"), 33779);
3061-assertEquals(DATEVALUE("1992/06/24 01am "), 33779);
3062-assertEquals(DATEVALUE("1999/1/01 02pm"), 36161);
3063-assertEquals(DATEVALUE("2222/1/01 03pm"), 117610);
3064-assertEquals(DATEVALUE("1902/9/02 12pm"), 976);
3065-assertEquals(DATEVALUE("1902/9/2 12pm"), 976);
3066-assertEquals(DATEVALUE("4243/11/3 12pm   "), 856071);
3067-assertEquals(DATEVALUE("  1992/04/19   12pm   "), 33713);
3068-assertEquals(DATEVALUE("1992/5/20 01am"), 33744);
3069-assertEquals(DATEVALUE("1992/6/21  3pm"), 33776);
3070-assertEquals(DATEVALUE("1992/9/29 3pm"), 33876);
3071-assertEquals(DATEVALUE("1992/1/24 3pm"), 33627);
3072-assertEquals(DATEVALUE("1992/12/21 3pm"), 33959);
3073-assertEquals(DATEVALUE("1992/01/31 3pm"), 33634);
3074-assertEquals(DATEVALUE("1992/1/13 3pm"), 33616);
3075-assertEquals(DATEVALUE("2004/2/29 3pm"), 38046);
3076-assertEquals(DATEVALUE("2004/2/28  3pm "), 38045);
3077-assertEquals(DATEVALUE("1999/1/13 3pm"), 36173);
3078-assertEquals(DATEVALUE("1999/01/13 3pm"), 36173);
3079-assertEquals(DATEVALUE("0999/01/13 3pm"), -329069);
3080-assertEquals(DATEVALUE("1200/01/13 3pm"), -255656);
3081-assertEquals(DATEVALUE("0029/01/13 3pm"), 47131);
3082-assertEquals(DATEVALUE("0030/01/13 3pm"), 10971);
3083-assertEquals(DATEVALUE("0044/01/13 3pm"), 16084);
3084-assertEquals(DATEVALUE("0050/01/13 3pm"), 18276);
3085-assertEquals(DATEVALUE("0097/01/13 00pm"), 35443);
3086-assertEquals(DATEVALUE("0099/01/13 3pm"), 36173);
3087-assertEquals(DATEVALUE("0000/01/13 3pm"), 36538);
3088-assertEquals(DATEVALUE("0101/01/13 3pm"), -657057);
3089-assertEquals(DATEVALUE("0100/01/13 3pm"), -657422);
3090-assertEquals(DATEVALUE("100/12/31 3pm"), -657070);
3091-assertEquals(DATEVALUE("122/11/10 3pm"), -649086);
3092-assertEquals(DATEVALUE("2222/1/22 3pm"), 117631);
3093-assertEquals(DATEVALUE("222/1/22 3pm"), -612854);
3094-catchAndAssertEquals(function() {
3095-  DATEVALUE("2005/2/29 000pm");// Too many digits
3096-}, ERRORS.VALUE_ERROR);
3097-catchAndAssertEquals(function() {
3098-  DATEVALUE("2001/2/2 13pm");// Hour out of range
3099-}, ERRORS.VALUE_ERROR);
3100-// DAY_MONTHNAME_YEAR, DD(fd)Month(fd)YYYY =============================================================================
3101-assertEquals(DATEVALUE("Sun 09 Feb 2017"), 42775);
3102-assertEquals(DATEVALUE("Sun 9 Feb 2017"), 42775);
3103-assertEquals(DATEVALUE("Mon 09 Feb 2017"), 42775);
3104-assertEquals(DATEVALUE("Thursday 09 Feb 2017"), 42775);
3105-assertEquals(DATEVALUE("Thursday 09 February 2017"), 42775);
3106-assertEquals(DATEVALUE("Sun 01 September 20"), 44075);
3107-assertEquals(DATEVALUE("Sun, 09, Feb, 2017"), 42775);
3108-assertEquals(DATEVALUE("20 May 1992"), 33744);
3109-assertEquals(DATEVALUE("31 December 100"), -657070);
3110-assertEquals(DATEVALUE("13 January 0030"), 10971);
3111-assertEquals(DATEVALUE("13 January 1200"), -255656);
3112-assertEquals(DATEVALUE("22 January 2222"), 117631);
3113-assertEquals(DATEVALUE("3 November 4243"), 856071);
3114-assertEquals(DATEVALUE("13 November 0999"), -328765);
3115-assertEquals(DATEVALUE("13 November 1200"), -255351);
3116-assertEquals(DATEVALUE("13 January 0029"), 47131);
3117-assertEquals(DATEVALUE("13 January 0030"), 10971);
3118-assertEquals(DATEVALUE("13 January 0044"), 16084);
3119-assertEquals(DATEVALUE("13 January 0050"), 18276);
3120-assertEquals(DATEVALUE("13 January 0097"), 35443);
3121-assertEquals(DATEVALUE("13 January 0099"), 36173);
3122-assertEquals(DATEVALUE("13 January 0000"), 36538);
3123-assertEquals(DATEVALUE("13 January 0101"), -657057);
3124-assertEquals(DATEVALUE("13 January 0100"), -657422);
3125-assertEquals(DATEVALUE("01 Jan 2017"), 42736);
3126-assertEquals(DATEVALUE("01 Feb 2017"), 42767);
3127-assertEquals(DATEVALUE("01 Mar 2017"), 42795);
3128-assertEquals(DATEVALUE("01 Apr 2017"), 42826);
3129-assertEquals(DATEVALUE("01 May 2017"), 42856);
3130-assertEquals(DATEVALUE("01 Jun 2017"), 42887);
3131-assertEquals(DATEVALUE("01 Jul 2017"), 42917);
3132-assertEquals(DATEVALUE("01 Aug 2017"), 42948);
3133-assertEquals(DATEVALUE("01 Sep 2017"), 42979);
3134-assertEquals(DATEVALUE("01 Oct 2017"), 43009);
3135-assertEquals(DATEVALUE("01 Nov 2017"), 43040);
3136-assertEquals(DATEVALUE(" 1 Dec 2017"), 43070);
3137-assertEquals(DATEVALUE("20 Jan 2015"), 42024);
3138-assertEquals(DATEVALUE("20 Feb 2015"), 42055);
3139-assertEquals(DATEVALUE("20 Mar 2015"), 42083);
3140-assertEquals(DATEVALUE("20 Apr 2015"), 42114);
3141-assertEquals(DATEVALUE("20 May 2015"), 42144);
3142-assertEquals(DATEVALUE("20 Jun 2015"), 42175);
3143-assertEquals(DATEVALUE("20 Jul 2015"), 42205);
3144-assertEquals(DATEVALUE("20 Aug 2015"), 42236);
3145-assertEquals(DATEVALUE("20 Sep 2015"), 42267);
3146-assertEquals(DATEVALUE("20 Oct 2015"), 42297);
3147-assertEquals(DATEVALUE("20 Nov 2015"), 42328);
3148-assertEquals(DATEVALUE("20 Dec 2015"), 42358);
3149-assertEquals(DATEVALUE("29 Feb 2004"), 38046); // leap year, 29th ok
3150-catchAndAssertEquals(function() {
3151-  DATEVALUE("29 Feb 2001");// not leap year, 29th not ok
3152-}, ERRORS.VALUE_ERROR);
3153-catchAndAssertEquals(function() {
3154-  DATEVALUE("32 June 2001");// overload numbers not ok
3155-}, ERRORS.VALUE_ERROR);
3156-// delimiter tests
3157-assertEquals(DATEVALUE("Sun, 09, Feb, 2017"), 42775);
3158-assertEquals(DATEVALUE("Sun, 09/Feb/2017"), 42775);
3159-assertEquals(DATEVALUE("09/Feb/2017"), 42775);
3160-assertEquals(DATEVALUE("09-Feb-2017"), 42775);
3161-assertEquals(DATEVALUE("09.Feb.2017"), 42775);
3162-assertEquals(DATEVALUE("09 Feb/2017"), 42775);
3163-assertEquals(DATEVALUE("09 . Feb . 2017"), 42775);
3164-// If the delimiters don't match the first one should be a space.
3165-catchAndAssertEquals(function() {
3166-  DATEVALUE("09.Feb/2017");
3167-}, ERRORS.VALUE_ERROR);
3168-// Comma delimiters should be followed by spaces.
3169-catchAndAssertEquals(function() {
3170-  DATEVALUE("09,Feb,2017");
3171-}, ERRORS.VALUE_ERROR);
3172-// timestamp tests
3173-assertEquals(DATEVALUE("24/June/1992 10am"), 33779);
3174-assertEquals(DATEVALUE("24/June/1992 10:10"), 33779);
3175-assertEquals(DATEVALUE("24/June/1992 10:10am"), 33779);
3176-assertEquals(DATEVALUE("24/June/1992 10:10:10"), 33779);
3177-assertEquals(DATEVALUE("24/June/1992 10:10:10am"), 33779);
3178-assertEquals(DATEVALUE("24/June/1992  10  am"), 33779);
3179-assertEquals(DATEVALUE("24/June/1992 10: 10 "), 33779);
3180-assertEquals(DATEVALUE("24/June/1992 10: 10 pm"), 33779);
3181-assertEquals(DATEVALUE("24/June/1992 10: 10: 10"), 33779);
3182-assertEquals(DATEVALUE("24/June/1992  10: 10: 10    am   "), 33779);
3183-// MONTHNAME_DAY_YEAR, Month(fd)DD(fd)YYYY, 'Aug 19 2020' ==============================================================
3184-assertEquals(DATEVALUE("Sun Feb 09 2017"), 42775);
3185-assertEquals(DATEVALUE("Sun Feb 9 2017"), 42775);
3186-assertEquals(DATEVALUE("Mon Feb 09 2017"), 42775);
3187-assertEquals(DATEVALUE("Thursday Feb 09 2017"), 42775);
3188-assertEquals(DATEVALUE("Thursday February 09 2017"), 42775);
3189-assertEquals(DATEVALUE("Sun September 01 20"), 44075);
3190-assertEquals(DATEVALUE("Sun, Feb, 09, 2017"), 42775);
3191-assertEquals(DATEVALUE("May 20 1992"), 33744);
3192-assertEquals(DATEVALUE("December 31 100"), -657070);
3193-assertEquals(DATEVALUE("January 13 0030"), 10971);
3194-assertEquals(DATEVALUE("January 13 1200"), -255656);
3195-assertEquals(DATEVALUE("January 22 2222"), 117631);
3196-assertEquals(DATEVALUE("November 3 4243"), 856071);
3197-assertEquals(DATEVALUE("Feb 29 2004"), 38046); // leap year, 29th ok
3198-catchAndAssertEquals(function() {
3199-  DATEVALUE("Feb 29 2001");// not leap year, 29th not ok
3200-}, ERRORS.VALUE_ERROR);
3201-catchAndAssertEquals(function() {
3202-  DATEVALUE("June 32 2001");// overload numbers not ok
3203-}, ERRORS.VALUE_ERROR);
3204-// YEAR_MONTHDIG, YYYY(fd)MM, '1992/06' ================================================================================
3205-assertEquals(DATEVALUE("2017/01"), 42736);
3206-assertEquals(DATEVALUE("2017/02"), 42767);
3207-assertEquals(DATEVALUE("2017/03"), 42795);
3208-assertEquals(DATEVALUE("2017/04"), 42826);
3209-assertEquals(DATEVALUE("2017/05"), 42856);
3210-assertEquals(DATEVALUE("2017/06"), 42887);
3211-assertEquals(DATEVALUE("2017/07"), 42917);
3212-assertEquals(DATEVALUE("2017/08"), 42948);
3213-assertEquals(DATEVALUE("2017/09"), 42979);
3214-assertEquals(DATEVALUE("2017/10"), 43009);
3215-assertEquals(DATEVALUE("2017/11"), 43040);
3216-assertEquals(DATEVALUE("2017/12"), 43070);
3217-assertEquals(DATEVALUE("2017/01"), 42736);
3218-// delimiter tests
3219-assertEquals(DATEVALUE("Thursday 2017/01"), 42736);
3220-assertEquals(DATEVALUE("Thursday, 2017/01"), 42736);
3221-assertEquals(DATEVALUE("2017/01"), 42736);
3222-assertEquals(DATEVALUE("2017-01"), 42736);
3223-assertEquals(DATEVALUE("2017. 01"), 42736);
3224-assertEquals(DATEVALUE("2017 01"), 42736);
3225-assertEquals(DATEVALUE("2017, 01"), 42736);
3226-// Comma and period delimiters should be followed by spaces.
3227-catchAndAssertEquals(function() {
3228-  DATEVALUE("2017,01");
3229-}, ERRORS.VALUE_ERROR);
3230-catchAndAssertEquals(function() {
3231-  DATEVALUE("2017.01");
3232-}, ERRORS.VALUE_ERROR);
3233-// timestamp test
3234-assertEquals(DATEVALUE("2017-01 10am"), 42736);
3235-assertEquals(DATEVALUE("2017-01 10:10"), 42736);
3236-assertEquals(DATEVALUE("2017-01 10:10am"), 42736);
3237-assertEquals(DATEVALUE("2017-01 10:10:10"), 42736);
3238-assertEquals(DATEVALUE("2017-01 10:10:10am"), 42736);
3239-assertEquals(DATEVALUE("2017-01  10  am"), 42736);
3240-assertEquals(DATEVALUE("2017-01 10: 10 "), 42736);
3241-assertEquals(DATEVALUE("2017-01 10: 10 pm"), 42736);
3242-assertEquals(DATEVALUE("2017-01 10: 10: 10"), 42736);
3243-assertEquals(DATEVALUE("2017-01  10: 10: 10    am   "), 42736);
3244-// MONTHDIG_YEAR, MM(fd)YYYY, '06/1992' ================================================================================
3245-assertEquals(DATEVALUE("01/2017"), 42736);
3246-assertEquals(DATEVALUE("02/2017"), 42767);
3247-assertEquals(DATEVALUE("03/2017"), 42795);
3248-assertEquals(DATEVALUE("04/2017"), 42826);
3249-assertEquals(DATEVALUE("05/2017"), 42856);
3250-assertEquals(DATEVALUE("06/2017"), 42887);
3251-assertEquals(DATEVALUE("07/2017"), 42917);
3252-assertEquals(DATEVALUE("08/2017"), 42948);
3253-assertEquals(DATEVALUE("09/2017"), 42979);
3254-assertEquals(DATEVALUE("10/2017"), 43009);
3255-assertEquals(DATEVALUE("11/2017"), 43040);
3256-assertEquals(DATEVALUE("12/2017"), 43070);
3257-// delimiter tests
3258-assertEquals(DATEVALUE("Thursday 01/2017"), 42736);
3259-assertEquals(DATEVALUE("Thursday, 01/2017"), 42736);
3260-assertEquals(DATEVALUE("1/2017"), 42736);
3261-assertEquals(DATEVALUE("01-2017"), 42736);
3262-assertEquals(DATEVALUE("01. 2017"), 42736);
3263-assertEquals(DATEVALUE("01, 2017"), 42736);
3264-// Comma, period delimiters should be followed by spaces.
3265-catchAndAssertEquals(function() {
3266-  DATEVALUE("01,2017");
3267-}, ERRORS.VALUE_ERROR);
3268-catchAndAssertEquals(function() {
3269-  DATEVALUE("01.2017");
3270-}, ERRORS.VALUE_ERROR);
3271-// 0 is not a month
3272-catchAndAssertEquals(function() {
3273-  DATEVALUE("0/2017");
3274-}, ERRORS.VALUE_ERROR);
3275-// timestamp test
3276-assertEquals(DATEVALUE("01-2017 10am"), 42736);
3277-assertEquals(DATEVALUE("01-2017 10:10"), 42736);
3278-assertEquals(DATEVALUE("01-2017 10:10am"), 42736);
3279-assertEquals(DATEVALUE("01-2017 10:10:10"), 42736);
3280-assertEquals(DATEVALUE("01-2017 10:10:10am"), 42736);
3281-assertEquals(DATEVALUE("01-2017  10  am"), 42736);
3282-assertEquals(DATEVALUE("01-2017 10: 10 "), 42736);
3283-assertEquals(DATEVALUE("01-2017 10: 10 pm"), 42736);
3284-assertEquals(DATEVALUE("01-2017 10: 10: 10"), 42736);
3285-assertEquals(DATEVALUE("01-2017  10: 10: 10    am   "), 42736);
3286-// YEAR_MONTHNAME, YYYY(fd)Month, '1992/Aug' ===========================================================================
3287-assertEquals(DATEVALUE("2017 January"), 42736);
3288-assertEquals(DATEVALUE("2017 February"), 42767);
3289-assertEquals(DATEVALUE("2017 March"), 42795);
3290-assertEquals(DATEVALUE("2017 April"), 42826);
3291-assertEquals(DATEVALUE("2017 May"), 42856);
3292-assertEquals(DATEVALUE("2017 June"), 42887);
3293-assertEquals(DATEVALUE("2017 July"), 42917);
3294-assertEquals(DATEVALUE("2017 August"), 42948);
3295-assertEquals(DATEVALUE("2017 September"), 42979);
3296-assertEquals(DATEVALUE("2017 October"), 43009);
3297-assertEquals(DATEVALUE("2017 November"), 43040);
3298-assertEquals(DATEVALUE("2017 December"), 43070);
3299-// delimiter tests
3300-assertEquals(DATEVALUE("Thursday 2017 January"), 42736);
3301-assertEquals(DATEVALUE("Thursday, 2017 January"), 42736);
3302-assertEquals(DATEVALUE("2017/January"), 42736);
3303-assertEquals(DATEVALUE("2017-January"), 42736);
3304-assertEquals(DATEVALUE("2017. January"), 42736);
3305-assertEquals(DATEVALUE("2017, January"), 42736);
3306-// Comma delimiters should be followed by spaces.
3307-catchAndAssertEquals(function() {
3308-  DATEVALUE("2017,January");
3309-}, ERRORS.VALUE_ERROR);
3310-catchAndAssertEquals(function() {
3311-  DATEVALUE("2017.January");
3312-}, ERRORS.VALUE_ERROR);
3313-// timestamp test
3314-assertEquals(DATEVALUE("2017-January 10am"), 42736);
3315-assertEquals(DATEVALUE("2017-January 10:10"), 42736);
3316-assertEquals(DATEVALUE("2017-January 10:10am"), 42736);
3317-assertEquals(DATEVALUE("2017-January 10:10:10"), 42736);
3318-assertEquals(DATEVALUE("2017-January 10:10:10am"), 42736);
3319-assertEquals(DATEVALUE("2017-January  10  am"), 42736);
3320-assertEquals(DATEVALUE("2017-January 10: 10 "), 42736);
3321-assertEquals(DATEVALUE("2017-January 10: 10 pm"), 42736);
3322-assertEquals(DATEVALUE("2017-January 10: 10: 10"), 42736);
3323-assertEquals(DATEVALUE("2017-January  10: 10: 10    am   "), 42736);
3324-// MONTHNAME_YEAR, Month(fd)YYYY, 'Aug 1992' ===========================================================================
3325-assertEquals(DATEVALUE("January 2017"), 42736);
3326-assertEquals(DATEVALUE("February 2017"), 42767);
3327-assertEquals(DATEVALUE("March 2017"), 42795);
3328-assertEquals(DATEVALUE("April 2017"), 42826);
3329-assertEquals(DATEVALUE("May 2017"), 42856);
3330-assertEquals(DATEVALUE("June 2017"), 42887);
3331-assertEquals(DATEVALUE("July 2017"), 42917);
3332-assertEquals(DATEVALUE("August 2017"), 42948);
3333-assertEquals(DATEVALUE("September 2017"), 42979);
3334-assertEquals(DATEVALUE("October 2017"), 43009);
3335-assertEquals(DATEVALUE("November 2017"), 43040);
3336-assertEquals(DATEVALUE("December 2017"), 43070);
3337-assertEquals(DATEVALUE("  Feb    2017  "), 42767);
3338-assertEquals(DATEVALUE("Feb-2017"), 42767);
3339-assertEquals(DATEVALUE("Feb. 2017"), 42767);
3340-assertEquals(DATEVALUE("Feb/2017"), 42767);
3341-assertEquals(DATEVALUE("Feb    .    2017"), 42767);
3342-assertEquals(DATEVALUE("Feb -      2017"), 42767);
3343-assertEquals(DATEVALUE("January 0030"), 10959);
3344-assertEquals(DATEVALUE("November 4243"), 856069);
3345-assertEquals(DATEVALUE("December 0100"), -657100);
3346-assertEquals(DATEVALUE("Jan 2017"), 42736);
3347-assertEquals(DATEVALUE("Feb 2017"), 42767);
3348-assertEquals(DATEVALUE("Mar 2017"), 42795);
3349-assertEquals(DATEVALUE("Apr 2017"), 42826);
3350-assertEquals(DATEVALUE("May 2017"), 42856);
3351-assertEquals(DATEVALUE("Jun 2017"), 42887);
3352-assertEquals(DATEVALUE("Jul 2017"), 42917);
3353-assertEquals(DATEVALUE("Aug 2017"), 42948);
3354-assertEquals(DATEVALUE("Sep 2017"), 42979);
3355-assertEquals(DATEVALUE("Oct 2017"), 43009);
3356-assertEquals(DATEVALUE("Nov 2017"), 43040);
3357-assertEquals(DATEVALUE("Dec 2017"), 43070);
3358-assertEquals(DATEVALUE("Feb, 2017"), 42767);
3359-catchAndAssertEquals(function() {
3360-  DATEVALUE("December 100");// need 4 digits
3361-}, ERRORS.VALUE_ERROR);
3362-catchAndAssertEquals(function() {
3363-  DATEVALUE("Dec.20");// need space after if using period
3364-}, ERRORS.VALUE_ERROR);
3365-// delimiter tests
3366-assertEquals(DATEVALUE("Thursday January 2017"), 42736);
3367-assertEquals(DATEVALUE("Thursday, January 2017"), 42736);
3368-assertEquals(DATEVALUE("January/2017"), 42736);
3369-assertEquals(DATEVALUE("January-2017"), 42736);
3370-assertEquals(DATEVALUE("January. 2017"), 42736);
3371-assertEquals(DATEVALUE("January, 2017"), 42736);
3372-// Comma, period delimiters should be followed by spaces.
3373-catchAndAssertEquals(function() {
3374-  DATEVALUE("January,2017");
3375-}, ERRORS.VALUE_ERROR);
3376-catchAndAssertEquals(function() {
3377-  DATEVALUE("January.2017");
3378-}, ERRORS.VALUE_ERROR);
3379-// timestamp test
3380-assertEquals(DATEVALUE("January-2017 10am"), 42736);
3381-assertEquals(DATEVALUE("January-2017 10:10"), 42736);
3382-assertEquals(DATEVALUE("January-2017 10:10am"), 42736);
3383-assertEquals(DATEVALUE("January-2017 10:10:10"), 42736);
3384-assertEquals(DATEVALUE("January-2017 10:10:10am"), 42736);
3385-assertEquals(DATEVALUE("January-2017  10  am"), 42736);
3386-assertEquals(DATEVALUE("January-2017 10: 10 "), 42736);
3387-assertEquals(DATEVALUE("January-2017 10: 10 pm"), 42736);
3388-assertEquals(DATEVALUE("January-2017 10: 10: 10"), 42736);
3389-assertEquals(DATEVALUE("January-2017  10: 10: 10    am  "), 42736);
3390+test("DATEVALUE", function(){
3391+  assertEquals(DATEVALUE("6/24/92"), 33779);
3392+  assertEquals(DATEVALUE(["6/24/92", false]), 33779);
3393+  catchAndAssertEquals(function() {
3394+    DATEVALUE("6/24/92", 10);
3395+  }, ERRORS.NA_ERROR);
3396+  catchAndAssertEquals(function() {
3397+    DATEVALUE();
3398+  }, ERRORS.NA_ERROR);
3399+  catchAndAssertEquals(function() {
3400+    DATEVALUE(false);
3401+  }, ERRORS.VALUE_ERROR);
3402+  // MONTHDIG_DAY_YEAR, MM(fd)DD(fd)YYYY ===============================================================================
3403+  assertEquals(DATEVALUE("6/24/92"), 33779);
3404+  assertEquals(DATEVALUE("6/24/1992"), 33779);
3405+  assertEquals(DATEVALUE("06/24/1992"), 33779);
3406+  assertEquals(DATEVALUE("1/01/1999"), 36161);
3407+  assertEquals(DATEVALUE("1/01/99"), 36161);
3408+  assertEquals(DATEVALUE("1/01/2222"), 117610);
3409+  assertEquals(DATEVALUE("9/02/1902"), 976);
3410+  assertEquals(DATEVALUE("9/2/1902"), 976);
3411+  assertEquals(DATEVALUE("11/3/4243"), 856071);
3412+  assertEquals(DATEVALUE("  04/19/1992  "), 33713);
3413+  assertEquals(DATEVALUE("5/20/1992"), 33744);
3414+  assertEquals(DATEVALUE("6/21/1992"), 33776);
3415+  assertEquals(DATEVALUE("9/29/1992"), 33876);
3416+  assertEquals(DATEVALUE("1/24/1992"), 33627);
3417+  assertEquals(DATEVALUE("12/21/1992"), 33959);
3418+  assertEquals(DATEVALUE("01/31/1992"), 33634);
3419+  assertEquals(DATEVALUE("1/13/1992"), 33616);
3420+  assertEquals(DATEVALUE("2/29/2004"), 38046);
3421+  assertEquals(DATEVALUE("2/28/2004"), 38045);
3422+  assertEquals(DATEVALUE("2/28/004"), 38045);
3423+  assertEquals(DATEVALUE("2/28/04"), 38045);
3424+  assertEquals(DATEVALUE("2/28/4"), 38045);
3425+  assertEquals(DATEVALUE("1/13/1999"), 36173);
3426+  assertEquals(DATEVALUE("01/13/1999"), 36173);
3427+  assertEquals(DATEVALUE("01/13/0999"), -329069);
3428+  assertEquals(DATEVALUE("01/13/1200"), -255656);
3429+  assertEquals(DATEVALUE("01/13/0029"), 47131);
3430+  assertEquals(DATEVALUE("01/13/0030"), 10971);
3431+  assertEquals(DATEVALUE("01/13/0044"), 16084);
3432+  assertEquals(DATEVALUE("01/13/0050"), 18276);
3433+  assertEquals(DATEVALUE("01/13/0097"), 35443);
3434+  assertEquals(DATEVALUE("01/13/0099"), 36173);
3435+  assertEquals(DATEVALUE("01/13/0000"), 36538);
3436+  assertEquals(DATEVALUE("01/13/0101"), -657057);
3437+  assertEquals(DATEVALUE("01/13/0100"), -657422);
3438+  assertEquals(DATEVALUE("12/31/100"), -657070);
3439+  assertEquals(DATEVALUE("11/10/122"), -649086);
3440+  assertEquals(DATEVALUE("1/22/2222"), 117631);
3441+  assertEquals(DATEVALUE("1/22/222"), -612854);
3442+  // delimiter tests
3443+  assertEquals(DATEVALUE("6-24-92"), 33779);
3444+  assertEquals(DATEVALUE("6/24/92"), 33779);
3445+  assertEquals(DATEVALUE("6 24 92"), 33779);
3446+  assertEquals(DATEVALUE("6.24.92"), 33779);
3447+  assertEquals(DATEVALUE("6 . 24 . 92"), 33779);
3448+  assertEquals(DATEVALUE("6 / 24 / 92"), 33779);
3449+  assertEquals(DATEVALUE("6, 24, 92"), 33779);
3450+  // flex delimiter should not allow a comma without a space after it.
3451+  catchAndAssertEquals(function() {
3452+    DATEVALUE("Sunday,6/24/92");
3453+  }, ERRORS.VALUE_ERROR);
3454+  // Leap day on non-leap years
3455+  catchAndAssertEquals(function() {
3456+    DATEVALUE("2/29/2005");
3457+  }, ERRORS.VALUE_ERROR);
3458+  catchAndAssertEquals(function() {
3459+    DATEVALUE("2/29/2001");
3460+  }, ERRORS.VALUE_ERROR);
3461+  // Out of range day for any month
3462+  catchAndAssertEquals(function() {
3463+    DATEVALUE("1/44/2005");
3464+  }, ERRORS.VALUE_ERROR);
3465+  // timestamp test
3466+  assertEquals(DATEVALUE("6-24-92 10am"), 33779);
3467+  assertEquals(DATEVALUE("6-24-92 10:10"), 33779);
3468+  assertEquals(DATEVALUE("6-24-92 10:10am"), 33779);
3469+  assertEquals(DATEVALUE("6-24-92 10:10:10"), 33779);
3470+  assertEquals(DATEVALUE("6-24-92 10:10:10am"), 33779);
3471+  assertEquals(DATEVALUE("6-24-92  10  am"), 33779);
3472+  assertEquals(DATEVALUE("6-24-92 10: 10 "), 33779);
3473+  assertEquals(DATEVALUE("6-24-92 10: 10 pm"), 33779);
3474+  assertEquals(DATEVALUE("6-24-92 10: 10: 10"), 33779);
3475+  assertEquals(DATEVALUE("6-24-92  10: 10: 10    am  "), 33779);
3476+  assertEquals(DATEVALUE("1992/6/24 00:00"), 33779);
3477+  assertEquals(DATEVALUE("1992/6/24 0:00"), 33779);
3478+  assertEquals(DATEVALUE("1992/6/24 10:10"), 33779);
3479+  assertEquals(DATEVALUE("1992/6/24 16:22"), 33779);
3480+  assertEquals(DATEVALUE("1992/6/24 25:10"), 33780);
3481+  assertEquals(DATEVALUE("1992/6/24 23:60"), 33780);
3482+  assertEquals(DATEVALUE("1992/6/24 24:00"), 33780);
3483+  assertEquals(DATEVALUE("1992/6/24 23:59"), 33779);
3484+  assertEquals(DATEVALUE("1999/1/13 10:11111111"), 43889);
3485+  assertEquals(DATEVALUE("1999/1/13 25000:22"), 37214);
3486+  assertEquals(DATEVALUE("1999/1/13 25000:    22"), 37214);
3487+  assertEquals(DATEVALUE("1992/6/24 00:00am"), 33779);
3488+  assertEquals(DATEVALUE("1992/06/24 01:44am "), 33779);
3489+  assertEquals(DATEVALUE("1999/1/01 02:59pm"), 36161);
3490+  assertEquals(DATEVALUE("2222/1/01 03:33pm"), 117610);
3491+  assertEquals(DATEVALUE("1902/9/02 12:33pm"), 976);
3492+  assertEquals(DATEVALUE("1902/9/2 12:33pm"), 976);
3493+  assertEquals(DATEVALUE("4243/11/3 12:33pm"), 856071);
3494+  assertEquals(DATEVALUE("  1992/04/19   12:  33pm   "), 33713);
3495+  assertEquals(DATEVALUE("1992/5/20 01:33am"), 33744);
3496+  assertEquals(DATEVALUE("1992/6/21  3:33pm"), 33776);
3497+  assertEquals(DATEVALUE("1992/9/29 3:33pm"), 33876);
3498+  assertEquals(DATEVALUE("1992/1/24 3:33pm"), 33627);
3499+  assertEquals(DATEVALUE("1992/12/21 3:33pm"), 33959);
3500+  assertEquals(DATEVALUE("1992/01/31 3:33pm"), 33634);
3501+  assertEquals(DATEVALUE("1992/1/13 3:33pm"), 33616);
3502+  assertEquals(DATEVALUE("2004/2/29 3:33pm"), 38046);
3503+  assertEquals(DATEVALUE("2004/2/28  3:33pm "), 38045);
3504+  assertEquals(DATEVALUE("1999/1/13 3:33pm"), 36173);
3505+  assertEquals(DATEVALUE("1999/01/13 3:33pm"), 36173);
3506+  assertEquals(DATEVALUE("0999/01/13 3:33pm"), -329069);
3507+  assertEquals(DATEVALUE("1200/01/13 3:33pm"), -255656);
3508+  assertEquals(DATEVALUE("0029/01/13 3:33pm"), 47131);
3509+  assertEquals(DATEVALUE("0030/01/13 3:33pm"), 10971);
3510+  assertEquals(DATEVALUE("0044/01/13 3:33pm"), 16084);
3511+  assertEquals(DATEVALUE("0050/01/13 3:33pm"), 18276);
3512+  assertEquals(DATEVALUE("0097/01/13 00:33pm"), 35443);
3513+  assertEquals(DATEVALUE("0099/01/13 3:33pm"), 36173);
3514+  assertEquals(DATEVALUE("0000/01/13 3:33pm"), 36538);
3515+  assertEquals(DATEVALUE("0101/01/13 3:33pm"), -657057);
3516+  assertEquals(DATEVALUE("0100/01/13 3:33pm"), -657422);
3517+  assertEquals(DATEVALUE("100/12/31 3:33pm"), -657070);
3518+  assertEquals(DATEVALUE("122/11/10 3:33pm"), -649086);
3519+  assertEquals(DATEVALUE("2222/1/22 3:33pm"), 117631);
3520+  assertEquals(DATEVALUE("222/1/22 3:33pm"), -612854);
3521+  assertEquals(DATEVALUE("1992/1/13 6:22222222am"), 49048); // overload minutes
3522+  assertEquals(DATEVALUE("1992/1/13 12:720pm"), 33617); // overload minutes
3523+  assertEquals(DATEVALUE("1992/1/13 00:720pm"), 33617); // overload minutes
3524+  assertEquals(DATEVALUE("1992/1/13 12:719pm"), 33616); // overload minutes
3525+  assertEquals(DATEVALUE("1992/1/13 00:720am"), 33616); // overload minutes
3526+  assertEquals(DATEVALUE("1992/1/13 00:01pm"), 33616); // overload minutes
3527+  assertEquals(DATEVALUE("1992/1/13 12:66669pm"), 33662); // overload minutes
3528+  assertEquals(DATEVALUE("1992/1/13 12:66669am"), 33662); // overload minutes
3529+  assertEquals(DATEVALUE("1992/1/13 12:66249pm"), 33662); // overload minutes
3530+  assertEquals(DATEVALUE("1992/1/13 12:66249am"), 33662); // overload minutes
3531+  assertEquals(DATEVALUE("1992/1/13 12:666669am"), 34078); // overload minutes
3532+  assertEquals(DATEVALUE("1992/1/13 12:666669pm"), 34079); // overload minutes
3533+  assertEquals(DATEVALUE("1992/1/13 12:100000000am"), 103060); // overload minutes
3534+  assertEquals(DATEVALUE("1992/1/13 12:0912347287am"), 667190); // overload minutes
3535+  assertEquals(DATEVALUE("1992/1/13 12:00000912347287am"), 667190); // overload minutes
3536+  assertEquals(DATEVALUE("1992/1/13 12:1989198298am"), 1415003); // overload minutes
3537+  assertEquals(DATEVALUE("1992/6/24 0:0:0"), 33779);
3538+  assertEquals(DATEVALUE("1992/6/24 0000:0000:0000"), 33779);
3539+  assertEquals(DATEVALUE("0000/01/13 3:33:999999999"), 48112); // overload seconds
3540+  assertEquals(DATEVALUE("1992/1/13 6:22222222:0"), 49048); // overload minutes
3541+  assertEquals(DATEVALUE("1992/1/13 12:912347287:10"), 667191); // overload minutes
3542+  assertEquals(DATEVALUE("1992/1/13 12:100000000:10"), 103060); // overload minutes
3543+  assertEquals(DATEVALUE("1992/1/13 23:720:10"), 33617); // overload minutes
3544+  assertEquals(DATEVALUE("1992/1/13 23:719:60"), 33617); // overload minutes, seconds
3545+  assertEquals(DATEVALUE("1992/6/24 24:00:00"), 33780); // overload hours
3546+  assertEquals(DATEVALUE("1999/1/01 200000000:999999999:923231312"), 9074624); // overload hours, minutes, seconds
3547+  assertEquals(DATEVALUE("  1992/04/19   12:  33: 11  "), 33713);
3548+  assertEquals(DATEVALUE("0000/01/13 3:33:33"), 36538);
3549+  assertEquals(DATEVALUE("4243/11/3 200000000:33:444"), 9189404);
3550+  assertEquals(DATEVALUE("1999/1/13 10:10:10pm"), 36173);
3551+  assertEquals(DATEVALUE("1992/6/24 0:0:0pm"), 33779);
3552+  assertEquals(DATEVALUE("1992/6/24 00:0000:0000pm"), 33779);
3553+  assertEquals(DATEVALUE("0000/01/13 3:33:999999999pm"), 48112); // overload seconds
3554+  assertEquals(DATEVALUE("1992/1/13 6:22222222:0pm"), 49048); // overload minutes
3555+  assertEquals(DATEVALUE("1992/1/13 12:912347287:10pm"), 667191); // overload minutes
3556+  assertEquals(DATEVALUE("1992/1/13 12:100000000:10pm"), 103060); // overload minutes
3557+  assertEquals(DATEVALUE("1992/6/24 00:00:00am"), 33779);
3558+  assertEquals(DATEVALUE("1992/06/24 01:44:00am "), 33779);
3559+  assertEquals(DATEVALUE("1999/1/01 02:59:00pm"), 36161);
3560+  assertEquals(DATEVALUE("2222/1/01 03:33:00pm"), 117610);
3561+  assertEquals(DATEVALUE("1902/9/02 12:33:00pm"), 976);
3562+  assertEquals(DATEVALUE("1902/9/2 12:33:00pm"), 976);
3563+  assertEquals(DATEVALUE("4243/11/3 12:33:00pm"), 856071);
3564+  assertEquals(DATEVALUE("  1992/04/19   12:  33:  00  pm   "), 33713);
3565+  assertEquals(DATEVALUE("1992/5/20 01:33:44am"), 33744);
3566+  assertEquals(DATEVALUE("1992/6/21  3:33:44pm"), 33776);
3567+  assertEquals(DATEVALUE("1992/9/29 3:33:44pm"), 33876);
3568+  assertEquals(DATEVALUE("1992/1/24 3:33:44pm"), 33627);
3569+  assertEquals(DATEVALUE("1992/12/21 3:33:44pm"), 33959);
3570+  assertEquals(DATEVALUE("1992/01/31 3:33:44pm"), 33634);
3571+  assertEquals(DATEVALUE("1992/1/13 3:33:44pm"), 33616);
3572+  assertEquals(DATEVALUE("2004/2/29 3:33:44pm"), 38046);
3573+  assertEquals(DATEVALUE("2004/2/28  3:33:44pm "), 38045);
3574+  assertEquals(DATEVALUE("1999/1/13 3:33:44pm"), 36173);
3575+  assertEquals(DATEVALUE("1999/01/13 3:33:44pm"), 36173);
3576+  assertEquals(DATEVALUE("0999/01/13 3:33:44pm"), -329069);
3577+  assertEquals(DATEVALUE("1200/01/13 3:33:44pm"), -255656);
3578+  assertEquals(DATEVALUE("0029/01/13 3:33:44pm"), 47131);
3579+  assertEquals(DATEVALUE("0030/01/13 3:33:44pm"), 10971);
3580+  assertEquals(DATEVALUE("0044/01/13 3:33:44pm"), 16084);
3581+  assertEquals(DATEVALUE("0050/01/13 3:33:44pm"), 18276);
3582+  assertEquals(DATEVALUE("0097/01/13 00:33:44pm"), 35443);
3583+  assertEquals(DATEVALUE("0099/01/13 3:33:44pm"), 36173);
3584+  assertEquals(DATEVALUE("0000/01/13 3:33:44pm"), 36538);
3585+  assertEquals(DATEVALUE("0101/01/13 3:33:44pm"), -657057);
3586+  assertEquals(DATEVALUE("0100/01/13 3:33:44pm"), -657422);
3587+  assertEquals(DATEVALUE("100/12/31 3:33:44pm"), -657070);
3588+  assertEquals(DATEVALUE("122/11/10 3:33:44pm"), -649086);
3589+  assertEquals(DATEVALUE("2222/1/22 3:33:44pm"), 117631);
3590+  assertEquals(DATEVALUE("222/1/22 3:33:44pm"), -612854);
3591+  assertEquals(DATEVALUE("1992/1/13 6:22222222:44am"), 49048); // overload minutes
3592+  assertEquals(DATEVALUE("1992/1/13 12:720:00pm"), 33617); // overload minutes
3593+  assertEquals(DATEVALUE("1992/1/13 00:720:00pm"), 33617); // overload minutes
3594+  assertEquals(DATEVALUE("1992/1/13 12:719:00pm"), 33616); // overload minutes
3595+  assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
3596+  assertEquals(DATEVALUE("1992/1/13 12:719:60pm"), 33617); // overload minutes
3597+  assertEquals(DATEVALUE("1992/1/13 00:720:00am"), 33616); // overload minutes
3598+  assertEquals(DATEVALUE("1992/1/13 00:01:00pm"), 33616); // overload minutes
3599+  assertEquals(DATEVALUE("1992/1/13 12:66669:00pm"), 33662); // overload minutes
3600+  assertEquals(DATEVALUE("1992/1/13 12:66669:00am"), 33662); // overload minutes
3601+  assertEquals(DATEVALUE("1992/1/13 12:66249:00pm"), 33662); // overload minutes
3602+  assertEquals(DATEVALUE("1992/1/13 12:66249:00am"), 33662); // overload minutes
3603+  assertEquals(DATEVALUE("1992/1/13 12:666669:00am"), 34078); // overload minutes
3604+  assertEquals(DATEVALUE("1992/1/13 12:666669:00pm"), 34079); // overload minutes
3605+  assertEquals(DATEVALUE("1992/1/13 12:100000000:00am"), 103060); // overload minutes
3606+  assertEquals(DATEVALUE("1992/1/13 12:912347287:00am"), 667190); // overload minutes
3607+  // YEAR_MONTHDIG_DAY, YYYY(fd)MM(fd)DD ===============================================================================
3608+  assertEquals(DATEVALUE("1992/6/24"), 33779);
3609+  assertEquals(DATEVALUE("1992/06/24"), 33779);
3610+  assertEquals(DATEVALUE("1999/1/01"), 36161);
3611+  assertEquals(DATEVALUE("2222/1/01"), 117610);
3612+  assertEquals(DATEVALUE("1902/9/02"), 976);
3613+  assertEquals(DATEVALUE("1902/9/2"), 976);
3614+  assertEquals(DATEVALUE("4243/11/3"), 856071);
3615+  assertEquals(DATEVALUE("  1992/04/19  "), 33713);
3616+  assertEquals(DATEVALUE("  1992 /  04/ 19  "), 33713);
3617+  assertEquals(DATEVALUE("1992/5/20"), 33744);
3618+  assertEquals(DATEVALUE("1992/6/21"), 33776);
3619+  assertEquals(DATEVALUE("1992/9/29"), 33876);
3620+  assertEquals(DATEVALUE("1992/1/24"), 33627);
3621+  assertEquals(DATEVALUE("1992/12/21"), 33959);
3622+  assertEquals(DATEVALUE("1992/01/31"), 33634);
3623+  assertEquals(DATEVALUE("1992/1/13"), 33616);
3624+  assertEquals(DATEVALUE("2004/2/29"), 38046);
3625+  assertEquals(DATEVALUE("2004/2/28"), 38045);
3626+  assertEquals(DATEVALUE("1999/1/13"), 36173);
3627+  assertEquals(DATEVALUE("1999/01/13"), 36173);
3628+  assertEquals(DATEVALUE("0999/01/13"), -329069);
3629+  assertEquals(DATEVALUE("1200/01/13"), -255656);
3630+  assertEquals(DATEVALUE("0029/01/13"), 47131);
3631+  assertEquals(DATEVALUE("0030/01/13"), 10971);
3632+  assertEquals(DATEVALUE("0044/01/13"), 16084);
3633+  assertEquals(DATEVALUE("0050/01/13"), 18276);
3634+  assertEquals(DATEVALUE("0097/01/13"), 35443);
3635+  assertEquals(DATEVALUE("0099/01/13"), 36173);
3636+  assertEquals(DATEVALUE("0000/01/13"), 36538);
3637+  assertEquals(DATEVALUE("0101/01/13"), -657057);
3638+  assertEquals(DATEVALUE("0100/01/13"), -657422);
3639+  assertEquals(DATEVALUE("100/12/31"), -657070);
3640+  assertEquals(DATEVALUE("122/11/10"), -649086);
3641+  assertEquals(DATEVALUE("2222/1/22"), 117631);
3642+  assertEquals(DATEVALUE("222/1/22"), -612854);
3643+  assertEquals(DATEVALUE("Sunday 1992/6/24"), 33779);
3644+  assertEquals(DATEVALUE("Monday 1992/6/24"), 33779);
3645+  assertEquals(DATEVALUE("Tuesday 1992/6/24"), 33779);
3646+  assertEquals(DATEVALUE("Wednesday 1992/6/24"), 33779);
3647+  assertEquals(DATEVALUE("Thursday 1992/6/24"), 33779);
3648+  assertEquals(DATEVALUE("Friday 1992/6/24"), 33779);
3649+  assertEquals(DATEVALUE("Saturday 1992/6/24"), 33779);
3650+  assertEquals(DATEVALUE("Sun 1992/6/24"), 33779);
3651+  assertEquals(DATEVALUE("Mon 1992/6/24"), 33779);
3652+  assertEquals(DATEVALUE("Tue 1992/6/24"), 33779);
3653+  assertEquals(DATEVALUE("Wed 1992/6/24"), 33779);
3654+  assertEquals(DATEVALUE("Thu 1992/6/24"), 33779);
3655+  assertEquals(DATEVALUE("Fri 1992/6/24"), 33779);
3656+  assertEquals(DATEVALUE("Sat 1992/6/24"), 33779);
3657+  assertEquals(DATEVALUE("Sunday, 1992/6/24"), 33779);
3658+  // delimiter tests
3659+  assertEquals(DATEVALUE("1992-6-24"), 33779);
3660+  assertEquals(DATEVALUE("1992/6/24"), 33779);
3661+  assertEquals(DATEVALUE("1992 6 24"), 33779);
3662+  assertEquals(DATEVALUE("1992 6 24"), 33779);
3663+  assertEquals(DATEVALUE("1992 . 6 . 24"), 33779);
3664+  assertEquals(DATEVALUE("1992 / 6 / 24"), 33779);
3665+  assertEquals(DATEVALUE("1992, 6, 24"), 33779);
3666+  // flex delimiter should not allow a comma without a space after it.
3667+  catchAndAssertEquals(function() {
3668+    DATEVALUE("Sunday,1992/6/24");
3669+  }, ERRORS.VALUE_ERROR);
3670+  // Leap day on non-leap years
3671+  catchAndAssertEquals(function() {
3672+    DATEVALUE("2005/2/29");
3673+  }, ERRORS.VALUE_ERROR);
3674+  catchAndAssertEquals(function() {
3675+    DATEVALUE("2001/2/29");
3676+  }, ERRORS.VALUE_ERROR);
3677+  // Out of range day for any month
3678+  catchAndAssertEquals(function() {
3679+    DATEVALUE("2005/1/44");
3680+  }, ERRORS.VALUE_ERROR);
3681+  // timestamp test
3682+  assertEquals(DATEVALUE("1992-6-24 10am"), 33779);
3683+  assertEquals(DATEVALUE("1992-6-24 10:10"), 33779);
3684+  assertEquals(DATEVALUE("1992-6-24 10:10am"), 33779);
3685+  assertEquals(DATEVALUE("1992-6-24 10:10:10"), 33779);
3686+  assertEquals(DATEVALUE("1992-6-24 10:10:10am"), 33779);
3687+  assertEquals(DATEVALUE("1992-6-24  10  am"), 33779);
3688+  assertEquals(DATEVALUE("1992-6-24 10: 10 "), 33779);
3689+  assertEquals(DATEVALUE("1992-6-24 10: 10 pm"), 33779);
3690+  assertEquals(DATEVALUE("1992-6-24 10: 10: 10"), 33779);
3691+  assertEquals(DATEVALUE("1992-6-24  10: 10: 10    am   "), 33779);
3692+  assertEquals(DATEVALUE("1992/6/24 00am"), 33779);
3693+  assertEquals(DATEVALUE("1992/06/24 01am "), 33779);
3694+  assertEquals(DATEVALUE("1999/1/01 02pm"), 36161);
3695+  assertEquals(DATEVALUE("2222/1/01 03pm"), 117610);
3696+  assertEquals(DATEVALUE("1902/9/02 12pm"), 976);
3697+  assertEquals(DATEVALUE("1902/9/2 12pm"), 976);
3698+  assertEquals(DATEVALUE("4243/11/3 12pm   "), 856071);
3699+  assertEquals(DATEVALUE("  1992/04/19   12pm   "), 33713);
3700+  assertEquals(DATEVALUE("1992/5/20 01am"), 33744);
3701+  assertEquals(DATEVALUE("1992/6/21  3pm"), 33776);
3702+  assertEquals(DATEVALUE("1992/9/29 3pm"), 33876);
3703+  assertEquals(DATEVALUE("1992/1/24 3pm"), 33627);
3704+  assertEquals(DATEVALUE("1992/12/21 3pm"), 33959);
3705+  assertEquals(DATEVALUE("1992/01/31 3pm"), 33634);
3706+  assertEquals(DATEVALUE("1992/1/13 3pm"), 33616);
3707+  assertEquals(DATEVALUE("2004/2/29 3pm"), 38046);
3708+  assertEquals(DATEVALUE("2004/2/28  3pm "), 38045);
3709+  assertEquals(DATEVALUE("1999/1/13 3pm"), 36173);
3710+  assertEquals(DATEVALUE("1999/01/13 3pm"), 36173);
3711+  assertEquals(DATEVALUE("0999/01/13 3pm"), -329069);
3712+  assertEquals(DATEVALUE("1200/01/13 3pm"), -255656);
3713+  assertEquals(DATEVALUE("0029/01/13 3pm"), 47131);
3714+  assertEquals(DATEVALUE("0030/01/13 3pm"), 10971);
3715+  assertEquals(DATEVALUE("0044/01/13 3pm"), 16084);
3716+  assertEquals(DATEVALUE("0050/01/13 3pm"), 18276);
3717+  assertEquals(DATEVALUE("0097/01/13 00pm"), 35443);
3718+  assertEquals(DATEVALUE("0099/01/13 3pm"), 36173);
3719+  assertEquals(DATEVALUE("0000/01/13 3pm"), 36538);
3720+  assertEquals(DATEVALUE("0101/01/13 3pm"), -657057);
3721+  assertEquals(DATEVALUE("0100/01/13 3pm"), -657422);
3722+  assertEquals(DATEVALUE("100/12/31 3pm"), -657070);
3723+  assertEquals(DATEVALUE("122/11/10 3pm"), -649086);
3724+  assertEquals(DATEVALUE("2222/1/22 3pm"), 117631);
3725+  assertEquals(DATEVALUE("222/1/22 3pm"), -612854);
3726+  catchAndAssertEquals(function() {
3727+    DATEVALUE("2005/2/29 000pm");// Too many digits
3728+  }, ERRORS.VALUE_ERROR);
3729+  catchAndAssertEquals(function() {
3730+    DATEVALUE("2001/2/2 13pm");// Hour out of range
3731+  }, ERRORS.VALUE_ERROR);
3732+  // DAY_MONTHNAME_YEAR, DD(fd)Month(fd)YYYY ===========================================================================
3733+  assertEquals(DATEVALUE("Sun 09 Feb 2017"), 42775);
3734+  assertEquals(DATEVALUE("Sun 9 Feb 2017"), 42775);
3735+  assertEquals(DATEVALUE("Mon 09 Feb 2017"), 42775);
3736+  assertEquals(DATEVALUE("Thursday 09 Feb 2017"), 42775);
3737+  assertEquals(DATEVALUE("Thursday 09 February 2017"), 42775);
3738+  assertEquals(DATEVALUE("Sun 01 September 20"), 44075);
3739+  assertEquals(DATEVALUE("Sun, 09, Feb, 2017"), 42775);
3740+  assertEquals(DATEVALUE("20 May 1992"), 33744);
3741+  assertEquals(DATEVALUE("31 December 100"), -657070);
3742+  assertEquals(DATEVALUE("13 January 0030"), 10971);
3743+  assertEquals(DATEVALUE("13 January 1200"), -255656);
3744+  assertEquals(DATEVALUE("22 January 2222"), 117631);
3745+  assertEquals(DATEVALUE("3 November 4243"), 856071);
3746+  assertEquals(DATEVALUE("13 November 0999"), -328765);
3747+  assertEquals(DATEVALUE("13 November 1200"), -255351);
3748+  assertEquals(DATEVALUE("13 January 0029"), 47131);
3749+  assertEquals(DATEVALUE("13 January 0030"), 10971);
3750+  assertEquals(DATEVALUE("13 January 0044"), 16084);
3751+  assertEquals(DATEVALUE("13 January 0050"), 18276);
3752+  assertEquals(DATEVALUE("13 January 0097"), 35443);
3753+  assertEquals(DATEVALUE("13 January 0099"), 36173);
3754+  assertEquals(DATEVALUE("13 January 0000"), 36538);
3755+  assertEquals(DATEVALUE("13 January 0101"), -657057);
3756+  assertEquals(DATEVALUE("13 January 0100"), -657422);
3757+  assertEquals(DATEVALUE("01 Jan 2017"), 42736);
3758+  assertEquals(DATEVALUE("01 Feb 2017"), 42767);
3759+  assertEquals(DATEVALUE("01 Mar 2017"), 42795);
3760+  assertEquals(DATEVALUE("01 Apr 2017"), 42826);
3761+  assertEquals(DATEVALUE("01 May 2017"), 42856);
3762+  assertEquals(DATEVALUE("01 Jun 2017"), 42887);
3763+  assertEquals(DATEVALUE("01 Jul 2017"), 42917);
3764+  assertEquals(DATEVALUE("01 Aug 2017"), 42948);
3765+  assertEquals(DATEVALUE("01 Sep 2017"), 42979);
3766+  assertEquals(DATEVALUE("01 Oct 2017"), 43009);
3767+  assertEquals(DATEVALUE("01 Nov 2017"), 43040);
3768+  assertEquals(DATEVALUE(" 1 Dec 2017"), 43070);
3769+  assertEquals(DATEVALUE("20 Jan 2015"), 42024);
3770+  assertEquals(DATEVALUE("20 Feb 2015"), 42055);
3771+  assertEquals(DATEVALUE("20 Mar 2015"), 42083);
3772+  assertEquals(DATEVALUE("20 Apr 2015"), 42114);
3773+  assertEquals(DATEVALUE("20 May 2015"), 42144);
3774+  assertEquals(DATEVALUE("20 Jun 2015"), 42175);
3775+  assertEquals(DATEVALUE("20 Jul 2015"), 42205);
3776+  assertEquals(DATEVALUE("20 Aug 2015"), 42236);
3777+  assertEquals(DATEVALUE("20 Sep 2015"), 42267);
3778+  assertEquals(DATEVALUE("20 Oct 2015"), 42297);
3779+  assertEquals(DATEVALUE("20 Nov 2015"), 42328);
3780+  assertEquals(DATEVALUE("20 Dec 2015"), 42358);
3781+  assertEquals(DATEVALUE("29 Feb 2004"), 38046); // leap year, 29th ok
3782+  catchAndAssertEquals(function() {
3783+    DATEVALUE("29 Feb 2001");// not leap year, 29th not ok
3784+  }, ERRORS.VALUE_ERROR);
3785+  catchAndAssertEquals(function() {
3786+    DATEVALUE("32 June 2001");// overload numbers not ok
3787+  }, ERRORS.VALUE_ERROR);
3788+  // delimiter tests
3789+  assertEquals(DATEVALUE("Sun, 09, Feb, 2017"), 42775);
3790+  assertEquals(DATEVALUE("Sun, 09/Feb/2017"), 42775);
3791+  assertEquals(DATEVALUE("09/Feb/2017"), 42775);
3792+  assertEquals(DATEVALUE("09-Feb-2017"), 42775);
3793+  assertEquals(DATEVALUE("09.Feb.2017"), 42775);
3794+  assertEquals(DATEVALUE("09 Feb/2017"), 42775);
3795+  assertEquals(DATEVALUE("09 . Feb . 2017"), 42775);
3796+  // If the delimiters don't match the first one should be a space.
3797+  catchAndAssertEquals(function() {
3798+    DATEVALUE("09.Feb/2017");
3799+  }, ERRORS.VALUE_ERROR);
3800+  // Comma delimiters should be followed by spaces.
3801+  catchAndAssertEquals(function() {
3802+    DATEVALUE("09,Feb,2017");
3803+  }, ERRORS.VALUE_ERROR);
3804+  // timestamp tests
3805+  assertEquals(DATEVALUE("24/June/1992 10am"), 33779);
3806+  assertEquals(DATEVALUE("24/June/1992 10:10"), 33779);
3807+  assertEquals(DATEVALUE("24/June/1992 10:10am"), 33779);
3808+  assertEquals(DATEVALUE("24/June/1992 10:10:10"), 33779);
3809+  assertEquals(DATEVALUE("24/June/1992 10:10:10am"), 33779);
3810+  assertEquals(DATEVALUE("24/June/1992  10  am"), 33779);
3811+  assertEquals(DATEVALUE("24/June/1992 10: 10 "), 33779);
3812+  assertEquals(DATEVALUE("24/June/1992 10: 10 pm"), 33779);
3813+  assertEquals(DATEVALUE("24/June/1992 10: 10: 10"), 33779);
3814+  assertEquals(DATEVALUE("24/June/1992  10: 10: 10    am   "), 33779);
3815+  // MONTHNAME_DAY_YEAR, Month(fd)DD(fd)YYYY, 'Aug 19 2020' ============================================================
3816+  assertEquals(DATEVALUE("Sun Feb 09 2017"), 42775);
3817+  assertEquals(DATEVALUE("Sun Feb 9 2017"), 42775);
3818+  assertEquals(DATEVALUE("Mon Feb 09 2017"), 42775);
3819+  assertEquals(DATEVALUE("Thursday Feb 09 2017"), 42775);
3820+  assertEquals(DATEVALUE("Thursday February 09 2017"), 42775);
3821+  assertEquals(DATEVALUE("Sun September 01 20"), 44075);
3822+  assertEquals(DATEVALUE("Sun, Feb, 09, 2017"), 42775);
3823+  assertEquals(DATEVALUE("May 20 1992"), 33744);
3824+  assertEquals(DATEVALUE("December 31 100"), -657070);
3825+  assertEquals(DATEVALUE("January 13 0030"), 10971);
3826+  assertEquals(DATEVALUE("January 13 1200"), -255656);
3827+  assertEquals(DATEVALUE("January 22 2222"), 117631);
3828+  assertEquals(DATEVALUE("November 3 4243"), 856071);
3829+  assertEquals(DATEVALUE("Feb 29 2004"), 38046); // leap year, 29th ok
3830+  catchAndAssertEquals(function() {
3831+    DATEVALUE("Feb 29 2001");// not leap year, 29th not ok
3832+  }, ERRORS.VALUE_ERROR);
3833+  catchAndAssertEquals(function() {
3834+    DATEVALUE("June 32 2001");// overload numbers not ok
3835+  }, ERRORS.VALUE_ERROR);
3836+  // YEAR_MONTHDIG, YYYY(fd)MM, '1992/06' ==============================================================================
3837+  assertEquals(DATEVALUE("2017/01"), 42736);
3838+  assertEquals(DATEVALUE("2017/02"), 42767);
3839+  assertEquals(DATEVALUE("2017/03"), 42795);
3840+  assertEquals(DATEVALUE("2017/04"), 42826);
3841+  assertEquals(DATEVALUE("2017/05"), 42856);
3842+  assertEquals(DATEVALUE("2017/06"), 42887);
3843+  assertEquals(DATEVALUE("2017/07"), 42917);
3844+  assertEquals(DATEVALUE("2017/08"), 42948);
3845+  assertEquals(DATEVALUE("2017/09"), 42979);
3846+  assertEquals(DATEVALUE("2017/10"), 43009);
3847+  assertEquals(DATEVALUE("2017/11"), 43040);
3848+  assertEquals(DATEVALUE("2017/12"), 43070);
3849+  assertEquals(DATEVALUE("2017/01"), 42736);
3850+  // delimiter tests
3851+  assertEquals(DATEVALUE("Thursday 2017/01"), 42736);
3852+  assertEquals(DATEVALUE("Thursday, 2017/01"), 42736);
3853+  assertEquals(DATEVALUE("2017/01"), 42736);
3854+  assertEquals(DATEVALUE("2017-01"), 42736);
3855+  assertEquals(DATEVALUE("2017. 01"), 42736);
3856+  assertEquals(DATEVALUE("2017 01"), 42736);
3857+  assertEquals(DATEVALUE("2017, 01"), 42736);
3858+  // Comma and period delimiters should be followed by spaces.
3859+  catchAndAssertEquals(function() {
3860+    DATEVALUE("2017,01");
3861+  }, ERRORS.VALUE_ERROR);
3862+  catchAndAssertEquals(function() {
3863+    DATEVALUE("2017.01");
3864+  }, ERRORS.VALUE_ERROR);
3865+  // timestamp test
3866+  assertEquals(DATEVALUE("2017-01 10am"), 42736);
3867+  assertEquals(DATEVALUE("2017-01 10:10"), 42736);
3868+  assertEquals(DATEVALUE("2017-01 10:10am"), 42736);
3869+  assertEquals(DATEVALUE("2017-01 10:10:10"), 42736);
3870+  assertEquals(DATEVALUE("2017-01 10:10:10am"), 42736);
3871+  assertEquals(DATEVALUE("2017-01  10  am"), 42736);
3872+  assertEquals(DATEVALUE("2017-01 10: 10 "), 42736);
3873+  assertEquals(DATEVALUE("2017-01 10: 10 pm"), 42736);
3874+  assertEquals(DATEVALUE("2017-01 10: 10: 10"), 42736);
3875+  assertEquals(DATEVALUE("2017-01  10: 10: 10    am   "), 42736);
3876+  // MONTHDIG_YEAR, MM(fd)YYYY, '06/1992' ================================================================================
3877+  assertEquals(DATEVALUE("01/2017"), 42736);
3878+  assertEquals(DATEVALUE("02/2017"), 42767);
3879+  assertEquals(DATEVALUE("03/2017"), 42795);
3880+  assertEquals(DATEVALUE("04/2017"), 42826);
3881+  assertEquals(DATEVALUE("05/2017"), 42856);
3882+  assertEquals(DATEVALUE("06/2017"), 42887);
3883+  assertEquals(DATEVALUE("07/2017"), 42917);
3884+  assertEquals(DATEVALUE("08/2017"), 42948);
3885+  assertEquals(DATEVALUE("09/2017"), 42979);
3886+  assertEquals(DATEVALUE("10/2017"), 43009);
3887+  assertEquals(DATEVALUE("11/2017"), 43040);
3888+  assertEquals(DATEVALUE("12/2017"), 43070);
3889+  // delimiter tests
3890+  assertEquals(DATEVALUE("Thursday 01/2017"), 42736);
3891+  assertEquals(DATEVALUE("Thursday, 01/2017"), 42736);
3892+  assertEquals(DATEVALUE("1/2017"), 42736);
3893+  assertEquals(DATEVALUE("01-2017"), 42736);
3894+  assertEquals(DATEVALUE("01. 2017"), 42736);
3895+  assertEquals(DATEVALUE("01, 2017"), 42736);
3896+  // Comma, period delimiters should be followed by spaces.
3897+  catchAndAssertEquals(function() {
3898+    DATEVALUE("01,2017");
3899+  }, ERRORS.VALUE_ERROR);
3900+  catchAndAssertEquals(function() {
3901+    DATEVALUE("01.2017");
3902+  }, ERRORS.VALUE_ERROR);
3903+  // 0 is not a month
3904+  catchAndAssertEquals(function() {
3905+    DATEVALUE("0/2017");
3906+  }, ERRORS.VALUE_ERROR);
3907+  // timestamp test
3908+  assertEquals(DATEVALUE("01-2017 10am"), 42736);
3909+  assertEquals(DATEVALUE("01-2017 10:10"), 42736);
3910+  assertEquals(DATEVALUE("01-2017 10:10am"), 42736);
3911+  assertEquals(DATEVALUE("01-2017 10:10:10"), 42736);
3912+  assertEquals(DATEVALUE("01-2017 10:10:10am"), 42736);
3913+  assertEquals(DATEVALUE("01-2017  10  am"), 42736);
3914+  assertEquals(DATEVALUE("01-2017 10: 10 "), 42736);
3915+  assertEquals(DATEVALUE("01-2017 10: 10 pm"), 42736);
3916+  assertEquals(DATEVALUE("01-2017 10: 10: 10"), 42736);
3917+  assertEquals(DATEVALUE("01-2017  10: 10: 10    am   "), 42736);
3918+  // YEAR_MONTHNAME, YYYY(fd)Month, '1992/Aug' =========================================================================
3919+  assertEquals(DATEVALUE("2017 January"), 42736);
3920+  assertEquals(DATEVALUE("2017 February"), 42767);
3921+  assertEquals(DATEVALUE("2017 March"), 42795);
3922+  assertEquals(DATEVALUE("2017 April"), 42826);
3923+  assertEquals(DATEVALUE("2017 May"), 42856);
3924+  assertEquals(DATEVALUE("2017 June"), 42887);
3925+  assertEquals(DATEVALUE("2017 July"), 42917);
3926+  assertEquals(DATEVALUE("2017 August"), 42948);
3927+  assertEquals(DATEVALUE("2017 September"), 42979);
3928+  assertEquals(DATEVALUE("2017 October"), 43009);
3929+  assertEquals(DATEVALUE("2017 November"), 43040);
3930+  assertEquals(DATEVALUE("2017 December"), 43070);
3931+  // delimiter tests
3932+  assertEquals(DATEVALUE("Thursday 2017 January"), 42736);
3933+  assertEquals(DATEVALUE("Thursday, 2017 January"), 42736);
3934+  assertEquals(DATEVALUE("2017/January"), 42736);
3935+  assertEquals(DATEVALUE("2017-January"), 42736);
3936+  assertEquals(DATEVALUE("2017. January"), 42736);
3937+  assertEquals(DATEVALUE("2017, January"), 42736);
3938+  // Comma delimiters should be followed by spaces.
3939+  catchAndAssertEquals(function() {
3940+    DATEVALUE("2017,January");
3941+  }, ERRORS.VALUE_ERROR);
3942+  catchAndAssertEquals(function() {
3943+    DATEVALUE("2017.January");
3944+  }, ERRORS.VALUE_ERROR);
3945+  // timestamp test
3946+  assertEquals(DATEVALUE("2017-January 10am"), 42736);
3947+  assertEquals(DATEVALUE("2017-January 10:10"), 42736);
3948+  assertEquals(DATEVALUE("2017-January 10:10am"), 42736);
3949+  assertEquals(DATEVALUE("2017-January 10:10:10"), 42736);
3950+  assertEquals(DATEVALUE("2017-January 10:10:10am"), 42736);
3951+  assertEquals(DATEVALUE("2017-January  10  am"), 42736);
3952+  assertEquals(DATEVALUE("2017-January 10: 10 "), 42736);
3953+  assertEquals(DATEVALUE("2017-January 10: 10 pm"), 42736);
3954+  assertEquals(DATEVALUE("2017-January 10: 10: 10"), 42736);
3955+  assertEquals(DATEVALUE("2017-January  10: 10: 10    am   "), 42736);
3956+  // MONTHNAME_YEAR, Month(fd)YYYY, 'Aug 1992' =========================================================================
3957+  assertEquals(DATEVALUE("January 2017"), 42736);
3958+  assertEquals(DATEVALUE("February 2017"), 42767);
3959+  assertEquals(DATEVALUE("March 2017"), 42795);
3960+  assertEquals(DATEVALUE("April 2017"), 42826);
3961+  assertEquals(DATEVALUE("May 2017"), 42856);
3962+  assertEquals(DATEVALUE("June 2017"), 42887);
3963+  assertEquals(DATEVALUE("July 2017"), 42917);
3964+  assertEquals(DATEVALUE("August 2017"), 42948);
3965+  assertEquals(DATEVALUE("September 2017"), 42979);
3966+  assertEquals(DATEVALUE("October 2017"), 43009);
3967+  assertEquals(DATEVALUE("November 2017"), 43040);
3968+  assertEquals(DATEVALUE("December 2017"), 43070);
3969+  assertEquals(DATEVALUE("  Feb    2017  "), 42767);
3970+  assertEquals(DATEVALUE("Feb-2017"), 42767);
3971+  assertEquals(DATEVALUE("Feb. 2017"), 42767);
3972+  assertEquals(DATEVALUE("Feb/2017"), 42767);
3973+  assertEquals(DATEVALUE("Feb    .    2017"), 42767);
3974+  assertEquals(DATEVALUE("Feb -      2017"), 42767);
3975+  assertEquals(DATEVALUE("January 0030"), 10959);
3976+  assertEquals(DATEVALUE("November 4243"), 856069);
3977+  assertEquals(DATEVALUE("December 0100"), -657100);
3978+  assertEquals(DATEVALUE("Jan 2017"), 42736);
3979+  assertEquals(DATEVALUE("Feb 2017"), 42767);
3980+  assertEquals(DATEVALUE("Mar 2017"), 42795);
3981+  assertEquals(DATEVALUE("Apr 2017"), 42826);
3982+  assertEquals(DATEVALUE("May 2017"), 42856);
3983+  assertEquals(DATEVALUE("Jun 2017"), 42887);
3984+  assertEquals(DATEVALUE("Jul 2017"), 42917);
3985+  assertEquals(DATEVALUE("Aug 2017"), 42948);
3986+  assertEquals(DATEVALUE("Sep 2017"), 42979);
3987+  assertEquals(DATEVALUE("Oct 2017"), 43009);
3988+  assertEquals(DATEVALUE("Nov 2017"), 43040);
3989+  assertEquals(DATEVALUE("Dec 2017"), 43070);
3990+  assertEquals(DATEVALUE("Feb, 2017"), 42767);
3991+  catchAndAssertEquals(function() {
3992+    DATEVALUE("December 100");// need 4 digits
3993+  }, ERRORS.VALUE_ERROR);
3994+  catchAndAssertEquals(function() {
3995+    DATEVALUE("Dec.20");// need space after if using period
3996+  }, ERRORS.VALUE_ERROR);
3997+  // delimiter tests
3998+  assertEquals(DATEVALUE("Thursday January 2017"), 42736);
3999+  assertEquals(DATEVALUE("Thursday, January 2017"), 42736);
4000+  assertEquals(DATEVALUE("January/2017"), 42736);
4001+  assertEquals(DATEVALUE("January-2017"), 42736);
4002+  assertEquals(DATEVALUE("January. 2017"), 42736);
4003+  assertEquals(DATEVALUE("January, 2017"), 42736);
4004+  // Comma, period delimiters should be followed by spaces.
4005+  catchAndAssertEquals(function() {
4006+    DATEVALUE("January,2017");
4007+  }, ERRORS.VALUE_ERROR);
4008+  catchAndAssertEquals(function() {
4009+    DATEVALUE("January.2017");
4010+  }, ERRORS.VALUE_ERROR);
4011+  // timestamp test
4012+  assertEquals(DATEVALUE("January-2017 10am"), 42736);
4013+  assertEquals(DATEVALUE("January-2017 10:10"), 42736);
4014+  assertEquals(DATEVALUE("January-2017 10:10am"), 42736);
4015+  assertEquals(DATEVALUE("January-2017 10:10:10"), 42736);
4016+  assertEquals(DATEVALUE("January-2017 10:10:10am"), 42736);
4017+  assertEquals(DATEVALUE("January-2017  10  am"), 42736);
4018+  assertEquals(DATEVALUE("January-2017 10: 10 "), 42736);
4019+  assertEquals(DATEVALUE("January-2017 10: 10 pm"), 42736);
4020+  assertEquals(DATEVALUE("January-2017 10: 10: 10"), 42736);
4021+  assertEquals(DATEVALUE("January-2017  10: 10: 10    am  "), 42736);
4022+});
4023diff --git a/tests/Formulas/DateFormulasTestTimeOverride.ts b/tests/Formulas/DateFormulasTestTimeOverride.ts
4024index 0dff4be..bac084a 100644
4025--- a/tests/Formulas/DateFormulasTestTimeOverride.ts
4026+++ b/tests/Formulas/DateFormulasTestTimeOverride.ts
4027@@ -6,14 +6,14 @@ import {
4028 import * as ERRORS from "../../src/Errors";
4029 import {
4030   assertEquals,
4031-  catchAndAssertEquals
4032+  catchAndAssertEquals,
4033+  test
4034 } from "../utils/Asserts"
4035 
4036 
4037 // WARNING: Locking in Date by overriding prototypes.
4038 function lockDate(year, month, day, hour, minute, second) {
4039-  // WARNING: Locking in Date by overriding prototypes.
4040-  var d = new Date(year, month, day, hour, minute, second); // Always "Dec 10 2012 04:55:04"
4041+  var d = new Date(year, month, day, hour, minute, second);
4042   Date.prototype.constructor = function () {
4043     return d;
4044   };
4045@@ -22,29 +22,31 @@ function lockDate(year, month, day, hour, minute, second) {
4046   };
4047 }
4048 
4049-// Test NOW
4050-lockDate(2012, 11, 10, 4, 55, 4);
4051-assertEquals(NOW().toNumber(), DATEVALUE("Dec 10 2012"));
4052-lockDate(1999, 11, 10, 4, 55, 4);
4053-assertEquals(NOW().toNumber(), DATEVALUE("Dec 10 1999"));
4054-lockDate(1999, 9, 22, 4, 55, 4);
4055-assertEquals(NOW().toNumber(), DATEVALUE("Oct 22 1999"));
4056-lockDate(1944, 1, 2, 1, 11, 55);
4057-assertEquals(NOW().toNumber(), DATEVALUE("Feb 2 1944"));
4058-catchAndAssertEquals(function() {
4059-  NOW(12);
4060-}, ERRORS.NA_ERROR);
4061+test("NOW", function(){
4062+  lockDate(2012, 11, 10, 4, 55, 4);
4063+  assertEquals(NOW().toNumber(), DATEVALUE("Dec 10 2012"));
4064+  lockDate(1999, 11, 10, 4, 55, 4);
4065+  assertEquals(NOW().toNumber(), DATEVALUE("Dec 10 1999"));
4066+  lockDate(1999, 9, 22, 4, 55, 4);
4067+  assertEquals(NOW().toNumber(), DATEVALUE("Oct 22 1999"));
4068+  lockDate(1944, 1, 2, 1, 11, 55);
4069+  assertEquals(NOW().toNumber(), DATEVALUE("Feb 2 1944"));
4070+  catchAndAssertEquals(function() {
4071+    NOW(12);
4072+  }, ERRORS.NA_ERROR);
4073+});
4074 
4075 
4076-// Test TODAY
4077-lockDate(2012, 11, 10, 4, 55, 4);
4078-assertEquals(TODAY().toNumber(), DATEVALUE("Dec 10 2012"));
4079-lockDate(1999, 11, 10, 4, 55, 4);
4080-assertEquals(TODAY().toNumber(), DATEVALUE("Dec 10 1999"));
4081-lockDate(1999, 9, 22, 4, 55, 4);
4082-assertEquals(TODAY().toNumber(), DATEVALUE("Oct 22 1999"));
4083-lockDate(1944, 1, 2, 1, 11, 55);
4084-assertEquals(TODAY().toNumber(), DATEVALUE("Feb 2 1944"));
4085-catchAndAssertEquals(function() {
4086-  TODAY(12);
4087-}, ERRORS.NA_ERROR);
4088\ No newline at end of file
4089+test("TODAY", function(){
4090+  lockDate(2012, 11, 10, 4, 55, 4);
4091+  assertEquals(TODAY().toNumber(), DATEVALUE("Dec 10 2012"));
4092+  lockDate(1999, 11, 10, 4, 55, 4);
4093+  assertEquals(TODAY().toNumber(), DATEVALUE("Dec 10 1999"));
4094+  lockDate(1999, 9, 22, 4, 55, 4);
4095+  assertEquals(TODAY().toNumber(), DATEVALUE("Oct 22 1999"));
4096+  lockDate(1944, 1, 2, 1, 11, 55);
4097+  assertEquals(TODAY().toNumber(), DATEVALUE("Feb 2 1944"));
4098+  catchAndAssertEquals(function() {
4099+    TODAY(12);
4100+  }, ERRORS.NA_ERROR);
4101+});
4102diff --git a/tests/Formulas/EngineeringTest.ts b/tests/Formulas/EngineeringTest.ts
4103index 138d6d5..773f705 100644
4104--- a/tests/Formulas/EngineeringTest.ts
4105+++ b/tests/Formulas/EngineeringTest.ts
4106@@ -10,209 +10,218 @@ import {
4107 import * as ERRORS from "../../src/Errors";
4108 import {
4109   assertEquals,
4110-  catchAndAssertEquals
4111+  catchAndAssertEquals,
4112+  test
4113 } from "../utils/Asserts";
4114 
4115 
4116-// Test BIN2DEC
4117-assertEquals(BIN2DEC("1010101010"), -342);
4118-assertEquals(BIN2DEC("10"), 2);
4119-assertEquals(BIN2DEC(["10", "str"]), 2);
4120-catchAndAssertEquals(function() {
4121-  BIN2DEC(false);
4122-}, ERRORS.VALUE_ERROR);
4123-catchAndAssertEquals(function() {
4124-  BIN2DEC("str");
4125-}, ERRORS.NUM_ERROR);
4126-catchAndAssertEquals(function() {
4127-  BIN2DEC();
4128-}, ERRORS.NA_ERROR);
4129-catchAndAssertEquals(function() {
4130-  BIN2DEC("10", "10");
4131-}, ERRORS.NA_ERROR);
4132+test("BIN2DEC", function(){
4133+  assertEquals(BIN2DEC("1010101010"), -342);
4134+  assertEquals(BIN2DEC("10"), 2);
4135+  assertEquals(BIN2DEC(["10", "str"]), 2);
4136+  catchAndAssertEquals(function() {
4137+    BIN2DEC(false);
4138+  }, ERRORS.VALUE_ERROR);
4139+  catchAndAssertEquals(function() {
4140+    BIN2DEC("str");
4141+  }, ERRORS.NUM_ERROR);
4142+  catchAndAssertEquals(function() {
4143+    BIN2DEC();
4144+  }, ERRORS.NA_ERROR);
4145+  catchAndAssertEquals(function() {
4146+    BIN2DEC("10", "10");
4147+  }, ERRORS.NA_ERROR);
4148+});
4149 
4150 
4151-// Test BIN2HEX
4152-assertEquals(BIN2HEX("1010101010"), "FFFFFFFEAA");
4153-assertEquals(BIN2HEX("10"), "2");
4154-assertEquals(BIN2HEX("10101010"), "AA");
4155-assertEquals(BIN2HEX("10101010", 4), "00AA");
4156-assertEquals(BIN2HEX(["10101010"], [4]), "00AA");
4157-catchAndAssertEquals(function() {
4158-  BIN2HEX("10101010", 22);
4159-}, ERRORS.NUM_ERROR);
4160-catchAndAssertEquals(function() {
4161-  BIN2HEX(false);
4162-}, ERRORS.VALUE_ERROR);
4163-catchAndAssertEquals(function() {
4164-  BIN2HEX("10101010", 0);
4165-}, ERRORS.NUM_ERROR);
4166-catchAndAssertEquals(function() {
4167-  BIN2DEC("str");
4168-}, ERRORS.NUM_ERROR);
4169-catchAndAssertEquals(function() {
4170-  BIN2DEC();
4171-}, ERRORS.NA_ERROR);
4172-catchAndAssertEquals(function() {
4173-  BIN2DEC("10", 4, 4);
4174-}, ERRORS.NA_ERROR);
4175+test("BIN2HEX", function(){
4176+  assertEquals(BIN2HEX("1010101010"), "FFFFFFFEAA");
4177+  assertEquals(BIN2HEX("10"), "2");
4178+  assertEquals(BIN2HEX("10101010"), "AA");
4179+  assertEquals(BIN2HEX("10101010", 4), "00AA");
4180+  assertEquals(BIN2HEX(["10101010"], [4]), "00AA");
4181+  catchAndAssertEquals(function() {
4182+    BIN2HEX("10101010", 22);
4183+  }, ERRORS.NUM_ERROR);
4184+  catchAndAssertEquals(function() {
4185+    BIN2HEX(false);
4186+  }, ERRORS.VALUE_ERROR);
4187+  catchAndAssertEquals(function() {
4188+    BIN2HEX("10101010", 0);
4189+  }, ERRORS.NUM_ERROR);
4190+  catchAndAssertEquals(function() {
4191+    BIN2DEC("str");
4192+  }, ERRORS.NUM_ERROR);
4193+  catchAndAssertEquals(function() {
4194+    BIN2DEC();
4195+  }, ERRORS.NA_ERROR);
4196+  catchAndAssertEquals(function() {
4197+    BIN2DEC("10", 4, 4);
4198+  }, ERRORS.NA_ERROR);
4199 
4200+});
4201 
4202-// Test BIN2OCT
4203-assertEquals(BIN2OCT("1010101010"), "7777777252");
4204-assertEquals(BIN2OCT("10"), "2");
4205-assertEquals(BIN2OCT("100"), "4");
4206-assertEquals(BIN2OCT("10101010"), "252");
4207-assertEquals(BIN2OCT("10101010", 4), "252");
4208-assertEquals(BIN2OCT(["10101010"], [4]), "252");
4209-catchAndAssertEquals(function() {
4210-  BIN2OCT("10101010", 22);
4211-}, ERRORS.NUM_ERROR);
4212-catchAndAssertEquals(function() {
4213-  BIN2OCT(false);
4214-}, ERRORS.VALUE_ERROR);
4215-catchAndAssertEquals(function() {
4216-  BIN2OCT("10101010", 0);
4217-}, ERRORS.NUM_ERROR);
4218-catchAndAssertEquals(function() {
4219-  BIN2OCT("str");
4220-}, ERRORS.NUM_ERROR);
4221-catchAndAssertEquals(function() {
4222-  BIN2OCT();
4223-}, ERRORS.NA_ERROR);
4224-catchAndAssertEquals(function() {
4225-  BIN2OCT("10", 4, 4);
4226-}, ERRORS.NA_ERROR);
4227 
4228+test("BIN2OCT", function(){
4229+  assertEquals(BIN2OCT("1010101010"), "7777777252");
4230+  assertEquals(BIN2OCT("10"), "2");
4231+  assertEquals(BIN2OCT("100"), "4");
4232+  assertEquals(BIN2OCT("10101010"), "252");
4233+  assertEquals(BIN2OCT("10101010", 4), "252");
4234+  assertEquals(BIN2OCT(["10101010"], [4]), "252");
4235+  catchAndAssertEquals(function() {
4236+    BIN2OCT("10101010", 22);
4237+  }, ERRORS.NUM_ERROR);
4238+  catchAndAssertEquals(function() {
4239+    BIN2OCT(false);
4240+  }, ERRORS.VALUE_ERROR);
4241+  catchAndAssertEquals(function() {
4242+    BIN2OCT("10101010", 0);
4243+  }, ERRORS.NUM_ERROR);
4244+  catchAndAssertEquals(function() {
4245+    BIN2OCT("str");
4246+  }, ERRORS.NUM_ERROR);
4247+  catchAndAssertEquals(function() {
4248+    BIN2OCT();
4249+  }, ERRORS.NA_ERROR);
4250+  catchAndAssertEquals(function() {
4251+    BIN2OCT("10", 4, 4);
4252+  }, ERRORS.NA_ERROR);
4253+});
4254 
4255-// Test DEC2BIN
4256-assertEquals(DEC2BIN([100]), "1100100");
4257-assertEquals(DEC2BIN(100), "1100100");
4258-assertEquals(DEC2BIN(22), "10110");
4259-assertEquals(DEC2BIN(22.11), "10110");
4260-assertEquals(DEC2BIN(22.77), "10110");
4261-assertEquals(DEC2BIN("22.77"), "10110");
4262-assertEquals(DEC2BIN(100, 8), "01100100");
4263-assertEquals(DEC2BIN([100], [8]), "01100100");
4264-assertEquals(DEC2BIN(100, 7), "1100100");
4265-assertEquals(DEC2BIN(100, 10), "0001100100");
4266-assertEquals(DEC2BIN(-100), "1110011100");
4267-assertEquals(DEC2BIN("-22.77"), "1111101010");
4268-assertEquals(DEC2BIN(-22.11), "1111101010");
4269-assertEquals(DEC2BIN(-22), "1111101010");
4270-assertEquals(DEC2BIN(false), "0");
4271-assertEquals(DEC2BIN(true), "1");
4272-catchAndAssertEquals(function() {
4273-  DEC2BIN(100, 0);
4274-}, ERRORS.NUM_ERROR);
4275-catchAndAssertEquals(function() {
4276-  DEC2BIN(513, 10);
4277-}, ERRORS.NUM_ERROR);
4278-catchAndAssertEquals(function() {
4279-  DEC2BIN(100, 100, 10);
4280-}, ERRORS.NA_ERROR);
4281-catchAndAssertEquals(function() {
4282-  DEC2BIN();
4283-}, ERRORS.NA_ERROR);
4284-catchAndAssertEquals(function() {
4285-  DEC2BIN("str");
4286-}, ERRORS.VALUE_ERROR);
4287 
4288+test("DEC2BIN", function(){
4289+  assertEquals(DEC2BIN([100]), "1100100");
4290+  assertEquals(DEC2BIN(100), "1100100");
4291+  assertEquals(DEC2BIN(22), "10110");
4292+  assertEquals(DEC2BIN(22.11), "10110");
4293+  assertEquals(DEC2BIN(22.77), "10110");
4294+  assertEquals(DEC2BIN("22.77"), "10110");
4295+  assertEquals(DEC2BIN(100, 8), "01100100");
4296+  assertEquals(DEC2BIN([100], [8]), "01100100");
4297+  assertEquals(DEC2BIN(100, 7), "1100100");
4298+  assertEquals(DEC2BIN(100, 10), "0001100100");
4299+  assertEquals(DEC2BIN(-100), "1110011100");
4300+  assertEquals(DEC2BIN("-22.77"), "1111101010");
4301+  assertEquals(DEC2BIN(-22.11), "1111101010");
4302+  assertEquals(DEC2BIN(-22), "1111101010");
4303+  assertEquals(DEC2BIN(false), "0");
4304+  assertEquals(DEC2BIN(true), "1");
4305+  catchAndAssertEquals(function() {
4306+    DEC2BIN(100, 0);
4307+  }, ERRORS.NUM_ERROR);
4308+  catchAndAssertEquals(function() {
4309+    DEC2BIN(513, 10);
4310+  }, ERRORS.NUM_ERROR);
4311+  catchAndAssertEquals(function() {
4312+    DEC2BIN(100, 100, 10);
4313+  }, ERRORS.NA_ERROR);
4314+  catchAndAssertEquals(function() {
4315+    DEC2BIN();
4316+  }, ERRORS.NA_ERROR);
4317+  catchAndAssertEquals(function() {
4318+    DEC2BIN("str");
4319+  }, ERRORS.VALUE_ERROR);
4320+});
4321 
4322-// Test DEC2HEX
4323-assertEquals(DEC2HEX([100]), "64");
4324-assertEquals(DEC2HEX(100), "64");
4325-assertEquals(DEC2HEX(22), "16");
4326-assertEquals(DEC2HEX(22.11), "16");
4327-assertEquals(DEC2HEX(22.77), "16");
4328-assertEquals(DEC2HEX("22.77"), "16");
4329-assertEquals(DEC2HEX(100, 8), "00000064");
4330-assertEquals(DEC2HEX([100], [8]), "00000064");
4331-assertEquals(DEC2HEX(100, 7), "0000064");
4332-assertEquals(DEC2HEX(100, 10), "0000000064");
4333-assertEquals(DEC2HEX(-100), "FFFFFFFF9C");
4334-assertEquals(DEC2HEX("-22.77"), "FFFFFFFFEA");
4335-assertEquals(DEC2HEX(-22.11), "FFFFFFFFEA");
4336-assertEquals(DEC2HEX(-22), "FFFFFFFFEA");
4337-assertEquals(DEC2HEX(false), "0");
4338-assertEquals(DEC2HEX(true), "1");
4339-catchAndAssertEquals(function() {
4340-  DEC2HEX(100, 0);
4341-}, ERRORS.NUM_ERROR);
4342-catchAndAssertEquals(function() {
4343-  DEC2HEX(549755813889, 10);
4344-}, ERRORS.NUM_ERROR);
4345-catchAndAssertEquals(function() {
4346-  DEC2HEX(54975581, -10);
4347-}, ERRORS.NUM_ERROR);
4348-catchAndAssertEquals(function() {
4349-  DEC2HEX(100, 100, 10);
4350-}, ERRORS.NA_ERROR);
4351-catchAndAssertEquals(function() {
4352-  DEC2HEX();
4353-}, ERRORS.NA_ERROR);
4354-catchAndAssertEquals(function() {
4355-  DEC2HEX("str");
4356-}, ERRORS.VALUE_ERROR);
4357 
4358+test("DEC2HEX", function(){
4359+  assertEquals(DEC2HEX([100]), "64");
4360+  assertEquals(DEC2HEX(100), "64");
4361+  assertEquals(DEC2HEX(22), "16");
4362+  assertEquals(DEC2HEX(22.11), "16");
4363+  assertEquals(DEC2HEX(22.77), "16");
4364+  assertEquals(DEC2HEX("22.77"), "16");
4365+  assertEquals(DEC2HEX(100, 8), "00000064");
4366+  assertEquals(DEC2HEX([100], [8]), "00000064");
4367+  assertEquals(DEC2HEX(100, 7), "0000064");
4368+  assertEquals(DEC2HEX(100, 10), "0000000064");
4369+  assertEquals(DEC2HEX(-100), "FFFFFFFF9C");
4370+  assertEquals(DEC2HEX("-22.77"), "FFFFFFFFEA");
4371+  assertEquals(DEC2HEX(-22.11), "FFFFFFFFEA");
4372+  assertEquals(DEC2HEX(-22), "FFFFFFFFEA");
4373+  assertEquals(DEC2HEX(false), "0");
4374+  assertEquals(DEC2HEX(true), "1");
4375+  catchAndAssertEquals(function() {
4376+    DEC2HEX(100, 0);
4377+  }, ERRORS.NUM_ERROR);
4378+  catchAndAssertEquals(function() {
4379+    DEC2HEX(549755813889, 10);
4380+  }, ERRORS.NUM_ERROR);
4381+  catchAndAssertEquals(function() {
4382+    DEC2HEX(54975581, -10);
4383+  }, ERRORS.NUM_ERROR);
4384+  catchAndAssertEquals(function() {
4385+    DEC2HEX(100, 100, 10);
4386+  }, ERRORS.NA_ERROR);
4387+  catchAndAssertEquals(function() {
4388+    DEC2HEX();
4389+  }, ERRORS.NA_ERROR);
4390+  catchAndAssertEquals(function() {
4391+    DEC2HEX("str");
4392+  }, ERRORS.VALUE_ERROR);
4393+});
4394 
4395-// Test DEC2OCT
4396-assertEquals(DEC2OCT([100]), "144");
4397-assertEquals(DEC2OCT(100), "144");
4398-assertEquals(DEC2OCT(22), "26");
4399-assertEquals(DEC2OCT(22.11), "26");
4400-assertEquals(DEC2OCT(22.77), "26");
4401-assertEquals(DEC2OCT("22.77"), "26");
4402-assertEquals(DEC2OCT(100, 8), "00000144");
4403-assertEquals(DEC2OCT([100], [8]), "00000144");
4404-assertEquals(DEC2OCT(100, 7), "0000144");
4405-assertEquals(DEC2OCT(100, 10), "0000000144");
4406-assertEquals(DEC2OCT(-100), "7777777634");
4407-assertEquals(DEC2OCT("-22.77"), "7777777752");
4408-assertEquals(DEC2OCT(-22.11), "7777777752");
4409-assertEquals(DEC2OCT(-22), "7777777752");
4410-assertEquals(DEC2OCT(false), "0");
4411-assertEquals(DEC2OCT(true), "1");
4412-catchAndAssertEquals(function() {
4413-  DEC2OCT(100, 0);
4414-}, ERRORS.NUM_ERROR);
4415-catchAndAssertEquals(function() {
4416-  DEC2OCT(536870913, 10);
4417-}, ERRORS.NUM_ERROR);
4418-catchAndAssertEquals(function() {
4419-  DEC2OCT(536870910, -10);
4420-}, ERRORS.NUM_ERROR);
4421-catchAndAssertEquals(function() {
4422-  DEC2OCT(100, 100, 10);
4423-}, ERRORS.NA_ERROR);
4424-catchAndAssertEquals(function() {
4425-  DEC2OCT();
4426-}, ERRORS.NA_ERROR);
4427-catchAndAssertEquals(function() {
4428-  DEC2OCT("str");
4429-}, ERRORS.VALUE_ERROR);
4430 
4431+test("DEC2OCT", function(){
4432+  assertEquals(DEC2OCT([100]), "144");
4433+  assertEquals(DEC2OCT(100), "144");
4434+  assertEquals(DEC2OCT(22), "26");
4435+  assertEquals(DEC2OCT(22.11), "26");
4436+  assertEquals(DEC2OCT(22.77), "26");
4437+  assertEquals(DEC2OCT("22.77"), "26");
4438+  assertEquals(DEC2OCT(100, 8), "00000144");
4439+  assertEquals(DEC2OCT([100], [8]), "00000144");
4440+  assertEquals(DEC2OCT(100, 7), "0000144");
4441+  assertEquals(DEC2OCT(100, 10), "0000000144");
4442+  assertEquals(DEC2OCT(-100), "7777777634");
4443+  assertEquals(DEC2OCT("-22.77"), "7777777752");
4444+  assertEquals(DEC2OCT(-22.11), "7777777752");
4445+  assertEquals(DEC2OCT(-22), "7777777752");
4446+  assertEquals(DEC2OCT(false), "0");
4447+  assertEquals(DEC2OCT(true), "1");
4448+  catchAndAssertEquals(function() {
4449+    DEC2OCT(100, 0);
4450+  }, ERRORS.NUM_ERROR);
4451+  catchAndAssertEquals(function() {
4452+    DEC2OCT(536870913, 10);
4453+  }, ERRORS.NUM_ERROR);
4454+  catchAndAssertEquals(function() {
4455+    DEC2OCT(536870910, -10);
4456+  }, ERRORS.NUM_ERROR);
4457+  catchAndAssertEquals(function() {
4458+    DEC2OCT(100, 100, 10);
4459+  }, ERRORS.NA_ERROR);
4460+  catchAndAssertEquals(function() {
4461+    DEC2OCT();
4462+  }, ERRORS.NA_ERROR);
4463+  catchAndAssertEquals(function() {
4464+    DEC2OCT("str");
4465+  }, ERRORS.VALUE_ERROR);
4466+});
4467 
4468-// Test DELTA
4469-assertEquals(DELTA(2, 2), 1);
4470-assertEquals(DELTA(2, 1), 0);
4471-assertEquals(DELTA(2), 0);
4472-assertEquals(DELTA("", ""), 1);
4473-assertEquals(DELTA(false), 1);
4474-assertEquals(DELTA(true), 0);
4475-assertEquals(DELTA(2.2, 2.1), 0);
4476-assertEquals(DELTA(1, true), 1);
4477-assertEquals(DELTA(0, false), 1);
4478-assertEquals(DELTA(true, true), 1);
4479-catchAndAssertEquals(function() {
4480-  DELTA("str");
4481-}, ERRORS.VALUE_ERROR);
4482-catchAndAssertEquals(function() {
4483-  DELTA("n", "n");
4484-}, ERRORS.VALUE_ERROR);
4485-catchAndAssertEquals(function() {
4486-  DELTA();
4487-}, ERRORS.NA_ERROR);
4488-catchAndAssertEquals(function() {
4489-  DELTA(1, 2, 3);
4490-}, ERRORS.NA_ERROR);
4491\ No newline at end of file
4492+
4493+test("DELTA", function(){
4494+  assertEquals(DELTA(2, 2), 1);
4495+  assertEquals(DELTA(2, 1), 0);
4496+  assertEquals(DELTA(2), 0);
4497+  assertEquals(DELTA("", ""), 1);
4498+  assertEquals(DELTA(false), 1);
4499+  assertEquals(DELTA(true), 0);
4500+  assertEquals(DELTA(2.2, 2.1), 0);
4501+  assertEquals(DELTA(1, true), 1);
4502+  assertEquals(DELTA(0, false), 1);
4503+  assertEquals(DELTA(true, true), 1);
4504+  catchAndAssertEquals(function() {
4505+    DELTA("str");
4506+  }, ERRORS.VALUE_ERROR);
4507+  catchAndAssertEquals(function() {
4508+    DELTA("n", "n");
4509+  }, ERRORS.VALUE_ERROR);
4510+  catchAndAssertEquals(function() {
4511+    DELTA();
4512+  }, ERRORS.NA_ERROR);
4513+  catchAndAssertEquals(function() {
4514+    DELTA(1, 2, 3);
4515+  }, ERRORS.NA_ERROR);
4516+});
4517diff --git a/tests/Formulas/FinancialTest.ts b/tests/Formulas/FinancialTest.ts
4518index 829d83f..6244a23 100644
4519--- a/tests/Formulas/FinancialTest.ts
4520+++ b/tests/Formulas/FinancialTest.ts
4521@@ -18,218 +18,229 @@ import {
4522 import * as ERRORS from "../../src/Errors";
4523 import {
4524   assertEquals,
4525-  catchAndAssertEquals
4526+  catchAndAssertEquals,
4527+  test
4528 } from "../utils/Asserts";
4529 
4530-// Test ACCRINT
4531-assertEquals(ACCRINT(DATE(2000, 1, 1), DATE(2000, 2, 1), DATE(2002, 12, 31), 0.05, 100, 4), 14.98631386861314);
4532-assertEquals(ACCRINT(DATE(2011, 1, 1), DATE(2011, 2, 1), DATE(2014, 7, 1), 0.1, 1000, 1, 0), 350);
4533-assertEquals(ACCRINT(DATE(2001, 1, 1), DATE(2011, 2, 1), DATE(2014, 7, 1), 0.1, 1000, 2, 1), 1349.6186192059456);
4534-assertEquals(ACCRINT(39508, 39691, 39569, 0.1, 1000, 2, 0), 16.666666666666664);
4535-assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 0), 2737.5);
4536-assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 1), 2737.8507871321012); // ms: 2787.087912 (1.76% err), gs: 2737.637363 (0.007% err)
4537-assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 2), 2777.777777777778); // ms, gs: 2737.777778 (1.46% err)
4538-assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 3), 2739.72602739726); //ms, gs: 2737.60274 (0.077% err)
4539-assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 4), 2737.5);
4540-assertEquals(ACCRINT(1, 44, "1461", "0.1", [1000], [1]), 400);
4541-assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1), 400);
4542-assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 0), 400);
4543-assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 1), 400);
4544-assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 2), 405.55555555555554); // gs: 400
4545-assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 3), 400); // gs: 399.6575342
4546-assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 4), 400);
4547-catchAndAssertEquals(function() {
4548-  ACCRINT(1, -1, 100, 0.1, 1000, 1, 4);
4549-}, ERRORS.NUM_ERROR);
4550-catchAndAssertEquals(function() {
4551-  ACCRINT(100, 2, 1, 0.1, 1000, 1, 4);
4552-}, ERRORS.NUM_ERROR);
4553-catchAndAssertEquals(function() {
4554-  ACCRINT(100, 2, 1, 0.1, 1000);
4555-}, ERRORS.NA_ERROR);
4556-catchAndAssertEquals(function() {
4557-  ACCRINT(1, 2, 1461, 0.1, 1000, 1, 1, 1);
4558-}, ERRORS.NA_ERROR);
4559-
4560-
4561-// Test CUMPRINC
4562-assertEquals(CUMPRINC(0.12, 12, 100, 1, 5, false), -26.324171373034403);
4563-assertEquals(CUMPRINC(0.12, 12, 100, 1, 5, 0), -26.324171373034403);
4564-assertEquals(CUMPRINC(0.12, 12, 100, 1, 5, true), -34.21801015449499);
4565-assertEquals(CUMPRINC(0.12, 12, 100, 1, 5, -11), -34.21801015449499);
4566-catchAndAssertEquals(function() {
4567-  CUMPRINC(0.12, 12, 100, 1, 5, []);
4568-}, ERRORS.REF_ERROR);
4569-catchAndAssertEquals(function() {
4570-  CUMPRINC(0.12, 12, 100, 0, 5, false);
4571-}, ERRORS.NUM_ERROR);
4572-catchAndAssertEquals(function() {
4573-  CUMPRINC(0.12, 12, 100, 3, 1, false);
4574-}, ERRORS.NUM_ERROR);
4575-catchAndAssertEquals(function() {
4576-  CUMPRINC();
4577-}, ERRORS.NA_ERROR);
4578-catchAndAssertEquals(function() {
4579-  CUMPRINC(0.12, 12, 100, 1, 5, true, 55);
4580-}, ERRORS.NA_ERROR);
4581-catchAndAssertEquals(function() {
4582-  CUMPRINC(0.12, 12, 100, 1, 5);
4583-}, ERRORS.NA_ERROR);
4584-
4585-
4586-// Test CUMIPMT
4587-assertEquals(CUMIPMT(0.12, 12, 100, 1, 5, 0), -54.39423242396348);
4588-assertEquals(CUMIPMT(0.12, 12, 100, 1, 5, false), -54.39423242396348);
4589-assertEquals(CUMIPMT(0.12, 12, 100, 1, 5, true), -37.851993235681675);
4590-assertEquals(CUMIPMT(0.12, 12, 100, 1, 5, 1), -37.851993235681675);
4591-assertEquals(CUMIPMT(0.12, 12, 100, 2, 6, 1), -45.74583201714228);
4592-assertEquals(CUMIPMT(0.12, 12, 100, 2, 6, true), -45.74583201714228);
4593-assertEquals(CUMIPMT([0.12], ["12"], [100, "str"], "1", 5, 0), -54.39423242396348);
4594-catchAndAssertEquals(function() {
4595-  CUMIPMT(0.12, 12, 100, 1, 5, []);
4596-}, ERRORS.REF_ERROR);
4597-catchAndAssertEquals(function() {
4598-  CUMIPMT(0.12, 12, 100, 0, 5, false);
4599-}, ERRORS.NUM_ERROR);
4600-catchAndAssertEquals(function() {
4601-  CUMIPMT(0.12, 12, 100, 3, 1, false);
4602-}, ERRORS.NUM_ERROR);
4603-catchAndAssertEquals(function() {
4604-  CUMIPMT();
4605-}, ERRORS.NA_ERROR);
4606-catchAndAssertEquals(function() {
4607-  CUMIPMT(0.12, 12, 100, 1, 5, true, 55);
4608-}, ERRORS.NA_ERROR);
4609-catchAndAssertEquals(function() {
4610-  CUMIPMT(0.12, 12, 100, 1, 5);
4611-}, ERRORS.NA_ERROR);
4612-
4613-
4614-// Test DB
4615-assertEquals(DB(100, 50, 10, 2, 12), 6.2482428240683285);
4616-assertEquals(DB("100", "50", "10", "2", "12"), 6.2482428240683285);
4617-assertEquals(DB(100, 50, 10, 2, 12.9999999), 6.2482428240683285);
4618-catchAndAssertEquals(function() {
4619-  DB(100, 50, 10, 2, 13);
4620-}, ERRORS.NUM_ERROR);
4621-catchAndAssertEquals(function() {
4622-  DB(100, 50, 10, 12, 2);
4623-}, ERRORS.NUM_ERROR);
4624-catchAndAssertEquals(function() {
4625-  DB(100, -50, 10, 2, 12);
4626-}, ERRORS.NUM_ERROR);
4627-
4628-
4629-// Test DDB
4630-assertEquals(DDB(100, 50, 10, 2, 2.25), 17.4375);
4631-assertEquals(DDB(100, [50], 10, 2, "2.25"), 17.4375);
4632-catchAndAssertEquals(function() {
4633-  DDB(100, 50, 10, 12, 2.25);
4634-}, ERRORS.NUM_ERROR);
4635-catchAndAssertEquals(function() {
4636-  DDB(100, -50, 10, 2, 12);
4637-}, ERRORS.NUM_ERROR);
4638-
4639-
4640-// Test DOLLAR
4641-assertEquals(DOLLAR(1.2351, 4), 1.2351);
4642-assertEquals(DOLLAR(1.2351, 2), 1.23);
4643-assertEquals(DOLLAR("$3.141592653589793", "2"), 3.14);
4644-assertEquals(DOLLAR("-$3.141592653589793", "2"), -3.14);
4645-assertEquals(DOLLAR("$-3.141592653589793", "2"), -3.14);
4646-assertEquals(DOLLAR(PI(), 1), 3.1);
4647-assertEquals(DOLLAR(PI(), 0), 3);
4648-assertEquals(DOLLAR(PI(), false), 3);
4649-assertEquals(DOLLAR(PI(), -1), 0);
4650-assertEquals(DOLLAR(31.41592653589793, -1), 30);
4651-assertEquals(DOLLAR([31.41592653589793], [-1]), 30);
4652-assertEquals(DOLLAR(31111.41592653589793, -4), 30000);
4653-assertEquals(DOLLAR(31111.41592653589793, -2), 31100);
4654-catchAndAssertEquals(function() {
4655-  DOLLAR();
4656-}, ERRORS.NA_ERROR);
4657-catchAndAssertEquals(function() {
4658-  DOLLAR(3.1, 1, 1);
4659-}, ERRORS.NA_ERROR);
4660-
4661-
4662-// Test  DOLLARDE
4663-assertEquals(DOLLARDE(0, 32), 0);
4664-assertEquals(DOLLARDE(100.1, 32), 100.3125);
4665-assertEquals(DOLLARDE(100.1, 32.9999), 100.3125);
4666-assertEquals(DOLLARDE("100.1", [32, "str"]), 100.3125);
4667-catchAndAssertEquals(function() {
4668-  DOLLARDE(100, []);
4669-}, ERRORS.REF_ERROR);
4670-catchAndAssertEquals(function() {
4671-  DOLLARDE(100, "str");
4672-}, ERRORS.VALUE_ERROR);
4673-catchAndAssertEquals(function() {
4674-  DOLLARDE(100, 0);
4675-}, ERRORS.DIV_ZERO_ERROR);
4676-catchAndAssertEquals(function() {
4677-  DOLLARDE(100, 0.99);
4678-}, ERRORS.DIV_ZERO_ERROR);
4679-catchAndAssertEquals(function() {
4680-  DOLLARDE();
4681-}, ERRORS.NA_ERROR);
4682-catchAndAssertEquals(function() {
4683-  DOLLARDE(3.1);
4684-}, ERRORS.NA_ERROR);
4685-catchAndAssertEquals(function() {
4686-  DOLLARDE(3.1, 32, 22);
4687-}, ERRORS.NA_ERROR);
4688-
4689-
4690-// Test DOLLARFR
4691-assertEquals(DOLLARFR(100.1, 32), 100.032);
4692-assertEquals(DOLLARFR(100.1, 32), 100.032);
4693-assertEquals(DOLLARFR(100.1, 32.9999), 100.032);
4694-assertEquals(DOLLARFR("100.1", [32, "str"]), 100.032);
4695-catchAndAssertEquals(function() {
4696-  DOLLARFR(100, []);
4697-}, ERRORS.REF_ERROR);
4698-catchAndAssertEquals(function() {
4699-  DOLLARFR(100, "str");
4700-}, ERRORS.VALUE_ERROR);
4701-catchAndAssertEquals(function() {
4702-  DOLLARFR(100, 0);
4703-}, ERRORS.DIV_ZERO_ERROR);
4704-catchAndAssertEquals(function() {
4705-  DOLLARFR(100, 0.99);
4706-}, ERRORS.DIV_ZERO_ERROR);
4707-catchAndAssertEquals(function() {
4708-  DOLLARFR();
4709-}, ERRORS.NA_ERROR);
4710-catchAndAssertEquals(function() {
4711-  DOLLARFR(3.1);
4712-}, ERRORS.NA_ERROR);
4713-catchAndAssertEquals(function() {
4714-  DOLLARFR(3.1, 32, 22);
4715-}, ERRORS.NA_ERROR);
4716-
4717-
4718-// Test EFFECT
4719-assertEquals(EFFECT(0.99, 12), 1.5890167507927795);
4720-assertEquals(EFFECT(0.99, 12.111), 1.5890167507927795);
4721-assertEquals(EFFECT(0.99, 12.999), 1.5890167507927795);
4722-assertEquals(EFFECT("100000", 12.999), 1.123182670038387e+47);
4723-assertEquals(EFFECT([100000], [12.999]), 1.123182670038387e+47);
4724-catchAndAssertEquals(function() {
4725-  EFFECT();
4726-}, ERRORS.NA_ERROR);
4727-catchAndAssertEquals(function() {
4728-  EFFECT(0.99);
4729-}, ERRORS.NA_ERROR);
4730-catchAndAssertEquals(function() {
4731-  EFFECT(-0.99, 12);
4732-}, ERRORS.NUM_ERROR);
4733-catchAndAssertEquals(function() {
4734-  EFFECT(0.99, 0);
4735-}, ERRORS.NUM_ERROR);
4736-catchAndAssertEquals(function() {
4737-  EFFECT(0.99, "str");
4738-}, ERRORS.VALUE_ERROR);
4739-catchAndAssertEquals(function() {
4740-  EFFECT(0.99, []);
4741-}, ERRORS.REF_ERROR);
4742+
4743+test("ACCRINT", function(){
4744+  assertEquals(ACCRINT(DATE(2000, 1, 1), DATE(2000, 2, 1), DATE(2002, 12, 31), 0.05, 100, 4), 14.98631386861314);
4745+  assertEquals(ACCRINT(DATE(2011, 1, 1), DATE(2011, 2, 1), DATE(2014, 7, 1), 0.1, 1000, 1, 0), 350);
4746+  assertEquals(ACCRINT(DATE(2001, 1, 1), DATE(2011, 2, 1), DATE(2014, 7, 1), 0.1, 1000, 2, 1), 1349.6186192059456);
4747+  assertEquals(ACCRINT(39508, 39691, 39569, 0.1, 1000, 2, 0), 16.666666666666664);
4748+  assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 0), 2737.5);
4749+  assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 1), 2737.8507871321012); // ms: 2787.087912 (1.76% err), gs: 2737.637363 (0.007% err)
4750+  assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 2), 2777.777777777778); // ms, gs: 2737.777778 (1.46% err)
4751+  assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 3), 2739.72602739726); //ms, gs: 2737.60274 (0.077% err)
4752+  assertEquals(ACCRINT(10000, 1, 20000, 0.1, 1000, 4, 4), 2737.5);
4753+  assertEquals(ACCRINT(1, 44, "1461", "0.1", [1000], [1]), 400);
4754+  assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1), 400);
4755+  assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 0), 400);
4756+  assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 1), 400);
4757+  assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 2), 405.55555555555554); // gs: 400
4758+  assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 3), 400); // gs: 399.6575342
4759+  assertEquals(ACCRINT(1, 2, 1461, 0.1, 1000, 1, 4), 400);
4760+  catchAndAssertEquals(function() {
4761+    ACCRINT(1, -1, 100, 0.1, 1000, 1, 4);
4762+  }, ERRORS.NUM_ERROR);
4763+  catchAndAssertEquals(function() {
4764+    ACCRINT(100, 2, 1, 0.1, 1000, 1, 4);
4765+  }, ERRORS.NUM_ERROR);
4766+  catchAndAssertEquals(function() {
4767+    ACCRINT(100, 2, 1, 0.1, 1000);
4768+  }, ERRORS.NA_ERROR);
4769+  catchAndAssertEquals(function() {
4770+    ACCRINT(1, 2, 1461, 0.1, 1000, 1, 1, 1);
4771+  }, ERRORS.NA_ERROR);
4772+});
4773+
4774+
4775+test("CUMPRINC", function(){
4776+  assertEquals(CUMPRINC(0.12, 12, 100, 1, 5, false), -26.324171373034403);
4777+  assertEquals(CUMPRINC(0.12, 12, 100, 1, 5, 0), -26.324171373034403);
4778+  assertEquals(CUMPRINC(0.12, 12, 100, 1, 5, true), -34.21801015449499);
4779+  assertEquals(CUMPRINC(0.12, 12, 100, 1, 5, -11), -34.21801015449499);
4780+  catchAndAssertEquals(function() {
4781+    CUMPRINC(0.12, 12, 100, 1, 5, []);
4782+  }, ERRORS.REF_ERROR);
4783+  catchAndAssertEquals(function() {
4784+    CUMPRINC(0.12, 12, 100, 0, 5, false);
4785+  }, ERRORS.NUM_ERROR);
4786+  catchAndAssertEquals(function() {
4787+    CUMPRINC(0.12, 12, 100, 3, 1, false);
4788+  }, ERRORS.NUM_ERROR);
4789+  catchAndAssertEquals(function() {
4790+    CUMPRINC();
4791+  }, ERRORS.NA_ERROR);
4792+  catchAndAssertEquals(function() {
4793+    CUMPRINC(0.12, 12, 100, 1, 5, true, 55);
4794+  }, ERRORS.NA_ERROR);
4795+  catchAndAssertEquals(function() {
4796+    CUMPRINC(0.12, 12, 100, 1, 5);
4797+  }, ERRORS.NA_ERROR);
4798+});
4799+
4800+
4801+test("CUMIPMT", function(){
4802+  assertEquals(CUMIPMT(0.12, 12, 100, 1, 5, 0), -54.39423242396348);
4803+  assertEquals(CUMIPMT(0.12, 12, 100, 1, 5, false), -54.39423242396348);
4804+  assertEquals(CUMIPMT(0.12, 12, 100, 1, 5, true), -37.851993235681675);
4805+  assertEquals(CUMIPMT(0.12, 12, 100, 1, 5, 1), -37.851993235681675);
4806+  assertEquals(CUMIPMT(0.12, 12, 100, 2, 6, 1), -45.74583201714228);
4807+  assertEquals(CUMIPMT(0.12, 12, 100, 2, 6, true), -45.74583201714228);
4808+  assertEquals(CUMIPMT([0.12], ["12"], [100, "str"], "1", 5, 0), -54.39423242396348);
4809+  catchAndAssertEquals(function() {
4810+    CUMIPMT(0.12, 12, 100, 1, 5, []);
4811+  }, ERRORS.REF_ERROR);
4812+  catchAndAssertEquals(function() {
4813+    CUMIPMT(0.12, 12, 100, 0, 5, false);
4814+  }, ERRORS.NUM_ERROR);
4815+  catchAndAssertEquals(function() {
4816+    CUMIPMT(0.12, 12, 100, 3, 1, false);
4817+  }, ERRORS.NUM_ERROR);
4818+  catchAndAssertEquals(function() {
4819+    CUMIPMT();
4820+  }, ERRORS.NA_ERROR);
4821+  catchAndAssertEquals(function() {
4822+    CUMIPMT(0.12, 12, 100, 1, 5, true, 55);
4823+  }, ERRORS.NA_ERROR);
4824+  catchAndAssertEquals(function() {
4825+    CUMIPMT(0.12, 12, 100, 1, 5);
4826+  }, ERRORS.NA_ERROR);
4827+});
4828+
4829+
4830+test("DB", function(){
4831+  assertEquals(DB(100, 50, 10, 2, 12), 6.2482428240683285);
4832+  assertEquals(DB("100", "50", "10", "2", "12"), 6.2482428240683285);
4833+  assertEquals(DB(100, 50, 10, 2, 12.9999999), 6.2482428240683285);
4834+  catchAndAssertEquals(function() {
4835+    DB(100, 50, 10, 2, 13);
4836+  }, ERRORS.NUM_ERROR);
4837+  catchAndAssertEquals(function() {
4838+    DB(100, 50, 10, 12, 2);
4839+  }, ERRORS.NUM_ERROR);
4840+  catchAndAssertEquals(function() {
4841+    DB(100, -50, 10, 2, 12);
4842+  }, ERRORS.NUM_ERROR);
4843+});
4844+
4845+
4846+test("DDB", function(){
4847+  assertEquals(DDB(100, 50, 10, 2, 2.25), 17.4375);
4848+  assertEquals(DDB(100, [50], 10, 2, "2.25"), 17.4375);
4849+  catchAndAssertEquals(function() {
4850+    DDB(100, 50, 10, 12, 2.25);
4851+  }, ERRORS.NUM_ERROR);
4852+  catchAndAssertEquals(function() {
4853+    DDB(100, -50, 10, 2, 12);
4854+  }, ERRORS.NUM_ERROR);
4855+});
4856+
4857+
4858+test("DOLLAR", function(){
4859+  assertEquals(DOLLAR(1.2351, 4), 1.2351);
4860+  assertEquals(DOLLAR(1.2351, 2), 1.23);
4861+  assertEquals(DOLLAR("$3.141592653589793", "2"), 3.14);
4862+  assertEquals(DOLLAR("-$3.141592653589793", "2"), -3.14);
4863+  assertEquals(DOLLAR("$-3.141592653589793", "2"), -3.14);
4864+  assertEquals(DOLLAR(PI(), 1), 3.1);
4865+  assertEquals(DOLLAR(PI(), 0), 3);
4866+  assertEquals(DOLLAR(PI(), false), 3);
4867+  assertEquals(DOLLAR(PI(), -1), 0);
4868+  assertEquals(DOLLAR(31.41592653589793, -1), 30);
4869+  assertEquals(DOLLAR([31.41592653589793], [-1]), 30);
4870+  assertEquals(DOLLAR(31111.41592653589793, -4), 30000);
4871+  assertEquals(DOLLAR(31111.41592653589793, -2), 31100);
4872+  catchAndAssertEquals(function() {
4873+    DOLLAR();
4874+  }, ERRORS.NA_ERROR);
4875+  catchAndAssertEquals(function() {
4876+    DOLLAR(3.1, 1, 1);
4877+  }, ERRORS.NA_ERROR);
4878+});
4879+
4880+
4881+test("DOLLARDE", function(){
4882+  assertEquals(DOLLARDE(0, 32), 0);
4883+  assertEquals(DOLLARDE(100.1, 32), 100.3125);
4884+  assertEquals(DOLLARDE(100.1, 32.9999), 100.3125);
4885+  assertEquals(DOLLARDE("100.1", [32, "str"]), 100.3125);
4886+  catchAndAssertEquals(function() {
4887+    DOLLARDE(100, []);
4888+  }, ERRORS.REF_ERROR);
4889+  catchAndAssertEquals(function() {
4890+    DOLLARDE(100, "str");
4891+  }, ERRORS.VALUE_ERROR);
4892+  catchAndAssertEquals(function() {
4893+    DOLLARDE(100, 0);
4894+  }, ERRORS.DIV_ZERO_ERROR);
4895+  catchAndAssertEquals(function() {
4896+    DOLLARDE(100, 0.99);
4897+  }, ERRORS.DIV_ZERO_ERROR);
4898+  catchAndAssertEquals(function() {
4899+    DOLLARDE();
4900+  }, ERRORS.NA_ERROR);
4901+  catchAndAssertEquals(function() {
4902+    DOLLARDE(3.1);
4903+  }, ERRORS.NA_ERROR);
4904+  catchAndAssertEquals(function() {
4905+    DOLLARDE(3.1, 32, 22);
4906+  }, ERRORS.NA_ERROR);
4907+});
4908+
4909+
4910+test("DOLLARFR", function(){
4911+  assertEquals(DOLLARFR(100.1, 32), 100.032);
4912+  assertEquals(DOLLARFR(100.1, 32), 100.032);
4913+  assertEquals(DOLLARFR(100.1, 32.9999), 100.032);
4914+  assertEquals(DOLLARFR("100.1", [32, "str"]), 100.032);
4915+  catchAndAssertEquals(function() {
4916+    DOLLARFR(100, []);
4917+  }, ERRORS.REF_ERROR);
4918+  catchAndAssertEquals(function() {
4919+    DOLLARFR(100, "str");
4920+  }, ERRORS.VALUE_ERROR);
4921+  catchAndAssertEquals(function() {
4922+    DOLLARFR(100, 0);
4923+  }, ERRORS.DIV_ZERO_ERROR);
4924+  catchAndAssertEquals(function() {
4925+    DOLLARFR(100, 0.99);
4926+  }, ERRORS.DIV_ZERO_ERROR);
4927+  catchAndAssertEquals(function() {
4928+    DOLLARFR();
4929+  }, ERRORS.NA_ERROR);
4930+  catchAndAssertEquals(function() {
4931+    DOLLARFR(3.1);
4932+  }, ERRORS.NA_ERROR);
4933+  catchAndAssertEquals(function() {
4934+    DOLLARFR(3.1, 32, 22);
4935+  }, ERRORS.NA_ERROR);
4936+});
4937+
4938+
4939+test("EFFECT", function(){
4940+  assertEquals(EFFECT(0.99, 12), 1.5890167507927795);
4941+  assertEquals(EFFECT(0.99, 12.111), 1.5890167507927795);
4942+  assertEquals(EFFECT(0.99, 12.999), 1.5890167507927795);
4943+  assertEquals(EFFECT("100000", 12.999), 1.123182670038387e+47);
4944+  assertEquals(EFFECT([100000], [12.999]), 1.123182670038387e+47);
4945+  catchAndAssertEquals(function() {
4946+    EFFECT();
4947+  }, ERRORS.NA_ERROR);
4948+  catchAndAssertEquals(function() {
4949+    EFFECT(0.99);
4950+  }, ERRORS.NA_ERROR);
4951+  catchAndAssertEquals(function() {
4952+    EFFECT(-0.99, 12);
4953+  }, ERRORS.NUM_ERROR);
4954+  catchAndAssertEquals(function() {
4955+    EFFECT(0.99, 0);
4956+  }, ERRORS.NUM_ERROR);
4957+  catchAndAssertEquals(function() {
4958+    EFFECT(0.99, "str");
4959+  }, ERRORS.VALUE_ERROR);
4960+  catchAndAssertEquals(function() {
4961+    EFFECT(0.99, []);
4962+  }, ERRORS.REF_ERROR);
4963+});
4964diff --git a/tests/Formulas/HelperTest.ts b/tests/Formulas/HelperTest.ts
4965index 59a3921..e33b84a 100644
4966--- a/tests/Formulas/HelperTest.ts
4967+++ b/tests/Formulas/HelperTest.ts
4968@@ -1,15 +1,21 @@
4969-import { Helpers } from "../../src/Helpers";
4970-import { assertEquals } from "../utils/Asserts"
4971+import {
4972+  Helpers
4973+} from "../../src/Helpers";
4974+import {
4975+  assertEquals,
4976+  test
4977+} from "../utils/Asserts"
4978 
4979-// Test Helpers.number
4980-assertEquals(-1, Helpers.number("-1"));
4981-assertEquals(1, Helpers.number("+1"));
4982-assertEquals(1.8239817293871983e+28, Helpers.number("18239817293871982379817157562"));
4983-assertEquals(1.8239817293871983e+28, Helpers.number("+18239817293871982379817157562"));
4984-assertEquals(-1.8239817293871983e+28, Helpers.number("-18239817293871982379817157562"));
4985-assertEquals(0, Helpers.number("10."));
4986-assertEquals(111, Helpers.number("000111"));
4987-assertEquals("10 + 10", Helpers.number("10 + 10"));
4988-assertEquals("10/10", Helpers.number("10/10"));
4989-assertEquals("10*10", Helpers.number("10*10"));
4990-assertEquals(10.18239817293872, Helpers.number("10.18239817293871982379817157562"));
4991+test("Helpers.number", function(){
4992+  assertEquals(-1, Helpers.number("-1"));
4993+  assertEquals(1, Helpers.number("+1"));
4994+  assertEquals(1.8239817293871983e+28, Helpers.number("18239817293871982379817157562"));
4995+  assertEquals(1.8239817293871983e+28, Helpers.number("+18239817293871982379817157562"));
4996+  assertEquals(-1.8239817293871983e+28, Helpers.number("-18239817293871982379817157562"));
4997+  assertEquals(0, Helpers.number("10."));
4998+  assertEquals(111, Helpers.number("000111"));
4999+  assertEquals("10 + 10", Helpers.number("10 + 10"));
5000+  assertEquals("10/10", Helpers.number("10/10"));
5001+  assertEquals("10*10", Helpers.number("10*10"));
5002+  assertEquals(10.18239817293872, Helpers.number("10.18239817293871982379817157562"));
5003+});
5004diff --git a/tests/Formulas/LogicalTest.ts b/tests/Formulas/LogicalTest.ts
5005index c26807f..40e7d71 100644
5006--- a/tests/Formulas/LogicalTest.ts
5007+++ b/tests/Formulas/LogicalTest.ts
5008@@ -10,147 +10,156 @@ import {
5009 import * as ERRORS from "../../src/Errors";
5010 import {
5011   assertEquals,
5012-  catchAndAssertEquals
5013+  catchAndAssertEquals,
5014+  test
5015 } from "../utils/Asserts";
5016 
5017 
5018-// Test AND
5019-assertEquals(AND(10), true);
5020-assertEquals(AND(10, 10), true);
5021-assertEquals(AND(10, 0), false);
5022-assertEquals(AND(10, false), false);
5023-assertEquals(AND(0, 0), false);
5024-catchAndAssertEquals(function() {
5025-  AND(1, "");
5026-}, ERRORS.VALUE_ERROR);
5027-catchAndAssertEquals(function() {
5028-  AND();
5029-}, ERRORS.NA_ERROR);
5030-catchAndAssertEquals(function() {
5031-  AND(1, "str");
5032-}, ERRORS.VALUE_ERROR);
5033-assertEquals(AND(0, [1, 1]), false);
5034-assertEquals(AND(1, [1, 1]), true);
5035-catchAndAssertEquals(function() {
5036-  AND(1, [1, "str"]);
5037-}, ERRORS.VALUE_ERROR);
5038+test("AND", function(){
5039+  assertEquals(AND(10), true);
5040+  assertEquals(AND(10, 10), true);
5041+  assertEquals(AND(10, 0), false);
5042+  assertEquals(AND(10, false), false);
5043+  assertEquals(AND(0, 0), false);
5044+  catchAndAssertEquals(function() {
5045+    AND(1, "");
5046+  }, ERRORS.VALUE_ERROR);
5047+  catchAndAssertEquals(function() {
5048+    AND();
5049+  }, ERRORS.NA_ERROR);
5050+  catchAndAssertEquals(function() {
5051+    AND(1, "str");
5052+  }, ERRORS.VALUE_ERROR);
5053+  assertEquals(AND(0, [1, 1]), false);
5054+  assertEquals(AND(1, [1, 1]), true);
5055+  catchAndAssertEquals(function() {
5056+    AND(1, [1, "str"]);
5057+  }, ERRORS.VALUE_ERROR);
5058+});
5059 
5060 
5061-// Test EXACT
5062-assertEquals(EXACT("m", "M"), false);
5063-assertEquals(EXACT("m", "m"), true);
5064-assertEquals(EXACT("m", false), false);
5065-assertEquals(EXACT(false, false), true);
5066-assertEquals(EXACT(10, 10), true);
5067-assertEquals(EXACT(10, "10"), true);
5068-assertEquals(EXACT(10, "str"), false);
5069-assertEquals(EXACT([10], [10]), true);
5070-assertEquals(EXACT(["str"], [10, 22]), false);
5071-catchAndAssertEquals(function() {
5072-  EXACT([], []);
5073-}, ERRORS.REF_ERROR);
5074-catchAndAssertEquals(function() {
5075-  EXACT([]);
5076-}, ERRORS.NA_ERROR);
5077-catchAndAssertEquals(function() {
5078-  EXACT("m");
5079-}, ERRORS.NA_ERROR);
5080-catchAndAssertEquals(function() {
5081-  EXACT(10, 10, 10);
5082-}, ERRORS.NA_ERROR);
5083-catchAndAssertEquals(function() {
5084-  EXACT(false);
5085-}, ERRORS.NA_ERROR);
5086+test("EXACT", function(){
5087+  assertEquals(EXACT("m", "M"), false);
5088+  assertEquals(EXACT("m", "m"), true);
5089+  assertEquals(EXACT("m", false), false);
5090+  assertEquals(EXACT(false, false), true);
5091+  assertEquals(EXACT(10, 10), true);
5092+  assertEquals(EXACT(10, "10"), true);
5093+  assertEquals(EXACT(10, "str"), false);
5094+  assertEquals(EXACT([10], [10]), true);
5095+  assertEquals(EXACT(["str"], [10, 22]), false);
5096+  catchAndAssertEquals(function() {
5097+    EXACT([], []);
5098+  }, ERRORS.REF_ERROR);
5099+  catchAndAssertEquals(function() {
5100+    EXACT([]);
5101+  }, ERRORS.NA_ERROR);
5102+  catchAndAssertEquals(function() {
5103+    EXACT("m");
5104+  }, ERRORS.NA_ERROR);
5105+  catchAndAssertEquals(function() {
5106+    EXACT(10, 10, 10);
5107+  }, ERRORS.NA_ERROR);
5108+  catchAndAssertEquals(function() {
5109+    EXACT(false);
5110+  }, ERRORS.NA_ERROR);
5111 
5112+});
5113 
5114-// Test TRUE
5115-assertEquals(TRUE(), true);
5116 
5117+test("TRUE", function(){
5118+  assertEquals(TRUE(), true);
5119+});
5120 
5121-// Test FALSE
5122-assertEquals(FALSE(), false);
5123 
5124+test("FALSE", function(){
5125+  assertEquals(FALSE(), false);
5126+});
5127 
5128-// Test NOT
5129-assertEquals(NOT(TRUE()), false);
5130-assertEquals(NOT(""), true);
5131-catchAndAssertEquals(function() {
5132-  NOT(" ");
5133-}, ERRORS.VALUE_ERROR);
5134-assertEquals(NOT(100), false);
5135-assertEquals(NOT(0), true);
5136-assertEquals(NOT(-1), false);
5137-assertEquals(NOT(1), false);
5138-catchAndAssertEquals(function() {
5139-  NOT("0");
5140-}, ERRORS.VALUE_ERROR);
5141-catchAndAssertEquals(function() {
5142-  NOT([]);
5143-}, ERRORS.REF_ERROR);
5144-assertEquals(NOT([10]), false);
5145-assertEquals(NOT([0, 0]), true);
5146-assertEquals(NOT([0, false]), true);
5147-assertEquals(NOT([false, 0]), true);
5148-assertEquals(NOT([10, "str"]), false);
5149-catchAndAssertEquals(function() {
5150-  NOT("str");
5151-}, ERRORS.VALUE_ERROR);
5152-assertEquals(NOT([""]), true);
5153-assertEquals(NOT([0]), true);
5154-assertEquals(NOT([1]), false);
5155-assertEquals(NOT([0, 1]), true);
5156-catchAndAssertEquals(function() {
5157-  NOT("1.2");
5158-}, ERRORS.VALUE_ERROR);
5159-catchAndAssertEquals(function() {
5160-  NOT();
5161-}, ERRORS.NA_ERROR);
5162-catchAndAssertEquals(function() {
5163-  NOT(false, false);
5164-}, ERRORS.NA_ERROR);
5165 
5166+test("NOT", function(){
5167+  assertEquals(NOT(TRUE()), false);
5168+  assertEquals(NOT(""), true);
5169+  catchAndAssertEquals(function() {
5170+    NOT(" ");
5171+  }, ERRORS.VALUE_ERROR);
5172+  assertEquals(NOT(100), false);
5173+  assertEquals(NOT(0), true);
5174+  assertEquals(NOT(-1), false);
5175+  assertEquals(NOT(1), false);
5176+  catchAndAssertEquals(function() {
5177+    NOT("0");
5178+  }, ERRORS.VALUE_ERROR);
5179+  catchAndAssertEquals(function() {
5180+    NOT([]);
5181+  }, ERRORS.REF_ERROR);
5182+  assertEquals(NOT([10]), false);
5183+  assertEquals(NOT([0, 0]), true);
5184+  assertEquals(NOT([0, false]), true);
5185+  assertEquals(NOT([false, 0]), true);
5186+  assertEquals(NOT([10, "str"]), false);
5187+  catchAndAssertEquals(function() {
5188+    NOT("str");
5189+  }, ERRORS.VALUE_ERROR);
5190+  assertEquals(NOT([""]), true);
5191+  assertEquals(NOT([0]), true);
5192+  assertEquals(NOT([1]), false);
5193+  assertEquals(NOT([0, 1]), true);
5194+  catchAndAssertEquals(function() {
5195+    NOT("1.2");
5196+  }, ERRORS.VALUE_ERROR);
5197+  catchAndAssertEquals(function() {
5198+    NOT();
5199+  }, ERRORS.NA_ERROR);
5200+  catchAndAssertEquals(function() {
5201+    NOT(false, false);
5202+  }, ERRORS.NA_ERROR);
5203+});
5204 
5205-// Test OR
5206-assertEquals(OR(true, false), true);
5207-assertEquals(OR(false, false), false);
5208-assertEquals(OR(1, 0), true);
5209-assertEquals(OR([1, 0]), true);
5210-assertEquals(OR(false, 0, -10), true);
5211-assertEquals(OR([false, 0, -10]), true);
5212-assertEquals(OR([false, 0, [-10]]), true);
5213-catchAndAssertEquals(function() {
5214-  OR([false, 0, []]);
5215-}, ERRORS.REF_ERROR);
5216-catchAndAssertEquals(function() {
5217-  OR(false, "d");
5218-}, ERRORS.VALUE_ERROR);
5219-catchAndAssertEquals(function() {
5220-  OR(false, "10");
5221-}, ERRORS.VALUE_ERROR);
5222-catchAndAssertEquals(function() {
5223-  OR(false, "1.1");
5224-}, ERRORS.VALUE_ERROR);
5225-catchAndAssertEquals(function() {
5226-  OR();
5227-}, ERRORS.NA_ERROR);
5228 
5229+test("OR", function(){
5230+  assertEquals(OR(true, false), true);
5231+  assertEquals(OR(false, false), false);
5232+  assertEquals(OR(1, 0), true);
5233+  assertEquals(OR([1, 0]), true);
5234+  assertEquals(OR(false, 0, -10), true);
5235+  assertEquals(OR([false, 0, -10]), true);
5236+  assertEquals(OR([false, 0, [-10]]), true);
5237+  catchAndAssertEquals(function() {
5238+    OR([false, 0, []]);
5239+  }, ERRORS.REF_ERROR);
5240+  catchAndAssertEquals(function() {
5241+    OR(false, "d");
5242+  }, ERRORS.VALUE_ERROR);
5243+  catchAndAssertEquals(function() {
5244+    OR(false, "10");
5245+  }, ERRORS.VALUE_ERROR);
5246+  catchAndAssertEquals(function() {
5247+    OR(false, "1.1");
5248+  }, ERRORS.VALUE_ERROR);
5249+  catchAndAssertEquals(function() {
5250+    OR();
5251+  }, ERRORS.NA_ERROR);
5252+});
5253 
5254-// Test XOR
5255-assertEquals(XOR(1, 1), false);
5256-assertEquals(XOR(1, 0), true);
5257-assertEquals(XOR(0, 0, 0), false);
5258-assertEquals(XOR(0, 0, 1), true);
5259-assertEquals(XOR(0, 0, [0, 0, 1]), true);
5260-assertEquals(XOR(0, 1, [0, 0, 1]), false);
5261-catchAndAssertEquals(function() {
5262-  XOR("str");
5263-}, ERRORS.VALUE_ERROR);
5264-catchAndAssertEquals(function() {
5265-  XOR();
5266-}, ERRORS.NA_ERROR);
5267-catchAndAssertEquals(function() {
5268-  XOR(1, []);
5269-}, ERRORS.REF_ERROR);
5270-catchAndAssertEquals(function() {
5271-  XOR([]);
5272-}, ERRORS.REF_ERROR);
5273\ No newline at end of file
5274+
5275+test("XOR", function(){
5276+  assertEquals(XOR(1, 1), false);
5277+  assertEquals(XOR(1, 0), true);
5278+  assertEquals(XOR(0, 0, 0), false);
5279+  assertEquals(XOR(0, 0, 1), true);
5280+  assertEquals(XOR(0, 0, [0, 0, 1]), true);
5281+  assertEquals(XOR(0, 1, [0, 0, 1]), false);
5282+  catchAndAssertEquals(function() {
5283+    XOR("str");
5284+  }, ERRORS.VALUE_ERROR);
5285+  catchAndAssertEquals(function() {
5286+    XOR();
5287+  }, ERRORS.NA_ERROR);
5288+  catchAndAssertEquals(function() {
5289+    XOR(1, []);
5290+  }, ERRORS.REF_ERROR);
5291+  catchAndAssertEquals(function() {
5292+    XOR([]);
5293+  }, ERRORS.REF_ERROR);
5294+});
5295diff --git a/tests/Formulas/MathTest.ts b/tests/Formulas/MathTest.ts
5296index aad5c1f..2427847 100644
5297--- a/tests/Formulas/MathTest.ts
5298+++ b/tests/Formulas/MathTest.ts
5299@@ -54,1013 +54,1063 @@ import {
5300 import * as ERRORS from "../../src/Errors";
5301 import {
5302   assertEquals,
5303-  catchAndAssertEquals
5304+  catchAndAssertEquals,
5305+  test
5306 } from "../utils/Asserts";
5307 
5308 
5309-// Test ABS
5310-assertEquals(ABS(-10), 10);
5311-assertEquals(ABS(-10.111), 10.111);
5312-assertEquals(ABS(0), 0);
5313-assertEquals(ABS(false), 0);
5314-assertEquals(ABS("-44"), 44);
5315-catchAndAssertEquals(function() {
5316-  ABS();
5317-}, ERRORS.NA_ERROR);
5318-catchAndAssertEquals(function() {
5319-  ABS("str");
5320-}, ERRORS.VALUE_ERROR);
5321-
5322-
5323-// Test ACOS
5324-assertEquals(ACOS(0), 1.5707963267948966);
5325-assertEquals(ACOS(-1), 3.141592653589793);
5326-assertEquals(ACOS(1), 0);
5327-assertEquals(ACOS("-1"), 3.141592653589793);
5328-assertEquals(ACOS(false), 1.5707963267948966);
5329-catchAndAssertEquals(function() {
5330-  ACOS("str");
5331-}, ERRORS.VALUE_ERROR);
5332-catchAndAssertEquals(function() {
5333-  ACOS(2);
5334-}, ERRORS.NUM_ERROR);
5335-
5336-
5337-// Test ACOSH
5338-assertEquals(ACOSH(22), 3.783672704329451);
5339-assertEquals(ACOSH(1), 0);
5340-assertEquals(ACOSH("11"), 3.0889699048446033);
5341-catchAndAssertEquals(function() {
5342-  ACOSH(-1);
5343-}, ERRORS.NUM_ERROR);
5344-catchAndAssertEquals(function() {
5345-  ACOSH("str");
5346-}, ERRORS.VALUE_ERROR);
5347-catchAndAssertEquals(function() {
5348-  ACOSH(false);
5349-}, ERRORS.NUM_ERROR);
5350-
5351-
5352-// Test ACOTH
5353-assertEquals(ACOTH(22), 0.04548588910286339);
5354-assertEquals(ACOTH(-1.1), -1.522261218861711);
5355-assertEquals(ACOTH("-22"), -0.04548588910286338);
5356-catchAndAssertEquals(function() {
5357-  ACOTH(-1);
5358-}, ERRORS.NUM_ERROR);
5359-catchAndAssertEquals(function() {
5360-  ACOTH("str");
5361-}, ERRORS.VALUE_ERROR);
5362-catchAndAssertEquals(function() {
5363-  ACOTH(false);
5364-}, ERRORS.NUM_ERROR);
5365-
5366-
5367-// Test ASIN
5368-assertEquals(ASIN(0), 0);
5369-assertEquals(ASIN(1), 1.5707963267948966);
5370-assertEquals(ASIN("1"), 1.5707963267948966);
5371-assertEquals(ASIN(false), 0);
5372-catchAndAssertEquals(function() {
5373-  ASIN(2);
5374-}, ERRORS.NUM_ERROR);
5375-catchAndAssertEquals(function() {
5376-  ASIN("str");
5377-}, ERRORS.VALUE_ERROR);
5378-
5379-
5380-// Test ASINH
5381-assertEquals(ASINH(1), 0.8813735870195429);
5382-assertEquals(ASINH(0), 0);
5383-assertEquals(ASINH("1"), 0.8813735870195429);
5384-assertEquals(ASINH(false), 0);
5385-assertEquals(ASINH(true), 0.8813735870195429);
5386-catchAndAssertEquals(function() {
5387-  ASINH("str");
5388-}, ERRORS.VALUE_ERROR);
5389-
5390-
5391-// Test ATAN
5392-assertEquals(ATAN(1), 0.7853981633974483);
5393-assertEquals(ATAN(0), 0);
5394-assertEquals(ATAN("1"), 0.7853981633974483);
5395-assertEquals(ATAN(false), 0);
5396-assertEquals(ATAN(true), 0.7853981633974483);
5397-catchAndAssertEquals(function() {
5398-  ASINH("str");
5399-}, ERRORS.VALUE_ERROR);
5400-
5401-// Test ATAN2
5402-assertEquals(ATAN2(4, 3), 0.6435011087932844);
5403-assertEquals(ATAN2(-1, -1), -2.356194490192345);
5404-catchAndAssertEquals(function() {
5405-  ATAN2(0, 0);
5406-}, ERRORS.DIV_ZERO_ERROR);
5407-assertEquals(ATAN2(1, 0), 0);
5408-assertEquals(ATAN2(0, 1), 1.5707963267948966);
5409-assertEquals(ATAN2(-1, "-1"), -2.356194490192345);
5410-assertEquals(ATAN2(true, false), 0);
5411-assertEquals(ATAN2(true, true), 0.7853981633974483);
5412-catchAndAssertEquals(function() {
5413-  ATAN2("str", false);
5414-}, ERRORS.VALUE_ERROR);
5415-
5416-
5417-// Test ATANH
5418-assertEquals(ATANH(0.51), 0.5627297693521489);
5419-assertEquals(ATANH(0.44), 0.47223080442042564);
5420-assertEquals(ATANH(0), 0);
5421-assertEquals(ATANH("0.1"), 0.10033534773107562);
5422-assertEquals(ATANH(false), 0);
5423-catchAndAssertEquals(function() {
5424-  ATANH(true);
5425-}, ERRORS.NUM_ERROR);
5426-catchAndAssertEquals(function() {
5427-  ATANH("str");
5428-}, ERRORS.VALUE_ERROR);
5429-
5430-
5431-// Test CEILING
5432-assertEquals(CEILING(10.1), 11);
5433-assertEquals(CEILING("10.1"), 11);
5434-assertEquals(CEILING(10.11111111, 0.1), 10.2);
5435-assertEquals(CEILING(10.22222222, 0.1), 10.3);
5436-assertEquals(CEILING(10.33333333, 0.2), 10.4);
5437-assertEquals(CEILING(10.33333333, 0.1), 10.4);
5438-assertEquals(CEILING([10.33333333], 0.1), 10.4);
5439-assertEquals(CEILING(10.22222222, 5), 15);
5440-assertEquals(CEILING(10.22222222, 8), 16);
5441-assertEquals(CEILING(10.22222222, true), 11);
5442-catchAndAssertEquals(function() {
5443-  CEILING(10, 0);
5444-}, ERRORS.DIV_ZERO_ERROR);
5445-catchAndAssertEquals(function() {
5446-  CEILING(10, 1, 2);
5447-}, ERRORS.NA_ERROR);
5448-catchAndAssertEquals(function() {
5449-  CEILING();
5450-}, ERRORS.NA_ERROR);
5451-
5452-
5453-// Test COMBIN
5454-assertEquals(COMBIN(4, 2), 6);
5455-assertEquals(COMBIN(4.999, 2.888), 6);
5456-assertEquals(COMBIN([4, "str"], [2]), 6);
5457-assertEquals(COMBIN(0, 0), 1);
5458-catchAndAssertEquals(function() {
5459-  COMBIN(2, "str");
5460-}, ERRORS.VALUE_ERROR);
5461-catchAndAssertEquals(function() {
5462-  COMBIN(2, []);
5463-}, ERRORS.REF_ERROR);
5464-catchAndAssertEquals(function() {
5465-  COMBIN(2, 4);
5466-}, ERRORS.NUM_ERROR);
5467-catchAndAssertEquals(function() {
5468-  COMBIN(0, 1);
5469-}, ERRORS.NUM_ERROR);
5470-catchAndAssertEquals(function() {
5471-  COMBIN();
5472-}, ERRORS.NA_ERROR);
5473-catchAndAssertEquals(function() {
5474-  COMBIN(4);
5475-}, ERRORS.NA_ERROR);
5476-catchAndAssertEquals(function() {
5477-  COMBIN(4, 2, 66);
5478-}, ERRORS.NA_ERROR);
5479-
5480-
5481-
5482-// Test COS
5483-assertEquals(COS(PI()), -1);
5484-assertEquals(COS(1), 0.5403023058681398);
5485-assertEquals(COS(false), 1);
5486-assertEquals(COS(true), 0.5403023058681398);
5487-assertEquals(COS(""), 1);
5488-assertEquals(COS("0"), 1);
5489-catchAndAssertEquals(function() {
5490-  COS("str");
5491-}, ERRORS.VALUE_ERROR);
5492-catchAndAssertEquals(function() {
5493-  COS();
5494-}, ERRORS.NA_ERROR);
5495-catchAndAssertEquals(function() {
5496-  COS(1, 1);
5497-}, ERRORS.NA_ERROR);
5498-assertEquals(COS([0, "str"]), 1);
5499-
5500-
5501-// Test COSH
5502-assertEquals(COSH(PI()), 11.591953275521522);
5503-assertEquals(COSH(1), 1.5430806348152437);
5504-assertEquals(COSH(false), 1);
5505-assertEquals(COSH(0), 1);
5506-assertEquals(COSH(true), 1.5430806348152437);
5507-assertEquals(COSH(""), 1);
5508-catchAndAssertEquals(function() {
5509-  COSH("str");
5510-}, ERRORS.VALUE_ERROR);
5511-catchAndAssertEquals(function() {
5512-  COSH();
5513-}, ERRORS.NA_ERROR);
5514-catchAndAssertEquals(function() {
5515-  COSH(1, 1);
5516-}, ERRORS.NA_ERROR);
5517-assertEquals(COSH([0, "str"]), 1);
5518-
5519-
5520-// Test COT
5521-assertEquals(COT(30), -0.15611995216165922);
5522-assertEquals(COT(1), 0.6420926159343306);
5523-assertEquals(COT(true), 0.6420926159343306);
5524-assertEquals(COT([1, "str"]), 0.6420926159343306);
5525-catchAndAssertEquals(function() {
5526-  COT(false);
5527-}, ERRORS.DIV_ZERO_ERROR);
5528-catchAndAssertEquals(function() {
5529-  COT(0);
5530-}, ERRORS.DIV_ZERO_ERROR);
5531-catchAndAssertEquals(function() {
5532-  COT("");
5533-}, ERRORS.DIV_ZERO_ERROR);
5534-catchAndAssertEquals(function() {
5535-  COT("str");
5536-}, ERRORS.VALUE_ERROR);
5537-catchAndAssertEquals(function() {
5538-  COT();
5539-}, ERRORS.NA_ERROR);
5540-catchAndAssertEquals(function() {
5541-  COT(1, 1);
5542-}, ERRORS.NA_ERROR);
5543-
5544-
5545-// Test COTH
5546-assertEquals(COTH(30), 1);
5547-assertEquals(COTH(1), 1.3130352854993315);
5548-assertEquals(COTH(true), 1.3130352854993315);
5549-assertEquals(COTH([1, "str"]), 1.3130352854993315);
5550-assertEquals(COTH(-1), -1.3130352854993315);
5551-catchAndAssertEquals(function() {
5552-  COTH(false);
5553-}, ERRORS.DIV_ZERO_ERROR);
5554-catchAndAssertEquals(function() {
5555-  COTH(0);
5556-}, ERRORS.DIV_ZERO_ERROR);
5557-catchAndAssertEquals(function() {
5558-  COTH("");
5559-}, ERRORS.DIV_ZERO_ERROR);
5560-catchAndAssertEquals(function() {
5561-  COTH("str");
5562-}, ERRORS.VALUE_ERROR);
5563-catchAndAssertEquals(function() {
5564-  COTH();
5565-}, ERRORS.NA_ERROR);
5566-catchAndAssertEquals(function() {
5567-  COTH(1, 1);
5568-}, ERRORS.NA_ERROR);
5569-
5570-
5571-// Test COUNTIF
5572-assertEquals(COUNTIF([1, 5, 10], ">4"), 2);
5573-assertEquals(COUNTIF([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 7);
5574-assertEquals(COUNTIF([1, 5, 10], 5), 1);
5575-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], 5), 4);
5576-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], 10), 1);
5577-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">5"), 1);
5578-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=5"), 4);
5579-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=10"), 1);
5580-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=     10  "), 1);
5581-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">0"), 6);
5582-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">=5"), 5);
5583-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "<10"), 5);
5584-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 6);
5585-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">4.99"), 5);
5586-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
5587-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
5588-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=>5"), 0);
5589-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "==5"), 0);
5590-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "boom"], "*o*"), 3);
5591-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "mom"), 2);
5592-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "?o?"), 3);
5593-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "???"), 5);
5594-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "????"), 0);
5595-assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "?"), 0);
5596-// dollar sign and negative values
5597-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=$5"), 4);
5598-assertEquals(COUNTIF([1, -5, -5, -5, 10, -5], "=-$5"), 4);
5599-assertEquals(COUNTIF([1, -5, -5, -5, 10, -5], "=-5"), 4);
5600-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">$5"), 1);
5601-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=$10"), 1);
5602-assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=  $ 10"), 1);
5603-catchAndAssertEquals(function() {
5604-  COUNTIF([0, 1, 0, 1]);
5605-}, ERRORS.NA_ERROR);
5606-catchAndAssertEquals(function() {
5607-  COUNTIF();
5608-}, ERRORS.NA_ERROR);
5609-catchAndAssertEquals(function() {
5610-  COUNTIF([], "=1", []);
5611-}, ERRORS.NA_ERROR);
5612-
5613-
5614-// Test COUNTIFS
5615-// All COUNTIF tests should also work on COUNTIFS
5616-assertEquals(COUNTIFS([1, 5, 10], ">4"), 2);
5617-assertEquals(COUNTIFS([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 7);
5618-assertEquals(COUNTIFS([1, 5, 10], 5), 1);
5619-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], 5), 4);
5620-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], 10), 1);
5621-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">5"), 1);
5622-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=5"), 4);
5623-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=10"), 1);
5624-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=     10  "), 1);
5625-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">0"), 6);
5626-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">=5"), 5);
5627-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "<10"), 5);
5628-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5, 44], "<=10"), 6);
5629-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">4.99"), 5);
5630-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "<4.99"), 1);
5631-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
5632-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=>5"), 0);
5633-assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "==5"), 0);
5634-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "boom"], "*o*"), 3);
5635-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "mom"), 2);
5636-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "?o?"), 3);
5637-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "???"), 5);
5638-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "????"), 0);
5639-assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "?"), 0);
5640-// Now actually test COUNTIFS
5641-assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1"), 2);
5642-assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1"), 2);
5643-assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1", [0, 0, 1, 1], "=1"), 2);
5644-assertEquals(COUNTIFS([1, 5, 10, 20, 40], ">4", [0, 0, 1, 1, 1], "=1", [0, 0, 0, 0, 0], "=1"), 0);
5645-assertEquals(COUNTIFS([1, 2, 3, 4], ">3", [true, true, false, true], true), 1);
5646-catchAndAssertEquals(function() {
5647-  COUNTIFS([1, 5, 10, 20], ">4", [0, 0], "=1");
5648-}, ERRORS.VALUE_ERROR);
5649-
5650-
5651-// Test COUNTUNIQUE
5652-assertEquals(COUNTUNIQUE([1, 1, 10]), 2);
5653-assertEquals(COUNTUNIQUE(["1", 1, 10]), 3);
5654-assertEquals(COUNTUNIQUE(["1", 1, 10, ""]), 4);
5655-assertEquals(COUNTUNIQUE(["1", 1, 10, "", ""]), 4);
5656-assertEquals(COUNTUNIQUE(["1", 1, 10, "", " "]), 5);
5657-assertEquals(COUNTUNIQUE(["1", 1, 10, []]), 4);
5658-assertEquals(COUNTUNIQUE(["", " ", [""], []]), 2);
5659-assertEquals(COUNTUNIQUE([[""], []]), 1);
5660-catchAndAssertEquals(function() {
5661-  COUNTUNIQUE();
5662-}, ERRORS.NA_ERROR);
5663-
5664-
5665-// Test DEGREES
5666-assertEquals(DEGREES(PI()), 180);
5667-assertEquals(DEGREES([PI(), "str"]), 180);
5668-assertEquals(DEGREES(false), 0);
5669-assertEquals(DEGREES(true), 57.29577951308232);
5670-assertEquals(DEGREES(1), 57.29577951308232);
5671-assertEquals(DEGREES(12), 687.5493541569879);
5672-catchAndAssertEquals(function() {
5673-  DEGREES("str");
5674-}, ERRORS.VALUE_ERROR);
5675-catchAndAssertEquals(function() {
5676-  DEGREES();
5677-}, ERRORS.NA_ERROR);
5678-catchAndAssertEquals(function() {
5679-  DEGREES(10, 10);
5680-}, ERRORS.NA_ERROR);
5681-
5682-
5683-// Test ERF
5684-assertEquals(ERF(2), 0.9953222650189527);
5685-assertEquals(ERF("2"), 0.9953222650189527);
5686-assertEquals(ERF(0), 1.1102230246251565e-16);
5687-assertEquals(ERF(1), 0.8427007929497149);
5688-assertEquals(ERF(true), 0.8427007929497149);
5689-assertEquals(ERF(false), 1.1102230246251565e-16);
5690-catchAndAssertEquals(function() {
5691-  ERF();
5692-}, ERRORS.NA_ERROR);
5693-catchAndAssertEquals(function() {
5694-  ERF([]);
5695-}, ERRORS.REF_ERROR);
5696-assertEquals(ERF(1, 2), 0.15262147206923782);
5697-assertEquals(ERF(2, 1), -0.15262147206923782);
5698-
5699-
5700-// Test ERFC
5701-assertEquals(ERFC(2), 0.004677734981047288);
5702-assertEquals(ERFC("2"), 0.004677734981047288);
5703-assertEquals(ERFC(0), 1);
5704-assertEquals(ERFC(1), 0.1572992070502851);
5705-assertEquals(ERFC(-1), 1.842700792949715);
5706-assertEquals(ERFC(-10), 2);
5707-catchAndAssertEquals(function() {
5708-  ERFC();
5709-}, ERRORS.NA_ERROR);
5710-catchAndAssertEquals(function() {
5711-  ERFC([]);
5712-}, ERRORS.REF_ERROR);
5713-
5714-
5715-
5716-// Test EVEN
5717-assertEquals(EVEN(3), 4);
5718-assertEquals(EVEN(4), 4);
5719-assertEquals(EVEN(5), 6);
5720-assertEquals(EVEN("4"), 4);
5721-assertEquals(EVEN(false), 0);
5722-assertEquals(EVEN(true), 2);
5723-assertEquals(EVEN([11, 22]), 12);
5724-assertEquals(EVEN([10, 22, "str"]), 10);
5725-catchAndAssertEquals(function() {
5726-  EVEN();
5727-}, ERRORS.NA_ERROR);
5728-catchAndAssertEquals(function() {
5729-  EVEN(1, 2, 3);
5730-}, ERRORS.NA_ERROR);
5731-catchAndAssertEquals(function() {
5732-  EVEN("str");
5733-}, ERRORS.VALUE_ERROR);
5734-
5735-
5736-// Test FLOOR
5737-assertEquals(FLOOR(10.1), 10);
5738-assertEquals(FLOOR("10.1"), 10);
5739-assertEquals(FLOOR(10.11111111, 0.1), 10.1);
5740-assertEquals(FLOOR(10.22222222, 0.1), 10.2);
5741-assertEquals(FLOOR(10.33333333, 0.2), 10.2);
5742-assertEquals(FLOOR(10.33333333, 0.1), 10.3);
5743-assertEquals(FLOOR([10.33333333], 0.1), 10.3);
5744-assertEquals(FLOOR(10.22222222, 5), 10);
5745-assertEquals(FLOOR(10.22222222, 8), 8);
5746-assertEquals(FLOOR(10.22222222, true), 10);
5747-catchAndAssertEquals(function() {
5748-  FLOOR(10, 0);
5749-}, ERRORS.DIV_ZERO_ERROR);
5750-catchAndAssertEquals(function() {
5751-  FLOOR(10, 1, 2);
5752-}, ERRORS.NA_ERROR);
5753-catchAndAssertEquals(function() {
5754-  FLOOR();
5755-}, ERRORS.NA_ERROR);
5756-
5757-
5758-// Test IF
5759-assertEquals(IF(true, "hit", "miss"), "hit");
5760-assertEquals(IF(false, "hit", "miss"), "miss");
5761-assertEquals(IF("", "hit", "miss"), "miss");
5762-assertEquals(IF("", "hit", "miss"), "miss");
5763-assertEquals(IF([true], "hit", "miss"), "hit");
5764-assertEquals(IF([false], "hit", "miss"), "miss");
5765-assertEquals(IF([""], "hit", "miss"), "miss");
5766-assertEquals(IF([""], "hit", "miss"), "miss");
5767-catchAndAssertEquals(function() {
5768-  IF("str", 1, 2);
5769-}, ERRORS.VALUE_ERROR);
5770-catchAndAssertEquals(function() {
5771-  IF([], 1, 2);
5772-}, ERRORS.REF_ERROR);
5773-
5774-
5775-// Test INT
5776-assertEquals(INT(99.33), 99);
5777-assertEquals(INT(99.99), 99);
5778-assertEquals(INT(true), 1);
5779-assertEquals(INT(false), 0);
5780-assertEquals(INT(""), 0);
5781-assertEquals(INT([1.1, "str"]), 1);
5782-catchAndAssertEquals(function() {
5783-  INT(100, 10);
5784-}, ERRORS.NA_ERROR);
5785-catchAndAssertEquals(function() {
5786-  INT();
5787-}, ERRORS.NA_ERROR);
5788-catchAndAssertEquals(function() {
5789-  INT("str");
5790-}, ERRORS.VALUE_ERROR);
5791-
5792-
5793-// Test ISEVEN
5794-assertEquals(ISEVEN(4), true);
5795-assertEquals(ISEVEN(3), false);
5796-assertEquals(ISEVEN(4.1), true);
5797-assertEquals(ISEVEN(false), true);
5798-assertEquals(ISEVEN(true), false);
5799-assertEquals(ISEVEN([4]), true);
5800-catchAndAssertEquals(function() {
5801-  ISEVEN(100, 10);
5802-}, ERRORS.NA_ERROR);
5803-catchAndAssertEquals(function() {
5804-  ISEVEN();
5805-}, ERRORS.NA_ERROR);
5806-catchAndAssertEquals(function() {
5807-  ISEVEN("");
5808-}, ERRORS.VALUE_ERROR);
5809-
5810-
5811-// Test ISODD
5812-assertEquals(ISODD(4), false);
5813-assertEquals(ISODD(3), true);
5814-assertEquals(ISODD(4.1), false);
5815-assertEquals(ISODD(false), false);
5816-assertEquals(ISODD(true), true);
5817-assertEquals(ISODD([4]), false);
5818-catchAndAssertEquals(function() {
5819-  ISODD(100, 10);
5820-}, ERRORS.NA_ERROR);
5821-catchAndAssertEquals(function() {
5822-  ISODD();
5823-}, ERRORS.NA_ERROR);
5824-catchAndAssertEquals(function() {
5825-  ISODD("");
5826-}, ERRORS.VALUE_ERROR);
5827-
5828-
5829-// Test LN
5830-assertEquals(LN(100), 4.605170185988092);
5831-assertEquals(LN("100"), 4.605170185988092);
5832-assertEquals(LN(1), 0);
5833-assertEquals(LN(true), 0);
5834-catchAndAssertEquals(function() {
5835-  LN(false);
5836-}, ERRORS.NUM_ERROR);
5837-catchAndAssertEquals(function() {
5838-  LN("str");
5839-}, ERRORS.VALUE_ERROR);
5840-catchAndAssertEquals(function() {
5841-  LN();
5842-}, ERRORS.NA_ERROR);
5843-catchAndAssertEquals(function() {
5844-  LN(10, 10);
5845-}, ERRORS.NA_ERROR);
5846-
5847-
5848-// Test LOG
5849-assertEquals(LOG(256, 2), 8);
5850-assertEquals(LOG(100), 2);
5851-assertEquals(LOG(100), 2);
5852-assertEquals(LOG(256, 10), 2.408239965311849);
5853-assertEquals(LOG(256), 2.408239965311849);
5854-assertEquals(LOG("100"), 2);
5855-assertEquals(LOG(1, 2), 0);
5856-catchAndAssertEquals(function() {
5857-  LOG("str");
5858-}, ERRORS.VALUE_ERROR);
5859-catchAndAssertEquals(function() {
5860-  LOG(256, 0);
5861-}, ERRORS.NUM_ERROR);
5862-catchAndAssertEquals(function() {
5863-  LOG(256, 1);
5864-}, ERRORS.DIV_ZERO_ERROR);
5865-catchAndAssertEquals(function() {
5866-  LOG(256, false);
5867-}, ERRORS.NUM_ERROR);
5868-catchAndAssertEquals(function() {
5869-  LOG(256, true);
5870-}, ERRORS.DIV_ZERO_ERROR);
5871-
5872-
5873-// Test LOG10
5874-assertEquals(LOG10(100), 2);
5875-assertEquals(LOG10("100"), 2);
5876-assertEquals(LOG10(1), 0);
5877-assertEquals(LOG10(10.1), 1.0043213737826424);
5878-catchAndAssertEquals(function() {
5879-  LOG10(false);
5880-}, ERRORS.NUM_ERROR);
5881-catchAndAssertEquals(function() {
5882-  LOG10("");
5883-}, ERRORS.NUM_ERROR);
5884-catchAndAssertEquals(function() {
5885-  LOG10("str");
5886-}, ERRORS.VALUE_ERROR);
5887-catchAndAssertEquals(function() {
5888-  LOG10();
5889-}, ERRORS.NA_ERROR);
5890-catchAndAssertEquals(function() {
5891-  LOG10(10, 10);
5892-}, ERRORS.NA_ERROR);
5893-
5894-
5895-// Test MOD
5896-assertEquals(MOD(10, 3), 1);
5897-catchAndAssertEquals(function() {
5898-  MOD(10, 3, 10);
5899-}, ERRORS.NA_ERROR);
5900-catchAndAssertEquals(function() {
5901-  MOD([10, 3]);
5902-}, ERRORS.NA_ERROR);
5903-catchAndAssertEquals(function() {
5904-  MOD(0, 0);
5905-}, ERRORS.DIV_ZERO_ERROR);
5906-catchAndAssertEquals(function() {
5907-  MOD(10);
5908-}, ERRORS.NA_ERROR);
5909-catchAndAssertEquals(function() {
5910-  MOD(10, false);
5911-}, ERRORS.DIV_ZERO_ERROR);
5912-catchAndAssertEquals(function() {
5913-  MOD(10, 0);
5914-}, ERRORS.DIV_ZERO_ERROR);
5915-catchAndAssertEquals(function() {
5916-  MOD(10, "str");
5917-}, ERRORS.VALUE_ERROR);
5918-assertEquals(MOD(10, "3"), 1);
5919-assertEquals(MOD(10.1, 3), 1.0999999999999996);
5920-assertEquals(MOD(10, 3.1), 0.6999999999999997);
5921-
5922-
5923-
5924-// Test ODD
5925-assertEquals(ODD(2), 3);
5926-assertEquals(ODD(4), 5);
5927-assertEquals(ODD(5), 5);
5928-assertEquals(ODD("4"), 5);
5929-assertEquals(ODD(false), 1);
5930-assertEquals(ODD(true), 1);
5931-assertEquals(ODD([10, 22]), 11);
5932-assertEquals(ODD([10, 22, "str"]), 11);
5933-catchAndAssertEquals(function() {
5934-  ODD();
5935-}, ERRORS.NA_ERROR);
5936-catchAndAssertEquals(function() {
5937-  ODD(1, 2, 3);
5938-}, ERRORS.NA_ERROR);
5939-catchAndAssertEquals(function() {
5940-  ODD("str");
5941-}, ERRORS.VALUE_ERROR);
5942-
5943-
5944-// Test PI
5945-assertEquals(PI(), 3.141592653589793);
5946-
5947-
5948-// Test POWER
5949-assertEquals(POWER(4, 10), 1048576);
5950-assertEquals(POWER(4, false), 1);
5951-assertEquals(POWER(4, true), 4);
5952-assertEquals(POWER([4], [10]), 1048576);
5953-assertEquals(POWER([4], [10, "str"]), 1048576);
5954-catchAndAssertEquals(function() {
5955-  POWER(4, "str");
5956-}, ERRORS.VALUE_ERROR);
5957-catchAndAssertEquals(function() {
5958-  POWER();
5959-}, ERRORS.NA_ERROR);
5960-catchAndAssertEquals(function() {
5961-  POWER(4);
5962-}, ERRORS.NA_ERROR);
5963-catchAndAssertEquals(function() {
5964-  POWER(4, 10, 22);
5965-}, ERRORS.NA_ERROR);
5966-
5967-
5968-// Test RADIANS
5969-assertEquals(RADIANS(180), 3.141592653589793);
5970-assertEquals(RADIANS(false), 0);
5971-assertEquals(RADIANS(true), 0.017453292519943295);
5972-catchAndAssertEquals(function() {
5973-  RADIANS("str");
5974-}, ERRORS.VALUE_ERROR);
5975-catchAndAssertEquals(function() {
5976-  RADIANS();
5977-}, ERRORS.NA_ERROR);
5978-catchAndAssertEquals(function() {
5979-  RADIANS(4, 10);
5980-}, ERRORS.NA_ERROR);
5981-
5982-
5983-// Test ROUND
5984-assertEquals(ROUND(99.44, 1), 99.4);
5985-assertEquals(ROUND(99.44, 0), 99);
5986-assertEquals(ROUND(99.4444444444444, 9), 99.444444444);
5987-assertEquals(ROUND(99.44), 99);
5988-assertEquals(ROUND("99.44"), 99);
5989-assertEquals(ROUND([99.44, 22.222], [1, 4]), 99.4);
5990-catchAndAssertEquals(function() {
5991-  ROUND();
5992-}, ERRORS.NA_ERROR);
5993-catchAndAssertEquals(function() {
5994-  ROUND(99.44, 1, 44);
5995-}, ERRORS.NA_ERROR);
5996-catchAndAssertEquals(function() {
5997-  ROUND(99.999, "str");
5998-}, ERRORS.VALUE_ERROR);
5999-
6000-
6001-// Test ROUNDDOWN
6002-assertEquals(ROUNDDOWN(99.46, 1), 99.4);
6003-assertEquals(ROUNDDOWN(99.99, 1), 99.9);
6004-assertEquals(ROUNDDOWN(99.5555555555555, 9), 99.555555555);
6005-assertEquals(ROUNDDOWN(99.99), 99);
6006-assertEquals(ROUNDDOWN("99.99"), 99);
6007-assertEquals(ROUNDDOWN([99.46666, 22.222], [1, 4]), 99.4);
6008-catchAndAssertEquals(function() {
6009-  ROUNDDOWN();
6010-}, ERRORS.NA_ERROR);
6011-catchAndAssertEquals(function() {
6012-  ROUNDDOWN(99.44, 1, 44);
6013-}, ERRORS.NA_ERROR);
6014-catchAndAssertEquals(function() {
6015-  ROUNDDOWN(99.999, "str");
6016-}, ERRORS.VALUE_ERROR);
6017-
6018-
6019-// Test ROUNDUP
6020-assertEquals(ROUNDUP(99.46, 1), 99.5);
6021-assertEquals(ROUNDUP(99.99, 1), 100);
6022-assertEquals(ROUNDUP(99.5555555555555, 9), 99.555555556);
6023-assertEquals(ROUNDUP(99.99), 100);
6024-assertEquals(ROUNDUP("99.99"), 100);
6025-assertEquals(ROUNDUP([99.46666, 22.222], [1, 4]), 99.5);
6026-catchAndAssertEquals(function() {
6027-  ROUNDUP();
6028-}, ERRORS.NA_ERROR);
6029-catchAndAssertEquals(function() {
6030-  ROUNDUP(99.44, 1, 44);
6031-}, ERRORS.NA_ERROR);
6032-catchAndAssertEquals(function() {
6033-  ROUNDUP(99.999, "str");
6034-}, ERRORS.VALUE_ERROR);
6035-
6036-
6037-// Test SIN
6038-assertEquals(SIN(0), 0);
6039-assertEquals(SIN(1), 0.8414709848078965);
6040-assertEquals(SIN(PI() / 2), 1);
6041-assertEquals(SIN(PI()), 0);
6042-assertEquals(SIN(true), 0.8414709848078965);
6043-assertEquals(SIN(false), 0);
6044-assertEquals(SIN("0"), 0);
6045-assertEquals(SIN(""), 0);
6046-catchAndAssertEquals(function() {
6047-  SIN("str");
6048-}, ERRORS.VALUE_ERROR);
6049-assertEquals(SIN([1]), 0.8414709848078965);
6050-assertEquals(SIN([[1]]), 0.8414709848078965);
6051-assertEquals(SIN([1, "str"]), 0.8414709848078965);
6052-
6053-
6054-// Test SINH
6055-assertEquals(SINH(PI()), 11.548739357257748);
6056-assertEquals(SINH(1), 1.1752011936438014);
6057-assertEquals(SINH(false), 0);
6058-assertEquals(SINH(true), 1.1752011936438014);
6059-assertEquals(SINH(""), 0);
6060-assertEquals(SINH("0"), 0);
6061-catchAndAssertEquals(function() {
6062-  SINH("str");
6063-}, ERRORS.VALUE_ERROR);
6064-assertEquals(SINH([10]), 11013.232874703393);
6065-assertEquals(SINH([[10]]), 11013.232874703393);
6066-catchAndAssertEquals(function() {
6067-  SIN([[]]);
6068-}, ERRORS.REF_ERROR);
6069-assertEquals(SINH([[10, "str"]]), 11013.232874703393);
6070-
6071-
6072-// Test SQRT
6073-assertEquals(SQRT(9), 3);
6074-assertEquals(SQRT("9"), 3);
6075-assertEquals(SQRT(4), 2);
6076-assertEquals(SQRT(false), 0);
6077-assertEquals(SQRT(true), 1);
6078-assertEquals(SQRT(""), 0);
6079-catchAndAssertEquals(function() {
6080-  SQRT("str");
6081-}, ERRORS.VALUE_ERROR);
6082-catchAndAssertEquals(function() {
6083-  SQRT(-9);
6084-}, ERRORS.VALUE_ERROR);
6085-catchAndAssertEquals(function() {
6086-  SQRT();
6087-}, ERRORS.NA_ERROR);
6088-catchAndAssertEquals(function() {
6089-  SQRT(4, 4);
6090-}, ERRORS.NA_ERROR);
6091-
6092-
6093-// Test SQRTPI
6094-assertEquals(SQRTPI(9), 5.317361552716548);
6095-assertEquals(SQRTPI("9"), 5.317361552716548);
6096-assertEquals(SQRTPI([9]), 5.317361552716548);
6097-assertEquals(SQRTPI(0), 0);
6098-assertEquals(SQRTPI(1), 1.7724538509055159);
6099-assertEquals(SQRTPI(""), 0);
6100-catchAndAssertEquals(function() {
6101-  SQRTPI("str");
6102-}, ERRORS.VALUE_ERROR);
6103-catchAndAssertEquals(function() {
6104-  SQRTPI(-1);
6105-}, ERRORS.NUM_ERROR);
6106-catchAndAssertEquals(function() {
6107-  SQRTPI();
6108-}, ERRORS.NA_ERROR);
6109-catchAndAssertEquals(function() {
6110-  SQRTPI(4, 4);
6111-}, ERRORS.NA_ERROR);
6112-
6113-
6114-// Test SUM
6115-assertEquals(SUM(10), 10);
6116-assertEquals(SUM(10, 10), 20);
6117-assertEquals(SUM(10, [5, 5]), 20);
6118-assertEquals(SUM("10", [5, 5]), 20);
6119-assertEquals(SUM(false, [10, 10]), 20);
6120-assertEquals(SUM(true, [10, 10]), 21);
6121-catchAndAssertEquals(function() {
6122-  SUM([10, 10], "");
6123-}, ERRORS.VALUE_ERROR);
6124-catchAndAssertEquals(function() {
6125-  SUM([10, 10], "str");
6126-}, ERRORS.VALUE_ERROR);
6127-catchAndAssertEquals(function() {
6128-  SUM();
6129-}, ERRORS.NA_ERROR);
6130-
6131-
6132-// Test SUMIF
6133-assertEquals(SUMIF([1, 5, 10], 5), 5);
6134-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], 5), 20);
6135-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], 10), 10);
6136-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">5"), 10);
6137-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=5"), 20);
6138-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=1"), 1);
6139-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=     1  "), 1);
6140-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">0"), 31);
6141-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">=5"), 30);
6142-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "<10"), 21);
6143-assertEquals(SUMIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 31);
6144-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">4.99"), 30);
6145-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
6146-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
6147-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=>5"), 0);
6148-assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "==5"), 0);
6149-assertEquals(SUMIF(["m", "m", 3, 11, true], "m"), 0);
6150-assertEquals(SUMIF(["m", "p", "m"], "m", [1, 1, 1]), 2);
6151-assertEquals(SUMIF(["p", "p", "p"], "m", [1, 1, 1]), 0);
6152-assertEquals(SUMIF(["p", "p", "p"], "", [1, 1, 1]), 0);
6153-assertEquals(SUMIF(["p", "p", "p"], "*", [1, 1, 1]), 3);
6154-assertEquals(SUMIF(["mom", "pop", "pap"], "*o*", [1, 1, 1]), 2);
6155-assertEquals(SUMIF(["mom", "pop", "pap"], "*a*", [1, 1, 1]), 1);
6156-assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1, 1]), 2);
6157-assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1, 1]), 2);
6158-assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1,]), 1);
6159-assertEquals(SUMIF(["pop", "pap"], "p*p", [1, 2, 4]), 3);
6160-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "boom"], "*o*", [1, 1, 1, 1, 1]), 3);
6161-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "mom", [1, 1, 1, 1, 1]), 2);
6162-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "?o?", [1, 1, 1, 1, 1]), 3);
6163-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "???", [1, 1, 1, 1, 1]), 5);
6164-assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "????", [1, 1, 1, 1, 1]), 0);
6165-assertEquals(SUMIF([0, 1, 0, 1], "=1", [1, 2, 4, 8]), 10);
6166-catchAndAssertEquals(function() {
6167-  SUMIF([0, 1, 0, 1]);
6168-}, ERRORS.NA_ERROR);
6169-catchAndAssertEquals(function() {
6170-  SUMIF();
6171-}, ERRORS.NA_ERROR);
6172-catchAndAssertEquals(function() {
6173-  SUMIF([], "=1", [], true);
6174-}, ERRORS.NA_ERROR);
6175-
6176-
6177-// Test SUMPRODUCT
6178-assertEquals(SUMPRODUCT([1, 5, 10], [2, 2, 2]), 32);
6179-assertEquals(SUMPRODUCT([1, 5, 10], [2, 2, 2], [2, 2, 2]), 64);
6180-assertEquals(SUMPRODUCT([1, 5, 10], [1, 2, 2], [1, 4, 4]), 121);
6181-assertEquals(SUMPRODUCT([1, 5, 10]), 16);
6182-assertEquals(SUMPRODUCT([1, 5, 10, ""]), 16);
6183-assertEquals(SUMPRODUCT([1, 5, 10, 200], [2, 2, 2, ""]), 32);
6184-assertEquals(SUMPRODUCT([1, 5, 10, "str"]), 16);
6185-assertEquals(SUMPRODUCT([10, 10, 22, "str"], [2, 2, [2, 2]]), 84);
6186-assertEquals(SUMPRODUCT(1, 5, 10), 50);
6187-assertEquals(SUMPRODUCT([1, 5, 10]), 16);
6188-catchAndAssertEquals(function() {
6189-  SUMPRODUCT([1, 5, 10], [2, 2]);
6190-}, ERRORS.VALUE_ERROR);
6191-catchAndAssertEquals(function() {
6192-  SUMPRODUCT([1, 5, 10], [2, 2, 2, []]);
6193-}, ERRORS.REF_ERROR);
6194-catchAndAssertEquals(function() {
6195-  SUMPRODUCT();
6196-}, ERRORS.NA_ERROR);
6197-
6198-
6199-
6200-// Test SUMSQ
6201-assertEquals(SUMSQ([1, 5, 10], 10), 226);
6202-assertEquals(SUMSQ([10, 10, 22, ""]), 684);
6203-assertEquals(SUMSQ(10, 10, 22), 684);
6204-assertEquals(SUMSQ(10, 10, "22", true), 685);
6205-assertEquals(SUMSQ(10, 10, "22", false), 684);
6206-assertEquals(SUMSQ([10, 10, 22, true]), 684);
6207-catchAndAssertEquals(function() {
6208-  SUMSQ([10, 10, 22, "", []]);
6209-}, ERRORS.REF_ERROR);
6210-catchAndAssertEquals(function() {
6211-  SUMSQ([]);
6212-}, ERRORS.REF_ERROR);
6213-catchAndAssertEquals(function() {
6214-  SUMSQ();
6215-}, ERRORS.NA_ERROR);
6216-
6217-
6218-// Test SUMX2MY2
6219-assertEquals(SUMX2MY2([1,2,3],[4,5,6]), -63);
6220-assertEquals(SUMX2MY2([1, 2, 3], [[4, 5], [6]]), -63);
6221-assertEquals(SUMX2MY2(["1",2,3],[4,5,6]), -48);
6222-assertEquals(SUMX2MY2(["",2,3],[4,5,6]), -48);
6223-assertEquals(SUMX2MY2([false,2,3],[4,5,6]), -48);
6224-assertEquals(SUMX2MY2([true,2,3],[4,5,6]), -48);
6225-catchAndAssertEquals(function() {
6226-  SUMX2MY2([1,2,3],[4,5, []]);
6227-}, ERRORS.REF_ERROR);
6228-catchAndAssertEquals(function() {
6229-  SUMX2MY2([1,2,3],[4,5]);
6230-}, ERRORS.NA_ERROR);
6231-catchAndAssertEquals(function() {
6232-  SUMX2MY2();
6233-}, ERRORS.NA_ERROR);
6234-
6235-
6236-// Test SUMX2PY2
6237-assertEquals(SUMX2PY2([1, 2, 3], [4, 5, 6]), 91);
6238-assertEquals(SUMX2PY2([1, 2, 3], [[4, 5], [6]]), 91);
6239-assertEquals(SUMX2PY2(["1",2,3],[4,5,6]), 74);
6240-assertEquals(SUMX2PY2(["",2,3],[4,5,6]), 74);
6241-assertEquals(SUMX2PY2([false,2,3],[4,5,6]), 74);
6242-assertEquals(SUMX2PY2([true,2,3],[4,5,6]), 74);
6243-catchAndAssertEquals(function() {
6244-  SUMX2PY2([1,2,3],[4,5, []]);
6245-}, ERRORS.REF_ERROR);
6246-catchAndAssertEquals(function() {
6247-  SUMX2PY2([1,2,3],[4,5]);
6248-}, ERRORS.NA_ERROR);
6249-catchAndAssertEquals(function() {
6250-  SUMX2PY2();
6251-}, ERRORS.NA_ERROR);
6252-
6253-
6254-// Test TAN
6255-assertEquals(TAN(0), 0);
6256-assertEquals(TAN(1), 1.5574077246549023);
6257-assertEquals(TAN(PI() / 2), 16331239353195370);
6258-assertEquals(TAN(PI()), 0);
6259-assertEquals(TAN(false), 0);
6260-assertEquals(TAN(true), 1.5574077246549023);
6261-assertEquals(TAN(""), 0);
6262-assertEquals(TAN("0"), 0);
6263-catchAndAssertEquals(function() {
6264-  TAN("str");
6265-}, ERRORS.VALUE_ERROR);
6266-catchAndAssertEquals(function() {
6267-  TAN();
6268-}, ERRORS.NA_ERROR);
6269-catchAndAssertEquals(function() {
6270-  TAN(1, 1);
6271-}, ERRORS.NA_ERROR);
6272-assertEquals(TAN([1, 44]), 1.5574077246549023);
6273-assertEquals(TAN([1, "str"]), 1.5574077246549023);
6274-
6275-
6276-// Test TANH
6277-assertEquals(TANH(0), 0);
6278-assertEquals(TANH(1), 0.7615941559557649);
6279-assertEquals(TANH(PI() / 2), 0.9171523356672744);
6280-assertEquals(TANH(PI()), 0.9962720762207501);
6281-assertEquals(TANH(false), 0);
6282-assertEquals(TANH(true), 0.7615941559557649);
6283-assertEquals(TANH(""), 0);
6284-assertEquals(TANH("0"), 0);
6285-catchAndAssertEquals(function() {
6286-  TANH("str");
6287-}, ERRORS.VALUE_ERROR);
6288-catchAndAssertEquals(function() {
6289-  TANH();
6290-}, ERRORS.NA_ERROR);
6291-catchAndAssertEquals(function() {
6292-  TANH(1, 1);
6293-}, ERRORS.NA_ERROR);
6294-assertEquals(TANH([1, 44]), 0.7615941559557649);
6295-assertEquals(TANH([1, "str"]), 0.7615941559557649);
6296-
6297-
6298-// Test TRUNC
6299-assertEquals(TRUNC(PI(), 2), 3.14);
6300-assertEquals(TRUNC("3.141592653589793", "2"), 3.14);
6301-assertEquals(TRUNC(PI(), 1), 3.1);
6302-assertEquals(TRUNC(PI(), 0), 3);
6303-assertEquals(TRUNC(PI(), false), 3);
6304-assertEquals(TRUNC(PI(), -1), 0);
6305-assertEquals(TRUNC(31.41592653589793, -1), 30);
6306-assertEquals(TRUNC([31.41592653589793], [-1]), 30);
6307-assertEquals(TRUNC(31111.41592653589793, -4), 30000);
6308-assertEquals(TRUNC(31111.41592653589793, -2), 31100);
6309-catchAndAssertEquals(function() {
6310-  TRUNC();
6311-}, ERRORS.NA_ERROR);
6312-catchAndAssertEquals(function() {
6313-  TRUNC(3.1, 1, 1);
6314-}, ERRORS.NA_ERROR);
6315+test("ABS", function(){
6316+  assertEquals(ABS(-10), 10);
6317+  assertEquals(ABS(-10.111), 10.111);
6318+  assertEquals(ABS(0), 0);
6319+  assertEquals(ABS(false), 0);
6320+  assertEquals(ABS("-44"), 44);
6321+  catchAndAssertEquals(function() {
6322+    ABS();
6323+  }, ERRORS.NA_ERROR);
6324+  catchAndAssertEquals(function() {
6325+    ABS("str");
6326+  }, ERRORS.VALUE_ERROR);
6327+});
6328+
6329+
6330+test("ACOS", function(){
6331+  assertEquals(ACOS(0), 1.5707963267948966);
6332+  assertEquals(ACOS(-1), 3.141592653589793);
6333+  assertEquals(ACOS(1), 0);
6334+  assertEquals(ACOS("-1"), 3.141592653589793);
6335+  assertEquals(ACOS(false), 1.5707963267948966);
6336+  catchAndAssertEquals(function() {
6337+    ACOS("str");
6338+  }, ERRORS.VALUE_ERROR);
6339+  catchAndAssertEquals(function() {
6340+    ACOS(2);
6341+  }, ERRORS.NUM_ERROR);
6342+});
6343+
6344+
6345+test("ACOSH", function(){
6346+  assertEquals(ACOSH(22), 3.783672704329451);
6347+  assertEquals(ACOSH(1), 0);
6348+  assertEquals(ACOSH("11"), 3.0889699048446033);
6349+  catchAndAssertEquals(function() {
6350+    ACOSH(-1);
6351+  }, ERRORS.NUM_ERROR);
6352+  catchAndAssertEquals(function() {
6353+    ACOSH("str");
6354+  }, ERRORS.VALUE_ERROR);
6355+  catchAndAssertEquals(function() {
6356+    ACOSH(false);
6357+  }, ERRORS.NUM_ERROR);
6358+});
6359+
6360+
6361+test("ACOTH", function(){
6362+  assertEquals(ACOTH(22), 0.04548588910286339);
6363+  assertEquals(ACOTH(-1.1), -1.522261218861711);
6364+  assertEquals(ACOTH("-22"), -0.04548588910286338);
6365+  catchAndAssertEquals(function() {
6366+    ACOTH(-1);
6367+  }, ERRORS.NUM_ERROR);
6368+  catchAndAssertEquals(function() {
6369+    ACOTH("str");
6370+  }, ERRORS.VALUE_ERROR);
6371+  catchAndAssertEquals(function() {
6372+    ACOTH(false);
6373+  }, ERRORS.NUM_ERROR);
6374+});
6375+
6376+
6377+test("ASIN", function(){
6378+  assertEquals(ASIN(0), 0);
6379+  assertEquals(ASIN(1), 1.5707963267948966);
6380+  assertEquals(ASIN("1"), 1.5707963267948966);
6381+  assertEquals(ASIN(false), 0);
6382+  catchAndAssertEquals(function() {
6383+    ASIN(2);
6384+  }, ERRORS.NUM_ERROR);
6385+  catchAndAssertEquals(function() {
6386+    ASIN("str");
6387+  }, ERRORS.VALUE_ERROR);
6388+});
6389+
6390+
6391+test("ASINH", function(){
6392+  assertEquals(ASINH(1), 0.8813735870195429);
6393+  assertEquals(ASINH(0), 0);
6394+  assertEquals(ASINH("1"), 0.8813735870195429);
6395+  assertEquals(ASINH(false), 0);
6396+  assertEquals(ASINH(true), 0.8813735870195429);
6397+  catchAndAssertEquals(function() {
6398+    ASINH("str");
6399+  }, ERRORS.VALUE_ERROR);
6400+});
6401+
6402+
6403+test("ATAN", function(){
6404+  assertEquals(ATAN(1), 0.7853981633974483);
6405+  assertEquals(ATAN(0), 0);
6406+  assertEquals(ATAN("1"), 0.7853981633974483);
6407+  assertEquals(ATAN(false), 0);
6408+  assertEquals(ATAN(true), 0.7853981633974483);
6409+  catchAndAssertEquals(function() {
6410+    ASINH("str");
6411+  }, ERRORS.VALUE_ERROR);
6412+});
6413+
6414+
6415+test("ATAN2", function(){
6416+  assertEquals(ATAN2(4, 3), 0.6435011087932844);
6417+  assertEquals(ATAN2(-1, -1), -2.356194490192345);
6418+  catchAndAssertEquals(function() {
6419+    ATAN2(0, 0);
6420+  }, ERRORS.DIV_ZERO_ERROR);
6421+  assertEquals(ATAN2(1, 0), 0);
6422+  assertEquals(ATAN2(0, 1), 1.5707963267948966);
6423+  assertEquals(ATAN2(-1, "-1"), -2.356194490192345);
6424+  assertEquals(ATAN2(true, false), 0);
6425+  assertEquals(ATAN2(true, true), 0.7853981633974483);
6426+  catchAndAssertEquals(function() {
6427+    ATAN2("str", false);
6428+  }, ERRORS.VALUE_ERROR);
6429+});
6430+
6431+
6432+test("ATANH", function(){
6433+  assertEquals(ATANH(0.51), 0.5627297693521489);
6434+  assertEquals(ATANH(0.44), 0.47223080442042564);
6435+  assertEquals(ATANH(0), 0);
6436+  assertEquals(ATANH("0.1"), 0.10033534773107562);
6437+  assertEquals(ATANH(false), 0);
6438+  catchAndAssertEquals(function() {
6439+    ATANH(true);
6440+  }, ERRORS.NUM_ERROR);
6441+  catchAndAssertEquals(function() {
6442+    ATANH("str");
6443+  }, ERRORS.VALUE_ERROR);
6444+});
6445+
6446+
6447+test("CEILING", function(){
6448+  assertEquals(CEILING(10.1), 11);
6449+  assertEquals(CEILING("10.1"), 11);
6450+  assertEquals(CEILING(10.11111111, 0.1), 10.2);
6451+  assertEquals(CEILING(10.22222222, 0.1), 10.3);
6452+  assertEquals(CEILING(10.33333333, 0.2), 10.4);
6453+  assertEquals(CEILING(10.33333333, 0.1), 10.4);
6454+  assertEquals(CEILING([10.33333333], 0.1), 10.4);
6455+  assertEquals(CEILING(10.22222222, 5), 15);
6456+  assertEquals(CEILING(10.22222222, 8), 16);
6457+  assertEquals(CEILING(10.22222222, true), 11);
6458+  catchAndAssertEquals(function() {
6459+    CEILING(10, 0);
6460+  }, ERRORS.DIV_ZERO_ERROR);
6461+  catchAndAssertEquals(function() {
6462+    CEILING(10, 1, 2);
6463+  }, ERRORS.NA_ERROR);
6464+  catchAndAssertEquals(function() {
6465+    CEILING();
6466+  }, ERRORS.NA_ERROR);
6467+});
6468+
6469+
6470+test("COMBIN", function(){
6471+  assertEquals(COMBIN(4, 2), 6);
6472+  assertEquals(COMBIN(4.999, 2.888), 6);
6473+  assertEquals(COMBIN([4, "str"], [2]), 6);
6474+  assertEquals(COMBIN(0, 0), 1);
6475+  catchAndAssertEquals(function() {
6476+    COMBIN(2, "str");
6477+  }, ERRORS.VALUE_ERROR);
6478+  catchAndAssertEquals(function() {
6479+    COMBIN(2, []);
6480+  }, ERRORS.REF_ERROR);
6481+  catchAndAssertEquals(function() {
6482+    COMBIN(2, 4);
6483+  }, ERRORS.NUM_ERROR);
6484+  catchAndAssertEquals(function() {
6485+    COMBIN(0, 1);
6486+  }, ERRORS.NUM_ERROR);
6487+  catchAndAssertEquals(function() {
6488+    COMBIN();
6489+  }, ERRORS.NA_ERROR);
6490+  catchAndAssertEquals(function() {
6491+    COMBIN(4);
6492+  }, ERRORS.NA_ERROR);
6493+  catchAndAssertEquals(function() {
6494+    COMBIN(4, 2, 66);
6495+  }, ERRORS.NA_ERROR);
6496+});
6497+
6498+
6499+test("COS", function(){
6500+  assertEquals(COS(PI()), -1);
6501+  assertEquals(COS(1), 0.5403023058681398);
6502+  assertEquals(COS(false), 1);
6503+  assertEquals(COS(true), 0.5403023058681398);
6504+  assertEquals(COS(""), 1);
6505+  assertEquals(COS("0"), 1);
6506+  catchAndAssertEquals(function() {
6507+    COS("str");
6508+  }, ERRORS.VALUE_ERROR);
6509+  catchAndAssertEquals(function() {
6510+    COS();
6511+  }, ERRORS.NA_ERROR);
6512+  catchAndAssertEquals(function() {
6513+    COS(1, 1);
6514+  }, ERRORS.NA_ERROR);
6515+  assertEquals(COS([0, "str"]), 1);
6516+});
6517+
6518+
6519+test("COSH", function(){
6520+  assertEquals(COSH(PI()), 11.591953275521522);
6521+  assertEquals(COSH(1), 1.5430806348152437);
6522+  assertEquals(COSH(false), 1);
6523+  assertEquals(COSH(0), 1);
6524+  assertEquals(COSH(true), 1.5430806348152437);
6525+  assertEquals(COSH(""), 1);
6526+  catchAndAssertEquals(function() {
6527+    COSH("str");
6528+  }, ERRORS.VALUE_ERROR);
6529+  catchAndAssertEquals(function() {
6530+    COSH();
6531+  }, ERRORS.NA_ERROR);
6532+  catchAndAssertEquals(function() {
6533+    COSH(1, 1);
6534+  }, ERRORS.NA_ERROR);
6535+  assertEquals(COSH([0, "str"]), 1);
6536+});
6537+
6538+
6539+test("COT", function(){
6540+  assertEquals(COT(30), -0.15611995216165922);
6541+  assertEquals(COT(1), 0.6420926159343306);
6542+  assertEquals(COT(true), 0.6420926159343306);
6543+  assertEquals(COT([1, "str"]), 0.6420926159343306);
6544+  catchAndAssertEquals(function() {
6545+    COT(false);
6546+  }, ERRORS.DIV_ZERO_ERROR);
6547+  catchAndAssertEquals(function() {
6548+    COT(0);
6549+  }, ERRORS.DIV_ZERO_ERROR);
6550+  catchAndAssertEquals(function() {
6551+    COT("");
6552+  }, ERRORS.DIV_ZERO_ERROR);
6553+  catchAndAssertEquals(function() {
6554+    COT("str");
6555+  }, ERRORS.VALUE_ERROR);
6556+  catchAndAssertEquals(function() {
6557+    COT();
6558+  }, ERRORS.NA_ERROR);
6559+  catchAndAssertEquals(function() {
6560+    COT(1, 1);
6561+  }, ERRORS.NA_ERROR);
6562+});
6563+
6564+
6565+test("COTH", function(){
6566+  assertEquals(COTH(30), 1);
6567+  assertEquals(COTH(1), 1.3130352854993315);
6568+  assertEquals(COTH(true), 1.3130352854993315);
6569+  assertEquals(COTH([1, "str"]), 1.3130352854993315);
6570+  assertEquals(COTH(-1), -1.3130352854993315);
6571+  catchAndAssertEquals(function() {
6572+    COTH(false);
6573+  }, ERRORS.DIV_ZERO_ERROR);
6574+  catchAndAssertEquals(function() {
6575+    COTH(0);
6576+  }, ERRORS.DIV_ZERO_ERROR);
6577+  catchAndAssertEquals(function() {
6578+    COTH("");
6579+  }, ERRORS.DIV_ZERO_ERROR);
6580+  catchAndAssertEquals(function() {
6581+    COTH("str");
6582+  }, ERRORS.VALUE_ERROR);
6583+  catchAndAssertEquals(function() {
6584+    COTH();
6585+  }, ERRORS.NA_ERROR);
6586+  catchAndAssertEquals(function() {
6587+    COTH(1, 1);
6588+  }, ERRORS.NA_ERROR);
6589+});
6590+
6591+
6592+test("COUNTIF", function(){
6593+  assertEquals(COUNTIF([1, 5, 10], ">4"), 2);
6594+  assertEquals(COUNTIF([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 7);
6595+  assertEquals(COUNTIF([1, 5, 10], 5), 1);
6596+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], 5), 4);
6597+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], 10), 1);
6598+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">5"), 1);
6599+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=5"), 4);
6600+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=10"), 1);
6601+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=     10  "), 1);
6602+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">0"), 6);
6603+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">=5"), 5);
6604+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "<10"), 5);
6605+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 6);
6606+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">4.99"), 5);
6607+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
6608+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
6609+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=>5"), 0);
6610+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "==5"), 0);
6611+  assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "boom"], "*o*"), 3);
6612+  assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "mom"), 2);
6613+  assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "?o?"), 3);
6614+  assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "???"), 5);
6615+  assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "????"), 0);
6616+  assertEquals(COUNTIF(["mom", "pop", "dad", "etc", "mom"], "?"), 0);
6617+  // dollar sign and negative values
6618+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=$5"), 4);
6619+  assertEquals(COUNTIF([1, -5, -5, -5, 10, -5], "=-$5"), 4);
6620+  assertEquals(COUNTIF([1, -5, -5, -5, 10, -5], "=-5"), 4);
6621+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], ">$5"), 1);
6622+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=$10"), 1);
6623+  assertEquals(COUNTIF([1, 5, 5, 5, 10, 5], "=  $ 10"), 1);
6624+  catchAndAssertEquals(function() {
6625+    COUNTIF([0, 1, 0, 1]);
6626+  }, ERRORS.NA_ERROR);
6627+  catchAndAssertEquals(function() {
6628+    COUNTIF();
6629+  }, ERRORS.NA_ERROR);
6630+  catchAndAssertEquals(function() {
6631+    COUNTIF([], "=1", []);
6632+  }, ERRORS.NA_ERROR);
6633+});
6634+
6635+
6636+test("COUNTIFS", function(){
6637+  // All COUNTIF tests should also work on COUNTIFS
6638+  assertEquals(COUNTIFS([1, 5, 10], ">4"), 2);
6639+  assertEquals(COUNTIFS([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 7);
6640+  assertEquals(COUNTIFS([1, 5, 10], 5), 1);
6641+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], 5), 4);
6642+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], 10), 1);
6643+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">5"), 1);
6644+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=5"), 4);
6645+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=10"), 1);
6646+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=     10  "), 1);
6647+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">0"), 6);
6648+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">=5"), 5);
6649+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "<10"), 5);
6650+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5, 44], "<=10"), 6);
6651+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], ">4.99"), 5);
6652+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "<4.99"), 1);
6653+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
6654+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "=>5"), 0);
6655+  assertEquals(COUNTIFS([1, 5, 5, 5, 10, 5], "==5"), 0);
6656+  assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "boom"], "*o*"), 3);
6657+  assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "mom"), 2);
6658+  assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "?o?"), 3);
6659+  assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "???"), 5);
6660+  assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "????"), 0);
6661+  assertEquals(COUNTIFS(["mom", "pop", "dad", "etc", "mom"], "?"), 0);
6662+  // Now actually test COUNTIFS
6663+  assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1"), 2);
6664+  assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1"), 2);
6665+  assertEquals(COUNTIFS([1, 5, 10, 20], ">4", [0, 0, 1, 1], "=1", [0, 0, 1, 1], "=1"), 2);
6666+  assertEquals(COUNTIFS([1, 5, 10, 20, 40], ">4", [0, 0, 1, 1, 1], "=1", [0, 0, 0, 0, 0], "=1"), 0);
6667+  assertEquals(COUNTIFS([1, 2, 3, 4], ">3", [true, true, false, true], true), 1);
6668+  catchAndAssertEquals(function() {
6669+    COUNTIFS([1, 5, 10, 20], ">4", [0, 0], "=1");
6670+  }, ERRORS.VALUE_ERROR);
6671+});
6672+
6673+
6674+test("COUNTUNIQUE", function(){
6675+  assertEquals(COUNTUNIQUE([1, 1, 10]), 2);
6676+  assertEquals(COUNTUNIQUE(["1", 1, 10]), 3);
6677+  assertEquals(COUNTUNIQUE(["1", 1, 10, ""]), 4);
6678+  assertEquals(COUNTUNIQUE(["1", 1, 10, "", ""]), 4);
6679+  assertEquals(COUNTUNIQUE(["1", 1, 10, "", " "]), 5);
6680+  assertEquals(COUNTUNIQUE(["1", 1, 10, []]), 4);
6681+  assertEquals(COUNTUNIQUE(["", " ", [""], []]), 2);
6682+  assertEquals(COUNTUNIQUE([[""], []]), 1);
6683+  catchAndAssertEquals(function() {
6684+    COUNTUNIQUE();
6685+  }, ERRORS.NA_ERROR);
6686+});
6687+
6688+
6689+test("DEGREES", function(){
6690+  assertEquals(DEGREES(PI()), 180);
6691+  assertEquals(DEGREES([PI(), "str"]), 180);
6692+  assertEquals(DEGREES(false), 0);
6693+  assertEquals(DEGREES(true), 57.29577951308232);
6694+  assertEquals(DEGREES(1), 57.29577951308232);
6695+  assertEquals(DEGREES(12), 687.5493541569879);
6696+  catchAndAssertEquals(function() {
6697+    DEGREES("str");
6698+  }, ERRORS.VALUE_ERROR);
6699+  catchAndAssertEquals(function() {
6700+    DEGREES();
6701+  }, ERRORS.NA_ERROR);
6702+  catchAndAssertEquals(function() {
6703+    DEGREES(10, 10);
6704+  }, ERRORS.NA_ERROR);
6705+});
6706+
6707+
6708+test("ERF", function(){
6709+  assertEquals(ERF(2), 0.9953222650189527);
6710+  assertEquals(ERF("2"), 0.9953222650189527);
6711+  assertEquals(ERF(0), 1.1102230246251565e-16);
6712+  assertEquals(ERF(1), 0.8427007929497149);
6713+  assertEquals(ERF(true), 0.8427007929497149);
6714+  assertEquals(ERF(false), 1.1102230246251565e-16);
6715+  catchAndAssertEquals(function() {
6716+    ERF();
6717+  }, ERRORS.NA_ERROR);
6718+  catchAndAssertEquals(function() {
6719+    ERF([]);
6720+  }, ERRORS.REF_ERROR);
6721+  assertEquals(ERF(1, 2), 0.15262147206923782);
6722+  assertEquals(ERF(2, 1), -0.15262147206923782);
6723+});
6724+
6725+
6726+test("ERFC", function(){
6727+  assertEquals(ERFC(2), 0.004677734981047288);
6728+  assertEquals(ERFC("2"), 0.004677734981047288);
6729+  assertEquals(ERFC(0), 1);
6730+  assertEquals(ERFC(1), 0.1572992070502851);
6731+  assertEquals(ERFC(-1), 1.842700792949715);
6732+  assertEquals(ERFC(-10), 2);
6733+  catchAndAssertEquals(function() {
6734+    ERFC();
6735+  }, ERRORS.NA_ERROR);
6736+  catchAndAssertEquals(function() {
6737+    ERFC([]);
6738+  }, ERRORS.REF_ERROR);
6739+});
6740+
6741+
6742+test("EVEN", function(){
6743+  assertEquals(EVEN(3), 4);
6744+  assertEquals(EVEN(4), 4);
6745+  assertEquals(EVEN(5), 6);
6746+  assertEquals(EVEN("4"), 4);
6747+  assertEquals(EVEN(false), 0);
6748+  assertEquals(EVEN(true), 2);
6749+  assertEquals(EVEN([11, 22]), 12);
6750+  assertEquals(EVEN([10, 22, "str"]), 10);
6751+  catchAndAssertEquals(function() {
6752+    EVEN();
6753+  }, ERRORS.NA_ERROR);
6754+  catchAndAssertEquals(function() {
6755+    EVEN(1, 2, 3);
6756+  }, ERRORS.NA_ERROR);
6757+  catchAndAssertEquals(function() {
6758+    EVEN("str");
6759+  }, ERRORS.VALUE_ERROR);
6760+});
6761+
6762+
6763+test("FLOOR", function(){
6764+  assertEquals(FLOOR(10.1), 10);
6765+  assertEquals(FLOOR("10.1"), 10);
6766+  assertEquals(FLOOR(10.11111111, 0.1), 10.1);
6767+  assertEquals(FLOOR(10.22222222, 0.1), 10.2);
6768+  assertEquals(FLOOR(10.33333333, 0.2), 10.2);
6769+  assertEquals(FLOOR(10.33333333, 0.1), 10.3);
6770+  assertEquals(FLOOR([10.33333333], 0.1), 10.3);
6771+  assertEquals(FLOOR(10.22222222, 5), 10);
6772+  assertEquals(FLOOR(10.22222222, 8), 8);
6773+  assertEquals(FLOOR(10.22222222, true), 10);
6774+  catchAndAssertEquals(function() {
6775+    FLOOR(10, 0);
6776+  }, ERRORS.DIV_ZERO_ERROR);
6777+  catchAndAssertEquals(function() {
6778+    FLOOR(10, 1, 2);
6779+  }, ERRORS.NA_ERROR);
6780+  catchAndAssertEquals(function() {
6781+    FLOOR();
6782+  }, ERRORS.NA_ERROR);
6783+});
6784+
6785+
6786+test("IF", function(){
6787+  assertEquals(IF(true, "hit", "miss"), "hit");
6788+  assertEquals(IF(false, "hit", "miss"), "miss");
6789+  assertEquals(IF("", "hit", "miss"), "miss");
6790+  assertEquals(IF("", "hit", "miss"), "miss");
6791+  assertEquals(IF([true], "hit", "miss"), "hit");
6792+  assertEquals(IF([false], "hit", "miss"), "miss");
6793+  assertEquals(IF([""], "hit", "miss"), "miss");
6794+  assertEquals(IF([""], "hit", "miss"), "miss");
6795+  catchAndAssertEquals(function() {
6796+    IF("str", 1, 2);
6797+  }, ERRORS.VALUE_ERROR);
6798+  catchAndAssertEquals(function() {
6799+    IF([], 1, 2);
6800+  }, ERRORS.REF_ERROR);
6801+});
6802+
6803+
6804+test("INT", function(){
6805+  assertEquals(INT(99.33), 99);
6806+  assertEquals(INT(99.99), 99);
6807+  assertEquals(INT(true), 1);
6808+  assertEquals(INT(false), 0);
6809+  assertEquals(INT(""), 0);
6810+  assertEquals(INT([1.1, "str"]), 1);
6811+  catchAndAssertEquals(function() {
6812+    INT(100, 10);
6813+  }, ERRORS.NA_ERROR);
6814+  catchAndAssertEquals(function() {
6815+    INT();
6816+  }, ERRORS.NA_ERROR);
6817+  catchAndAssertEquals(function() {
6818+    INT("str");
6819+  }, ERRORS.VALUE_ERROR);
6820+});
6821+
6822+
6823+test("ISEVEN", function(){
6824+  assertEquals(ISEVEN(4), true);
6825+  assertEquals(ISEVEN(3), false);
6826+  assertEquals(ISEVEN(4.1), true);
6827+  assertEquals(ISEVEN(false), true);
6828+  assertEquals(ISEVEN(true), false);
6829+  assertEquals(ISEVEN([4]), true);
6830+  catchAndAssertEquals(function() {
6831+    ISEVEN(100, 10);
6832+  }, ERRORS.NA_ERROR);
6833+  catchAndAssertEquals(function() {
6834+    ISEVEN();
6835+  }, ERRORS.NA_ERROR);
6836+  catchAndAssertEquals(function() {
6837+    ISEVEN("");
6838+  }, ERRORS.VALUE_ERROR);
6839+});
6840+
6841+
6842+test("ISODD", function(){
6843+  assertEquals(ISODD(4), false);
6844+  assertEquals(ISODD(3), true);
6845+  assertEquals(ISODD(4.1), false);
6846+  assertEquals(ISODD(false), false);
6847+  assertEquals(ISODD(true), true);
6848+  assertEquals(ISODD([4]), false);
6849+  catchAndAssertEquals(function() {
6850+    ISODD(100, 10);
6851+  }, ERRORS.NA_ERROR);
6852+  catchAndAssertEquals(function() {
6853+    ISODD();
6854+  }, ERRORS.NA_ERROR);
6855+  catchAndAssertEquals(function() {
6856+    ISODD("");
6857+  }, ERRORS.VALUE_ERROR);
6858+});
6859+
6860+
6861+test("LN", function(){
6862+  assertEquals(LN(100), 4.605170185988092);
6863+  assertEquals(LN("100"), 4.605170185988092);
6864+  assertEquals(LN(1), 0);
6865+  assertEquals(LN(true), 0);
6866+  catchAndAssertEquals(function() {
6867+    LN(false);
6868+  }, ERRORS.NUM_ERROR);
6869+  catchAndAssertEquals(function() {
6870+    LN("str");
6871+  }, ERRORS.VALUE_ERROR);
6872+  catchAndAssertEquals(function() {
6873+    LN();
6874+  }, ERRORS.NA_ERROR);
6875+  catchAndAssertEquals(function() {
6876+    LN(10, 10);
6877+  }, ERRORS.NA_ERROR);
6878+});
6879+
6880+
6881+test("LOG", function(){
6882+  assertEquals(LOG(256, 2), 8);
6883+  assertEquals(LOG(100), 2);
6884+  assertEquals(LOG(100), 2);
6885+  assertEquals(LOG(256, 10), 2.408239965311849);
6886+  assertEquals(LOG(256), 2.408239965311849);
6887+  assertEquals(LOG("100"), 2);
6888+  assertEquals(LOG(1, 2), 0);
6889+  catchAndAssertEquals(function() {
6890+    LOG("str");
6891+  }, ERRORS.VALUE_ERROR);
6892+  catchAndAssertEquals(function() {
6893+    LOG(256, 0);
6894+  }, ERRORS.NUM_ERROR);
6895+  catchAndAssertEquals(function() {
6896+    LOG(256, 1);
6897+  }, ERRORS.DIV_ZERO_ERROR);
6898+  catchAndAssertEquals(function() {
6899+    LOG(256, false);
6900+  }, ERRORS.NUM_ERROR);
6901+  catchAndAssertEquals(function() {
6902+    LOG(256, true);
6903+  }, ERRORS.DIV_ZERO_ERROR);
6904+});
6905+
6906+
6907+test("LOG10", function(){
6908+  assertEquals(LOG10(100), 2);
6909+  assertEquals(LOG10("100"), 2);
6910+  assertEquals(LOG10(1), 0);
6911+  assertEquals(LOG10(10.1), 1.0043213737826424);
6912+  catchAndAssertEquals(function() {
6913+    LOG10(false);
6914+  }, ERRORS.NUM_ERROR);
6915+  catchAndAssertEquals(function() {
6916+    LOG10("");
6917+  }, ERRORS.NUM_ERROR);
6918+  catchAndAssertEquals(function() {
6919+    LOG10("str");
6920+  }, ERRORS.VALUE_ERROR);
6921+  catchAndAssertEquals(function() {
6922+    LOG10();
6923+  }, ERRORS.NA_ERROR);
6924+  catchAndAssertEquals(function() {
6925+    LOG10(10, 10);
6926+  }, ERRORS.NA_ERROR);
6927+});
6928+
6929+
6930+test("MOD", function(){
6931+  assertEquals(MOD(10, 3), 1);
6932+  catchAndAssertEquals(function() {
6933+    MOD(10, 3, 10);
6934+  }, ERRORS.NA_ERROR);
6935+  catchAndAssertEquals(function() {
6936+    MOD([10, 3]);
6937+  }, ERRORS.NA_ERROR);
6938+  catchAndAssertEquals(function() {
6939+    MOD(0, 0);
6940+  }, ERRORS.DIV_ZERO_ERROR);
6941+  catchAndAssertEquals(function() {
6942+    MOD(10);
6943+  }, ERRORS.NA_ERROR);
6944+  catchAndAssertEquals(function() {
6945+    MOD(10, false);
6946+  }, ERRORS.DIV_ZERO_ERROR);
6947+  catchAndAssertEquals(function() {
6948+    MOD(10, 0);
6949+  }, ERRORS.DIV_ZERO_ERROR);
6950+  catchAndAssertEquals(function() {
6951+    MOD(10, "str");
6952+  }, ERRORS.VALUE_ERROR);
6953+  assertEquals(MOD(10, "3"), 1);
6954+  assertEquals(MOD(10.1, 3), 1.0999999999999996);
6955+  assertEquals(MOD(10, 3.1), 0.6999999999999997);
6956+});
6957+
6958+
6959+test("ODD", function(){
6960+  assertEquals(ODD(2), 3);
6961+  assertEquals(ODD(4), 5);
6962+  assertEquals(ODD(5), 5);
6963+  assertEquals(ODD("4"), 5);
6964+  assertEquals(ODD(false), 1);
6965+  assertEquals(ODD(true), 1);
6966+  assertEquals(ODD([10, 22]), 11);
6967+  assertEquals(ODD([10, 22, "str"]), 11);
6968+  catchAndAssertEquals(function() {
6969+    ODD();
6970+  }, ERRORS.NA_ERROR);
6971+  catchAndAssertEquals(function() {
6972+    ODD(1, 2, 3);
6973+  }, ERRORS.NA_ERROR);
6974+  catchAndAssertEquals(function() {
6975+    ODD("str");
6976+  }, ERRORS.VALUE_ERROR);
6977+});
6978+
6979+
6980+test("PI", function(){
6981+  assertEquals(PI(), 3.141592653589793);
6982+});
6983+
6984+
6985+test("POWER", function(){
6986+  assertEquals(POWER(4, 10), 1048576);
6987+  assertEquals(POWER(4, false), 1);
6988+  assertEquals(POWER(4, true), 4);
6989+  assertEquals(POWER([4], [10]), 1048576);
6990+  assertEquals(POWER([4], [10, "str"]), 1048576);
6991+  catchAndAssertEquals(function() {
6992+    POWER(4, "str");
6993+  }, ERRORS.VALUE_ERROR);
6994+  catchAndAssertEquals(function() {
6995+    POWER();
6996+  }, ERRORS.NA_ERROR);
6997+  catchAndAssertEquals(function() {
6998+    POWER(4);
6999+  }, ERRORS.NA_ERROR);
7000+  catchAndAssertEquals(function() {
7001+    POWER(4, 10, 22);
7002+  }, ERRORS.NA_ERROR);
7003+});
7004+
7005+
7006+test("RADIANS", function(){
7007+  assertEquals(RADIANS(180), 3.141592653589793);
7008+  assertEquals(RADIANS(false), 0);
7009+  assertEquals(RADIANS(true), 0.017453292519943295);
7010+  catchAndAssertEquals(function() {
7011+    RADIANS("str");
7012+  }, ERRORS.VALUE_ERROR);
7013+  catchAndAssertEquals(function() {
7014+    RADIANS();
7015+  }, ERRORS.NA_ERROR);
7016+  catchAndAssertEquals(function() {
7017+    RADIANS(4, 10);
7018+  }, ERRORS.NA_ERROR);
7019+});
7020+
7021+
7022+
7023+test("ROUND", function(){
7024+  assertEquals(ROUND(99.44, 1), 99.4);
7025+  assertEquals(ROUND(99.44, 0), 99);
7026+  assertEquals(ROUND(99.4444444444444, 9), 99.444444444);
7027+  assertEquals(ROUND(99.44), 99);
7028+  assertEquals(ROUND("99.44"), 99);
7029+  assertEquals(ROUND([99.44, 22.222], [1, 4]), 99.4);
7030+  catchAndAssertEquals(function() {
7031+    ROUND();
7032+  }, ERRORS.NA_ERROR);
7033+  catchAndAssertEquals(function() {
7034+    ROUND(99.44, 1, 44);
7035+  }, ERRORS.NA_ERROR);
7036+  catchAndAssertEquals(function() {
7037+    ROUND(99.999, "str");
7038+  }, ERRORS.VALUE_ERROR);
7039+});
7040+
7041+
7042+test("ROUNDDOWN", function(){
7043+  assertEquals(ROUNDDOWN(99.46, 1), 99.4);
7044+  assertEquals(ROUNDDOWN(99.99, 1), 99.9);
7045+  assertEquals(ROUNDDOWN(99.5555555555555, 9), 99.555555555);
7046+  assertEquals(ROUNDDOWN(99.99), 99);
7047+  assertEquals(ROUNDDOWN("99.99"), 99);
7048+  assertEquals(ROUNDDOWN([99.46666, 22.222], [1, 4]), 99.4);
7049+  catchAndAssertEquals(function() {
7050+    ROUNDDOWN();
7051+  }, ERRORS.NA_ERROR);
7052+  catchAndAssertEquals(function() {
7053+    ROUNDDOWN(99.44, 1, 44);
7054+  }, ERRORS.NA_ERROR);
7055+  catchAndAssertEquals(function() {
7056+    ROUNDDOWN(99.999, "str");
7057+  }, ERRORS.VALUE_ERROR);
7058+});
7059+
7060+
7061+test("ROUNDUP", function(){
7062+  assertEquals(ROUNDUP(99.46, 1), 99.5);
7063+  assertEquals(ROUNDUP(99.99, 1), 100);
7064+  assertEquals(ROUNDUP(99.5555555555555, 9), 99.555555556);
7065+  assertEquals(ROUNDUP(99.99), 100);
7066+  assertEquals(ROUNDUP("99.99"), 100);
7067+  assertEquals(ROUNDUP([99.46666, 22.222], [1, 4]), 99.5);
7068+  catchAndAssertEquals(function() {
7069+    ROUNDUP();
7070+  }, ERRORS.NA_ERROR);
7071+  catchAndAssertEquals(function() {
7072+    ROUNDUP(99.44, 1, 44);
7073+  }, ERRORS.NA_ERROR);
7074+  catchAndAssertEquals(function() {
7075+    ROUNDUP(99.999, "str");
7076+  }, ERRORS.VALUE_ERROR);
7077+});
7078+
7079+
7080+test("SIN", function(){
7081+  assertEquals(SIN(0), 0);
7082+  assertEquals(SIN(1), 0.8414709848078965);
7083+  assertEquals(SIN(PI() / 2), 1);
7084+  assertEquals(SIN(PI()), 0);
7085+  assertEquals(SIN(true), 0.8414709848078965);
7086+  assertEquals(SIN(false), 0);
7087+  assertEquals(SIN("0"), 0);
7088+  assertEquals(SIN(""), 0);
7089+  catchAndAssertEquals(function() {
7090+    SIN("str");
7091+  }, ERRORS.VALUE_ERROR);
7092+  assertEquals(SIN([1]), 0.8414709848078965);
7093+  assertEquals(SIN([[1]]), 0.8414709848078965);
7094+  assertEquals(SIN([1, "str"]), 0.8414709848078965);
7095+});
7096+
7097+
7098+test("SINH", function(){
7099+  assertEquals(SINH(PI()), 11.548739357257748);
7100+  assertEquals(SINH(1), 1.1752011936438014);
7101+  assertEquals(SINH(false), 0);
7102+  assertEquals(SINH(true), 1.1752011936438014);
7103+  assertEquals(SINH(""), 0);
7104+  assertEquals(SINH("0"), 0);
7105+  catchAndAssertEquals(function() {
7106+    SINH("str");
7107+  }, ERRORS.VALUE_ERROR);
7108+  assertEquals(SINH([10]), 11013.232874703393);
7109+  assertEquals(SINH([[10]]), 11013.232874703393);
7110+  catchAndAssertEquals(function() {
7111+    SIN([[]]);
7112+  }, ERRORS.REF_ERROR);
7113+  assertEquals(SINH([[10, "str"]]), 11013.232874703393);
7114+});
7115+
7116+
7117+test("SQRT", function(){
7118+  assertEquals(SQRT(9), 3);
7119+  assertEquals(SQRT("9"), 3);
7120+  assertEquals(SQRT(4), 2);
7121+  assertEquals(SQRT(false), 0);
7122+  assertEquals(SQRT(true), 1);
7123+  assertEquals(SQRT(""), 0);
7124+  catchAndAssertEquals(function() {
7125+    SQRT("str");
7126+  }, ERRORS.VALUE_ERROR);
7127+  catchAndAssertEquals(function() {
7128+    SQRT(-9);
7129+  }, ERRORS.VALUE_ERROR);
7130+  catchAndAssertEquals(function() {
7131+    SQRT();
7132+  }, ERRORS.NA_ERROR);
7133+  catchAndAssertEquals(function() {
7134+    SQRT(4, 4);
7135+  }, ERRORS.NA_ERROR);
7136+});
7137+
7138+
7139+test("SQRTPI", function(){
7140+  assertEquals(SQRTPI(9), 5.317361552716548);
7141+  assertEquals(SQRTPI("9"), 5.317361552716548);
7142+  assertEquals(SQRTPI([9]), 5.317361552716548);
7143+  assertEquals(SQRTPI(0), 0);
7144+  assertEquals(SQRTPI(1), 1.7724538509055159);
7145+  assertEquals(SQRTPI(""), 0);
7146+  catchAndAssertEquals(function() {
7147+    SQRTPI("str");
7148+  }, ERRORS.VALUE_ERROR);
7149+  catchAndAssertEquals(function() {
7150+    SQRTPI(-1);
7151+  }, ERRORS.NUM_ERROR);
7152+  catchAndAssertEquals(function() {
7153+    SQRTPI();
7154+  }, ERRORS.NA_ERROR);
7155+  catchAndAssertEquals(function() {
7156+    SQRTPI(4, 4);
7157+  }, ERRORS.NA_ERROR);
7158+});
7159+
7160+
7161+test("SUM", function(){
7162+  assertEquals(SUM(10), 10);
7163+  assertEquals(SUM(10, 10), 20);
7164+  assertEquals(SUM(10, [5, 5]), 20);
7165+  assertEquals(SUM("10", [5, 5]), 20);
7166+  assertEquals(SUM(false, [10, 10]), 20);
7167+  assertEquals(SUM(true, [10, 10]), 21);
7168+  catchAndAssertEquals(function() {
7169+    SUM([10, 10], "");
7170+  }, ERRORS.VALUE_ERROR);
7171+  catchAndAssertEquals(function() {
7172+    SUM([10, 10], "str");
7173+  }, ERRORS.VALUE_ERROR);
7174+  catchAndAssertEquals(function() {
7175+    SUM();
7176+  }, ERRORS.NA_ERROR);
7177+});
7178+
7179+
7180+test("SUMIF", function(){
7181+  assertEquals(SUMIF([1, 5, 10], 5), 5);
7182+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], 5), 20);
7183+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], 10), 10);
7184+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">5"), 10);
7185+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=5"), 20);
7186+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=1"), 1);
7187+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=     1  "), 1);
7188+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">0"), 31);
7189+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">=5"), 30);
7190+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "<10"), 21);
7191+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 31);
7192+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], ">4.99"), 30);
7193+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
7194+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=     1.0.0  "), 0);
7195+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "=>5"), 0);
7196+  assertEquals(SUMIF([1, 5, 5, 5, 10, 5], "==5"), 0);
7197+  assertEquals(SUMIF(["m", "m", 3, 11, true], "m"), 0);
7198+  assertEquals(SUMIF(["m", "p", "m"], "m", [1, 1, 1]), 2);
7199+  assertEquals(SUMIF(["p", "p", "p"], "m", [1, 1, 1]), 0);
7200+  assertEquals(SUMIF(["p", "p", "p"], "", [1, 1, 1]), 0);
7201+  assertEquals(SUMIF(["p", "p", "p"], "*", [1, 1, 1]), 3);
7202+  assertEquals(SUMIF(["mom", "pop", "pap"], "*o*", [1, 1, 1]), 2);
7203+  assertEquals(SUMIF(["mom", "pop", "pap"], "*a*", [1, 1, 1]), 1);
7204+  assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1, 1]), 2);
7205+  assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1, 1]), 2);
7206+  assertEquals(SUMIF(["mom", "pop", "pap"], "p*p", [1, 1,]), 1);
7207+  assertEquals(SUMIF(["pop", "pap"], "p*p", [1, 2, 4]), 3);
7208+  assertEquals(SUMIF(["mom", "pop", "dad", "etc", "boom"], "*o*", [1, 1, 1, 1, 1]), 3);
7209+  assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "mom", [1, 1, 1, 1, 1]), 2);
7210+  assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "?o?", [1, 1, 1, 1, 1]), 3);
7211+  assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "???", [1, 1, 1, 1, 1]), 5);
7212+  assertEquals(SUMIF(["mom", "pop", "dad", "etc", "mom"], "????", [1, 1, 1, 1, 1]), 0);
7213+  assertEquals(SUMIF([0, 1, 0, 1], "=1", [1, 2, 4, 8]), 10);
7214+  catchAndAssertEquals(function() {
7215+    SUMIF([0, 1, 0, 1]);
7216+  }, ERRORS.NA_ERROR);
7217+  catchAndAssertEquals(function() {
7218+    SUMIF();
7219+  }, ERRORS.NA_ERROR);
7220+  catchAndAssertEquals(function() {
7221+    SUMIF([], "=1", [], true);
7222+  }, ERRORS.NA_ERROR);
7223+});
7224+
7225+
7226+test("SUMPRODUCT", function(){
7227+  assertEquals(SUMPRODUCT([1, 5, 10], [2, 2, 2]), 32);
7228+  assertEquals(SUMPRODUCT([1, 5, 10], [2, 2, 2], [2, 2, 2]), 64);
7229+  assertEquals(SUMPRODUCT([1, 5, 10], [1, 2, 2], [1, 4, 4]), 121);
7230+  assertEquals(SUMPRODUCT([1, 5, 10]), 16);
7231+  assertEquals(SUMPRODUCT([1, 5, 10, ""]), 16);
7232+  assertEquals(SUMPRODUCT([1, 5, 10, 200], [2, 2, 2, ""]), 32);
7233+  assertEquals(SUMPRODUCT([1, 5, 10, "str"]), 16);
7234+  assertEquals(SUMPRODUCT([10, 10, 22, "str"], [2, 2, [2, 2]]), 84);
7235+  assertEquals(SUMPRODUCT(1, 5, 10), 50);
7236+  assertEquals(SUMPRODUCT([1, 5, 10]), 16);
7237+  catchAndAssertEquals(function() {
7238+    SUMPRODUCT([1, 5, 10], [2, 2]);
7239+  }, ERRORS.VALUE_ERROR);
7240+  catchAndAssertEquals(function() {
7241+    SUMPRODUCT([1, 5, 10], [2, 2, 2, []]);
7242+  }, ERRORS.REF_ERROR);
7243+  catchAndAssertEquals(function() {
7244+    SUMPRODUCT();
7245+  }, ERRORS.NA_ERROR);
7246+});
7247+
7248+
7249+test("SUMSQ", function(){
7250+  assertEquals(SUMSQ([1, 5, 10], 10), 226);
7251+  assertEquals(SUMSQ([10, 10, 22, ""]), 684);
7252+  assertEquals(SUMSQ(10, 10, 22), 684);
7253+  assertEquals(SUMSQ(10, 10, "22", true), 685);
7254+  assertEquals(SUMSQ(10, 10, "22", false), 684);
7255+  assertEquals(SUMSQ([10, 10, 22, true]), 684);
7256+  catchAndAssertEquals(function() {
7257+    SUMSQ([10, 10, 22, "", []]);
7258+  }, ERRORS.REF_ERROR);
7259+  catchAndAssertEquals(function() {
7260+    SUMSQ([]);
7261+  }, ERRORS.REF_ERROR);
7262+  catchAndAssertEquals(function() {
7263+    SUMSQ();
7264+  }, ERRORS.NA_ERROR);
7265+});
7266+
7267+
7268+test("SUMX2MY2", function(){
7269+  assertEquals(SUMX2MY2([1,2,3],[4,5,6]), -63);
7270+  assertEquals(SUMX2MY2([1, 2, 3], [[4, 5], [6]]), -63);
7271+  assertEquals(SUMX2MY2(["1",2,3],[4,5,6]), -48);
7272+  assertEquals(SUMX2MY2(["",2,3],[4,5,6]), -48);
7273+  assertEquals(SUMX2MY2([false,2,3],[4,5,6]), -48);
7274+  assertEquals(SUMX2MY2([true,2,3],[4,5,6]), -48);
7275+  catchAndAssertEquals(function() {
7276+    SUMX2MY2([1,2,3],[4,5, []]);
7277+  }, ERRORS.REF_ERROR);
7278+  catchAndAssertEquals(function() {
7279+    SUMX2MY2([1,2,3],[4,5]);
7280+  }, ERRORS.NA_ERROR);
7281+  catchAndAssertEquals(function() {
7282+    SUMX2MY2();
7283+  }, ERRORS.NA_ERROR);
7284+});
7285+
7286+
7287+test("SUMX2PY2", function(){
7288+  assertEquals(SUMX2PY2([1, 2, 3], [4, 5, 6]), 91);
7289+  assertEquals(SUMX2PY2([1, 2, 3], [[4, 5], [6]]), 91);
7290+  assertEquals(SUMX2PY2(["1",2,3],[4,5,6]), 74);
7291+  assertEquals(SUMX2PY2(["",2,3],[4,5,6]), 74);
7292+  assertEquals(SUMX2PY2([false,2,3],[4,5,6]), 74);
7293+  assertEquals(SUMX2PY2([true,2,3],[4,5,6]), 74);
7294+  catchAndAssertEquals(function() {
7295+    SUMX2PY2([1,2,3],[4,5, []]);
7296+  }, ERRORS.REF_ERROR);
7297+  catchAndAssertEquals(function() {
7298+    SUMX2PY2([1,2,3],[4,5]);
7299+  }, ERRORS.NA_ERROR);
7300+  catchAndAssertEquals(function() {
7301+    SUMX2PY2();
7302+  }, ERRORS.NA_ERROR);
7303+});
7304+
7305+
7306+test("TAN", function(){
7307+  assertEquals(TAN(0), 0);
7308+  assertEquals(TAN(1), 1.5574077246549023);
7309+  assertEquals(TAN(PI() / 2), 16331239353195370);
7310+  assertEquals(TAN(PI()), 0);
7311+  assertEquals(TAN(false), 0);
7312+  assertEquals(TAN(true), 1.5574077246549023);
7313+  assertEquals(TAN(""), 0);
7314+  assertEquals(TAN("0"), 0);
7315+  catchAndAssertEquals(function() {
7316+    TAN("str");
7317+  }, ERRORS.VALUE_ERROR);
7318+  catchAndAssertEquals(function() {
7319+    TAN();
7320+  }, ERRORS.NA_ERROR);
7321+  catchAndAssertEquals(function() {
7322+    TAN(1, 1);
7323+  }, ERRORS.NA_ERROR);
7324+  assertEquals(TAN([1, 44]), 1.5574077246549023);
7325+  assertEquals(TAN([1, "str"]), 1.5574077246549023);
7326+});
7327+
7328+
7329+test("TANH", function(){
7330+  assertEquals(TANH(0), 0);
7331+  assertEquals(TANH(1), 0.7615941559557649);
7332+  assertEquals(TANH(PI() / 2), 0.9171523356672744);
7333+  assertEquals(TANH(PI()), 0.9962720762207501);
7334+  assertEquals(TANH(false), 0);
7335+  assertEquals(TANH(true), 0.7615941559557649);
7336+  assertEquals(TANH(""), 0);
7337+  assertEquals(TANH("0"), 0);
7338+  catchAndAssertEquals(function() {
7339+    TANH("str");
7340+  }, ERRORS.VALUE_ERROR);
7341+  catchAndAssertEquals(function() {
7342+    TANH();
7343+  }, ERRORS.NA_ERROR);
7344+  catchAndAssertEquals(function() {
7345+    TANH(1, 1);
7346+  }, ERRORS.NA_ERROR);
7347+  assertEquals(TANH([1, 44]), 0.7615941559557649);
7348+  assertEquals(TANH([1, "str"]), 0.7615941559557649);
7349+});
7350+
7351+
7352+test("TRUNC", function(){
7353+  assertEquals(TRUNC(PI(), 2), 3.14);
7354+  assertEquals(TRUNC("3.141592653589793", "2"), 3.14);
7355+  assertEquals(TRUNC(PI(), 1), 3.1);
7356+  assertEquals(TRUNC(PI(), 0), 3);
7357+  assertEquals(TRUNC(PI(), false), 3);
7358+  assertEquals(TRUNC(PI(), -1), 0);
7359+  assertEquals(TRUNC(31.41592653589793, -1), 30);
7360+  assertEquals(TRUNC([31.41592653589793], [-1]), 30);
7361+  assertEquals(TRUNC(31111.41592653589793, -4), 30000);
7362+  assertEquals(TRUNC(31111.41592653589793, -2), 31100);
7363+  catchAndAssertEquals(function() {
7364+    TRUNC();
7365+  }, ERRORS.NA_ERROR);
7366+  catchAndAssertEquals(function() {
7367+    TRUNC(3.1, 1, 1);
7368+  }, ERRORS.NA_ERROR);
7369+});
7370diff --git a/tests/Formulas/StatisticalTest.ts b/tests/Formulas/StatisticalTest.ts
7371index 4f1c565..647f44f 100644
7372--- a/tests/Formulas/StatisticalTest.ts
7373+++ b/tests/Formulas/StatisticalTest.ts
7374@@ -22,355 +22,380 @@ import {
7375 import * as ERRORS from "../../src/Errors";
7376 import {
7377   assertEquals,
7378-  catchAndAssertEquals
7379+  catchAndAssertEquals,
7380+  test
7381 } from "../utils/Asserts";
7382 
7383 
7384-// Test AVEDEV
7385-assertEquals(AVEDEV(1, 2, 4, 55), 19.75);
7386-assertEquals(AVEDEV(1, 2, 4, "55"), 19.75);
7387-assertEquals(AVEDEV([1, 2, 4, "55"]), 1.1111111111111112);
7388-assertEquals(AVEDEV([1, 2, 4, "55"], [10, 10, "str"]), 3.6799999999999997);
7389-assertEquals(AVEDEV([1, 2, 4, "55"], [10, 10]), 3.6799999999999997);
7390-assertEquals(AVEDEV(1, 2, 4, "55", [10, [10]]), 13.777777777777777);
7391-assertEquals(AVEDEV(1, 2, 4, "55", 10, 10), 13.77777777777778);
7392-assertEquals(AVEDEV(1, 2, 4, 55, false), 17.040000000000003);
7393-assertEquals(AVEDEV(1, 2, 4, 55, 0), 17.040000000000003);
7394-assertEquals(AVEDEV(1, 2, 4, 55, true), 16.959999999999997);
7395-assertEquals(AVEDEV(1, 2, 4, 55, 1), 16.959999999999997);
7396-assertEquals(AVEDEV([1, 2, 4, 55, 0]), 17.040000000000003);
7397-assertEquals(AVEDEV([1, 2, 4, 55], 0), 17.040000000000003);
7398-catchAndAssertEquals(function() {
7399-  AVEDEV();
7400-}, ERRORS.NA_ERROR);
7401-catchAndAssertEquals(function() {
7402-  AVEDEV(10, 10, "str");
7403-}, ERRORS.VALUE_ERROR);
7404-catchAndAssertEquals(function() {
7405-  AVEDEV(10, 10, []);
7406-}, ERRORS.REF_ERROR);
7407-
7408-
7409-// Test AVERAGE
7410-assertEquals(AVERAGE(1, 2, 4, 55), 15.5);
7411-assertEquals(AVERAGE(1, 2, 4, "55"), 15.5);
7412-assertEquals(AVERAGE(1, 2, 4, 55, false), 12.4);
7413-assertEquals(AVERAGE(1, 2, 4, 55, true), 12.6);
7414-assertEquals(AVERAGE(1, 2, 4, 55, 0), 12.4);
7415-assertEquals(AVERAGE(1, 2, 4, 55, 1), 12.6);
7416-catchAndAssertEquals(function() {
7417-  AVERAGE(1, 2, 4, "str");
7418-}, ERRORS.VALUE_ERROR);
7419-assertEquals(AVERAGE([1, 2, 4, 55, "str"]), 15.5);
7420-assertEquals(AVERAGE([1, 2, 4, 55, "22"]), 15.5);
7421-assertEquals(AVERAGE([0]), 0);
7422-catchAndAssertEquals(function() {
7423-  AVERAGE();
7424-}, ERRORS.NA_ERROR);
7425-catchAndAssertEquals(function() {
7426-  AVERAGE([]);
7427-}, ERRORS.REF_ERROR);
7428-
7429-
7430-// Test AVERAGEA
7431-assertEquals(AVERAGEA(1, 2, 4, 55), 15.5);
7432-assertEquals(AVERAGEA(1, 2, 4, "55"), 15.5);
7433-assertEquals(AVERAGEA(1, 2, 4, 55, false), 12.4);
7434-assertEquals(AVERAGEA(1, 2, 4, 55, true), 12.6);
7435-assertEquals(AVERAGEA(1, 2, 4, 55, 0), 12.4);
7436-assertEquals(AVERAGEA(1, 2, 4, 55, 1), 12.6);
7437-catchAndAssertEquals(function() {
7438-  AVERAGEA(1, 2, 4, "str");
7439-}, ERRORS.VALUE_ERROR);
7440-assertEquals(AVERAGEA([1, 2, 4, 55, "str"]), 12.4);
7441-assertEquals(AVERAGEA([1, 2, 4, 55, "22"]), 12.4);
7442-assertEquals(AVERAGEA([1, 2, 4, 55, 0]), 12.4);
7443-assertEquals(AVERAGEA([0]), 0);
7444-catchAndAssertEquals(function() {
7445-  AVERAGEA();
7446-}, ERRORS.NA_ERROR);
7447-catchAndAssertEquals(function() {
7448-  AVERAGEA([]);
7449-}, ERRORS.REF_ERROR);
7450-
7451-
7452-// Test AVERAGEIF
7453-assertEquals(AVERAGEIF([1, 5, 10], '>2'), 7.5);
7454-assertEquals(AVERAGEIF([1, 5, 10], ">4"), 7.5);
7455-assertEquals(AVERAGEIF([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 2);
7456-assertEquals(AVERAGEIF([1, 5, 10], 5), 5);
7457-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], 5), 5);
7458-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], 10), 10);
7459-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], ">5"), 10);
7460-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "=5"), 5);
7461-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "=10"), 10);
7462-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "=     10  "), 10);
7463-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], ">0"), 5.166666666666667);
7464-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], ">=5"), 6);
7465-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "<>1"), 6);
7466-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "<10"), 4.2);
7467-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 5.166666666666667);
7468-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], ">4.99"), 6);
7469-assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
7470-catchAndAssertEquals(function() {
7471-  AVERAGEIF([1, 5, 5, 5, 10, 5], "=     1.0.0  ");
7472-}, ERRORS.DIV_ZERO_ERROR);
7473-catchAndAssertEquals(function() {
7474-  AVERAGEIF([1, 5, 5, 5, 10, 5], "=>5");
7475-}, ERRORS.DIV_ZERO_ERROR);
7476-catchAndAssertEquals(function() {
7477-  AVERAGEIF([1, 5, 5, 5, 10, 5], "==5");
7478-}, ERRORS.DIV_ZERO_ERROR);
7479-
7480-
7481-// Test CORREL
7482-assertEquals(CORREL([9, 5],[10, 4]), 1);
7483-assertEquals(CORREL([10, 5, 16],[9, 3, 22]), 0.9876779373054069);
7484-catchAndAssertEquals(function() {
7485-  CORREL(5, 5);
7486-}, ERRORS.DIV_ZERO_ERROR);
7487-catchAndAssertEquals(function() {
7488-  CORREL([9, true], [5, true]);
7489-}, ERRORS.DIV_ZERO_ERROR);
7490-catchAndAssertEquals(function() {
7491-  CORREL([9, "10"], [5, "10"]);
7492-}, ERRORS.DIV_ZERO_ERROR);
7493-catchAndAssertEquals(function() {
7494-  CORREL([9], [5]);
7495-}, ERRORS.DIV_ZERO_ERROR);
7496-catchAndAssertEquals(function() {
7497-  CORREL();
7498-}, ERRORS.NA_ERROR);
7499-catchAndAssertEquals(function() {
7500-  CORREL([9, 5]);
7501-}, ERRORS.NA_ERROR);
7502-catchAndAssertEquals(function() {
7503-  CORREL([9, 5],[10]);
7504-}, ERRORS.NA_ERROR);
7505-
7506-
7507-// Test PEARSON (same as CORREL)
7508-assertEquals(PEARSON([9, 5],[10, 4]), 1);
7509-
7510-
7511-// Test COUNT
7512-assertEquals(COUNT([1, 5, 10, 0]), 4);
7513-assertEquals(COUNT(1, 5, 10, 0), 4);
7514-assertEquals(COUNT(1, 5, 10, "0"), 4);
7515-assertEquals(COUNT(1, 5, 10, ["0", "str"]), 4);
7516-assertEquals(COUNT(1, 5, 10, false), 4);
7517-assertEquals(COUNT(1, 5, 10, true), 4);
7518-assertEquals(COUNT([]), 0);
7519-assertEquals(COUNT(["str"]), 0);
7520-catchAndAssertEquals(function() {
7521-  COUNT();
7522-}, ERRORS.NA_ERROR);
7523-
7524-
7525-// Test COUNTA
7526-assertEquals(COUNTA(1, 2, 3), 3);
7527-assertEquals(COUNTA(0, 1, 2, 3), 4);
7528-assertEquals(COUNTA(0, 1, 2, 3, [], []), 6);
7529-assertEquals(COUNTA(0, 1, 2, 3, [], ""), 6);
7530-assertEquals(COUNTA(1, 2, "3"), 3);
7531-assertEquals(COUNTA(1, 2, "3", ["str"]), 4);
7532-assertEquals(COUNTA(1, 2, false), 3);
7533-assertEquals(COUNTA(1, 2, true), 3);
7534-assertEquals(COUNTA([]), 1);
7535-catchAndAssertEquals(function() {
7536-  COUNTA();
7537-}, ERRORS.NA_ERROR);
7538-
7539-
7540-// Test DEVSQ
7541-assertEquals(DEVSQ(1, 2), 0.5);
7542-assertEquals(DEVSQ([1, 2]), 0.5);
7543-assertEquals(DEVSQ([1, [2]]), 0.5);
7544-assertEquals(DEVSQ(1), 0);
7545-assertEquals(DEVSQ(false), 0);
7546-assertEquals(DEVSQ(true), 0);
7547-assertEquals(DEVSQ(1, 2, 3, 4), 5);
7548-assertEquals(DEVSQ([1, 2, 3, 4]), 5);
7549-catchAndAssertEquals(function() {
7550-  DEVSQ(1, "str");
7551-}, ERRORS.VALUE_ERROR);
7552-catchAndAssertEquals(function() {
7553-  DEVSQ();
7554-}, ERRORS.NA_ERROR);
7555-catchAndAssertEquals(function() {
7556-  DEVSQ([1, 2, [], 3]);
7557-}, ERRORS.REF_ERROR);
7558-
7559-
7560-// Test EXPONDIST
7561-assertEquals(EXPONDIST(4, 0.5, false), 0.06766764161830635);
7562-assertEquals(EXPONDIST(4, 0.5, 0), 0.06766764161830635);
7563-assertEquals(EXPONDIST(4, 0.5, true), 0.8646647167633873);
7564-assertEquals(EXPONDIST(4, 0.5, 1), 0.8646647167633873);
7565-assertEquals(EXPONDIST(4, 0.5, -1), 0.8646647167633873);
7566-assertEquals(EXPONDIST([4, "str"], ["0.5"], [false]), 0.06766764161830635);
7567-catchAndAssertEquals(function() {
7568-  EXPONDIST("str", 0.5, "1");
7569-}, ERRORS.VALUE_ERROR);
7570-catchAndAssertEquals(function() {
7571-  EXPONDIST(4, 0.5, "1");
7572-}, ERRORS.VALUE_ERROR);
7573-catchAndAssertEquals(function() {
7574-  EXPONDIST();
7575-}, ERRORS.NA_ERROR);
7576-catchAndAssertEquals(function() {
7577-  EXPONDIST(4, 0.5);
7578-}, ERRORS.NA_ERROR);
7579-catchAndAssertEquals(function() {
7580-  EXPONDIST(4, 0.5, true, 1);
7581-}, ERRORS.NA_ERROR);
7582-
7583-
7584-// Test FINV
7585-assertEquals(FINV(0.42, 2, 3), 1.174597274485816);
7586-// TODO: Test this more.
7587+test("AVEDEV", function(){
7588+  assertEquals(AVEDEV(1, 2, 4, 55), 19.75);
7589+  assertEquals(AVEDEV(1, 2, 4, "55"), 19.75);
7590+  assertEquals(AVEDEV([1, 2, 4, "55"]), 1.1111111111111112);
7591+  assertEquals(AVEDEV([1, 2, 4, "55"], [10, 10, "str"]), 3.6799999999999997);
7592+  assertEquals(AVEDEV([1, 2, 4, "55"], [10, 10]), 3.6799999999999997);
7593+  assertEquals(AVEDEV(1, 2, 4, "55", [10, [10]]), 13.777777777777777);
7594+  assertEquals(AVEDEV(1, 2, 4, "55", 10, 10), 13.77777777777778);
7595+  assertEquals(AVEDEV(1, 2, 4, 55, false), 17.040000000000003);
7596+  assertEquals(AVEDEV(1, 2, 4, 55, 0), 17.040000000000003);
7597+  assertEquals(AVEDEV(1, 2, 4, 55, true), 16.959999999999997);
7598+  assertEquals(AVEDEV(1, 2, 4, 55, 1), 16.959999999999997);
7599+  assertEquals(AVEDEV([1, 2, 4, 55, 0]), 17.040000000000003);
7600+  assertEquals(AVEDEV([1, 2, 4, 55], 0), 17.040000000000003);
7601+  catchAndAssertEquals(function() {
7602+    AVEDEV();
7603+  }, ERRORS.NA_ERROR);
7604+  catchAndAssertEquals(function() {
7605+    AVEDEV(10, 10, "str");
7606+  }, ERRORS.VALUE_ERROR);
7607+  catchAndAssertEquals(function() {
7608+    AVEDEV(10, 10, []);
7609+  }, ERRORS.REF_ERROR);
7610+});
7611+
7612+
7613+test("AVERAGE", function(){
7614+  assertEquals(AVERAGE(1, 2, 4, 55), 15.5);
7615+  assertEquals(AVERAGE(1, 2, 4, "55"), 15.5);
7616+  assertEquals(AVERAGE(1, 2, 4, 55, false), 12.4);
7617+  assertEquals(AVERAGE(1, 2, 4, 55, true), 12.6);
7618+  assertEquals(AVERAGE(1, 2, 4, 55, 0), 12.4);
7619+  assertEquals(AVERAGE(1, 2, 4, 55, 1), 12.6);
7620+  catchAndAssertEquals(function() {
7621+    AVERAGE(1, 2, 4, "str");
7622+  }, ERRORS.VALUE_ERROR);
7623+  assertEquals(AVERAGE([1, 2, 4, 55, "str"]), 15.5);
7624+  assertEquals(AVERAGE([1, 2, 4, 55, "22"]), 15.5);
7625+  assertEquals(AVERAGE([0]), 0);
7626+  catchAndAssertEquals(function() {
7627+    AVERAGE();
7628+  }, ERRORS.NA_ERROR);
7629+  catchAndAssertEquals(function() {
7630+    AVERAGE([]);
7631+  }, ERRORS.REF_ERROR);
7632+});
7633+
7634+
7635+test("AVERAGEA", function(){
7636+  assertEquals(AVERAGEA(1, 2, 4, 55), 15.5);
7637+  assertEquals(AVERAGEA(1, 2, 4, "55"), 15.5);
7638+  assertEquals(AVERAGEA(1, 2, 4, 55, false), 12.4);
7639+  assertEquals(AVERAGEA(1, 2, 4, 55, true), 12.6);
7640+  assertEquals(AVERAGEA(1, 2, 4, 55, 0), 12.4);
7641+  assertEquals(AVERAGEA(1, 2, 4, 55, 1), 12.6);
7642+  catchAndAssertEquals(function() {
7643+    AVERAGEA(1, 2, 4, "str");
7644+  }, ERRORS.VALUE_ERROR);
7645+  assertEquals(AVERAGEA([1, 2, 4, 55, "str"]), 12.4);
7646+  assertEquals(AVERAGEA([1, 2, 4, 55, "22"]), 12.4);
7647+  assertEquals(AVERAGEA([1, 2, 4, 55, 0]), 12.4);
7648+  assertEquals(AVERAGEA([0]), 0);
7649+  catchAndAssertEquals(function() {
7650+    AVERAGEA();
7651+  }, ERRORS.NA_ERROR);
7652+  catchAndAssertEquals(function() {
7653+    AVERAGEA([]);
7654+  }, ERRORS.REF_ERROR);
7655+});
7656+
7657+
7658+test("AVERAGEIF", function(){
7659+  assertEquals(AVERAGEIF([1, 5, 10], '>2'), 7.5);
7660+  assertEquals(AVERAGEIF([1, 5, 10], ">4"), 7.5);
7661+  assertEquals(AVERAGEIF([1, 2, 2, 2, 2, 2, 2, 2], ">1"), 2);
7662+  assertEquals(AVERAGEIF([1, 5, 10], 5), 5);
7663+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], 5), 5);
7664+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], 10), 10);
7665+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], ">5"), 10);
7666+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "=5"), 5);
7667+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "=10"), 10);
7668+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "=     10  "), 10);
7669+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], ">0"), 5.166666666666667);
7670+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], ">=5"), 6);
7671+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "<>1"), 6);
7672+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "<10"), 4.2);
7673+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5, 44], "<=10"), 5.166666666666667);
7674+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], ">4.99"), 6);
7675+  assertEquals(AVERAGEIF([1, 5, 5, 5, 10, 5], "<4.99"), 1);
7676+  catchAndAssertEquals(function() {
7677+    AVERAGEIF([1, 5, 5, 5, 10, 5], "=     1.0.0  ");
7678+  }, ERRORS.DIV_ZERO_ERROR);
7679+  catchAndAssertEquals(function() {
7680+    AVERAGEIF([1, 5, 5, 5, 10, 5], "=>5");
7681+  }, ERRORS.DIV_ZERO_ERROR);
7682+  catchAndAssertEquals(function() {
7683+    AVERAGEIF([1, 5, 5, 5, 10, 5], "==5");
7684+  }, ERRORS.DIV_ZERO_ERROR);
7685+});
7686+
7687+
7688+test("CORREL", function(){
7689+  assertEquals(CORREL([9, 5],[10, 4]), 1);
7690+  assertEquals(CORREL([10, 5, 16],[9, 3, 22]), 0.9876779373054069);
7691+  catchAndAssertEquals(function() {
7692+    CORREL(5, 5);
7693+  }, ERRORS.DIV_ZERO_ERROR);
7694+  catchAndAssertEquals(function() {
7695+    CORREL([9, true], [5, true]);
7696+  }, ERRORS.DIV_ZERO_ERROR);
7697+  catchAndAssertEquals(function() {
7698+    CORREL([9, "10"], [5, "10"]);
7699+  }, ERRORS.DIV_ZERO_ERROR);
7700+  catchAndAssertEquals(function() {
7701+    CORREL([9], [5]);
7702+  }, ERRORS.DIV_ZERO_ERROR);
7703+  catchAndAssertEquals(function() {
7704+    CORREL();
7705+  }, ERRORS.NA_ERROR);
7706+  catchAndAssertEquals(function() {
7707+    CORREL([9, 5]);
7708+  }, ERRORS.NA_ERROR);
7709+  catchAndAssertEquals(function() {
7710+    CORREL([9, 5],[10]);
7711+  }, ERRORS.NA_ERROR);
7712+});
7713+
7714+
7715+test("PEARSON", function(){
7716+  // same as CORREL
7717+  assertEquals(PEARSON([9, 5],[10, 4]), 1);
7718+});
7719+
7720+
7721+test("COUNT", function(){
7722+  assertEquals(COUNT([1, 5, 10, 0]), 4);
7723+  assertEquals(COUNT(1, 5, 10, 0), 4);
7724+  assertEquals(COUNT(1, 5, 10, "0"), 4);
7725+  assertEquals(COUNT(1, 5, 10, ["0", "str"]), 4);
7726+  assertEquals(COUNT(1, 5, 10, false), 4);
7727+  assertEquals(COUNT(1, 5, 10, true), 4);
7728+  assertEquals(COUNT([]), 0);
7729+  assertEquals(COUNT(["str"]), 0);
7730+  catchAndAssertEquals(function() {
7731+    COUNT();
7732+  }, ERRORS.NA_ERROR);
7733+});
7734+
7735+
7736+test("COUNTA", function(){
7737+  assertEquals(COUNTA(1, 2, 3), 3);
7738+  assertEquals(COUNTA(0, 1, 2, 3), 4);
7739+  assertEquals(COUNTA(0, 1, 2, 3, [], []), 6);
7740+  assertEquals(COUNTA(0, 1, 2, 3, [], ""), 6);
7741+  assertEquals(COUNTA(1, 2, "3"), 3);
7742+  assertEquals(COUNTA(1, 2, "3", ["str"]), 4);
7743+  assertEquals(COUNTA(1, 2, false), 3);
7744+  assertEquals(COUNTA(1, 2, true), 3);
7745+  assertEquals(COUNTA([]), 1);
7746+  catchAndAssertEquals(function() {
7747+    COUNTA();
7748+  }, ERRORS.NA_ERROR);
7749+});
7750+
7751+
7752+test("DEVSQ", function(){
7753+  assertEquals(DEVSQ(1, 2), 0.5);
7754+  assertEquals(DEVSQ([1, 2]), 0.5);
7755+  assertEquals(DEVSQ([1, [2]]), 0.5);
7756+  assertEquals(DEVSQ(1), 0);
7757+  assertEquals(DEVSQ(false), 0);
7758+  assertEquals(DEVSQ(true), 0);
7759+  assertEquals(DEVSQ(1, 2, 3, 4), 5);
7760+  assertEquals(DEVSQ([1, 2, 3, 4]), 5);
7761+  catchAndAssertEquals(function() {
7762+    DEVSQ(1, "str");
7763+  }, ERRORS.VALUE_ERROR);
7764+  catchAndAssertEquals(function() {
7765+    DEVSQ();
7766+  }, ERRORS.NA_ERROR);
7767+  catchAndAssertEquals(function() {
7768+    DEVSQ([1, 2, [], 3]);
7769+  }, ERRORS.REF_ERROR);
7770+});
7771+
7772+
7773+test("EXPONDIST", function(){
7774+  assertEquals(EXPONDIST(4, 0.5, false), 0.06766764161830635);
7775+  assertEquals(EXPONDIST(4, 0.5, 0), 0.06766764161830635);
7776+  assertEquals(EXPONDIST(4, 0.5, true), 0.8646647167633873);
7777+  assertEquals(EXPONDIST(4, 0.5, 1), 0.8646647167633873);
7778+  assertEquals(EXPONDIST(4, 0.5, -1), 0.8646647167633873);
7779+  assertEquals(EXPONDIST([4, "str"], ["0.5"], [false]), 0.06766764161830635);
7780+  catchAndAssertEquals(function() {
7781+    EXPONDIST("str", 0.5, "1");
7782+  }, ERRORS.VALUE_ERROR);
7783+  catchAndAssertEquals(function() {
7784+    EXPONDIST(4, 0.5, "1");
7785+  }, ERRORS.VALUE_ERROR);
7786+  catchAndAssertEquals(function() {
7787+    EXPONDIST();
7788+  }, ERRORS.NA_ERROR);
7789+  catchAndAssertEquals(function() {
7790+    EXPONDIST(4, 0.5);
7791+  }, ERRORS.NA_ERROR);
7792+  catchAndAssertEquals(function() {
7793+    EXPONDIST(4, 0.5, true, 1);
7794+  }, ERRORS.NA_ERROR);
7795+});
7796 
7797 
7798-// Test FISHER
7799-assertEquals(FISHER(0.962), 1.972066740199461);
7800-assertEquals(FISHER([0.962]), 1.972066740199461);
7801-assertEquals(FISHER("0.962"), 1.972066740199461);
7802-assertEquals(FISHER(0), 0);
7803-assertEquals(FISHER(false), 0);
7804-assertEquals(FISHER(0.92), 1.589026915173973);
7805-catchAndAssertEquals(function() {
7806-  FISHER("str");
7807-}, ERRORS.VALUE_ERROR);
7808-catchAndAssertEquals(function() {
7809-  FISHER(1);
7810-}, ERRORS.NUM_ERROR);
7811-catchAndAssertEquals(function() {
7812-  FISHER(-1);
7813-}, ERRORS.NUM_ERROR);
7814-catchAndAssertEquals(function() {
7815-  FISHER();
7816-}, ERRORS.NA_ERROR);
7817-catchAndAssertEquals(function() {
7818-  FISHER(0.55, 0.1);
7819-}, ERRORS.NA_ERROR);
7820-
7821-
7822-// Test FISHERINV
7823-assertEquals(FISHERINV(0.962), 0.7451676440945232);
7824-assertEquals(FISHERINV(0.962), 0.7451676440945232);
7825-assertEquals(FISHERINV([0.962]), 0.7451676440945232);
7826-assertEquals(FISHERINV("0.962"), 0.7451676440945232);
7827-assertEquals(FISHERINV(0), 0);
7828-assertEquals(FISHERINV(false), 0);
7829-assertEquals(FISHERINV(true), 0.761594155955765);
7830-assertEquals(FISHERINV(0.92), 0.7258974148490807);
7831-catchAndAssertEquals(function() {
7832-  FISHER("str");
7833-}, ERRORS.VALUE_ERROR);
7834-catchAndAssertEquals(function() {
7835-  FISHER();
7836-}, ERRORS.NA_ERROR);
7837-catchAndAssertEquals(function() {
7838-  FISHER(0.55, 0.1);
7839-}, ERRORS.NA_ERROR);
7840-
7841-
7842-// Test MAX
7843-assertEquals(MAX(100, 22), 100);
7844-assertEquals(MAX(100, "22"), 100);
7845-assertEquals(MAX(-100, false), 0);
7846-assertEquals(MAX(-100, true), 1);
7847-assertEquals(MAX(100, [101, 2]), 101);
7848-assertEquals(MAX(100, [101, 2, "10000"]), 101);
7849-assertEquals(MAX(100, ["10000"]), 100);
7850-catchAndAssertEquals(function() {
7851-  MAX(100, []);
7852-}, ERRORS.REF_ERROR);
7853-catchAndAssertEquals(function() {
7854-  MAX([]);
7855-}, ERRORS.REF_ERROR);
7856-catchAndAssertEquals(function() {
7857-  MAX();
7858-}, ERRORS.NA_ERROR);
7859-catchAndAssertEquals(function() {
7860-  MAX(100, "str");
7861-}, ERRORS.VALUE_ERROR);
7862-
7863-// Test MAXA
7864-assertEquals(MAXA(100, 22, 44), 100);
7865-
7866-
7867-// Tes MEDIAN
7868-assertEquals(MEDIAN(100, 22, 54), 54);
7869-assertEquals(MEDIAN(100, 22, "54"), 54);
7870-assertEquals(MEDIAN(100, 22), 61);
7871-assertEquals(MEDIAN(2), 2);
7872-assertEquals(MEDIAN(false), 0);
7873-assertEquals(MEDIAN(1, 1, 2, 6, 6, 9, 5), 5);
7874-assertEquals(MEDIAN(6, 6, 1, 1, 2, 9), 4);
7875-assertEquals(MEDIAN(1, 1, 2, [5, 6, 6, 9]), 5);
7876-catchAndAssertEquals(function() {
7877-  MEDIAN(1, 1, 2, 5, "mmm", 6, 6, 9);
7878-}, ERRORS.VALUE_ERROR);
7879-assertEquals(MEDIAN(1, 1, 2, [5, "mmm", 6, 6, 9]), 5);
7880-assertEquals(MEDIAN(1, 1, 2, ["mm"]), 1);
7881-assertEquals(MEDIAN(100, 22, 1, 14), 18);
7882-assertEquals(MEDIAN(100, 22, 1, 1), 11.5);
7883-assertEquals(MEDIAN(100, 22, 1), 22);
7884-assertEquals(MEDIAN(100, 22, [54]), 54);
7885-assertEquals(MEDIAN(100, 22, ["str"]), 61);
7886-catchAndAssertEquals(function() {
7887-  MEDIAN(10, 22, "str");
7888-}, ERRORS.VALUE_ERROR);
7889-catchAndAssertEquals(function() {
7890-  MEDIAN();
7891-}, ERRORS.NA_ERROR);
7892-catchAndAssertEquals(function() {
7893-  MEDIAN(["str"]);
7894-}, ERRORS.NUM_ERROR);
7895-
7896-
7897-// Test MIN
7898-assertEquals(MIN(100, 22, 44), 22);
7899-assertEquals(MIN(100, "22"), 22);
7900-assertEquals(MIN(100, false), 0);
7901-assertEquals(MIN(100, true), 1);
7902-assertEquals(MIN(100, [101, 2]), 2);
7903-assertEquals(MIN(100, [101, 2, "-10"]), 2);
7904-assertEquals(MIN(100, ["-10"]), 100);
7905-catchAndAssertEquals(function() {
7906-  MIN(100, []);
7907-}, ERRORS.REF_ERROR);
7908-catchAndAssertEquals(function() {
7909-  MIN([]);
7910-}, ERRORS.REF_ERROR);
7911-catchAndAssertEquals(function() {
7912-  MIN();
7913-}, ERRORS.NA_ERROR);
7914-catchAndAssertEquals(function() {
7915-  MIN(100, "str");
7916-}, ERRORS.VALUE_ERROR);
7917-
7918-
7919-// Test MINA
7920-assertEquals(MINA(100, 22, 44), 22);
7921-
7922-
7923-// Test F.DIST
7924-assertEquals(FDIST$LEFTTAILED(15.35, 7, 6, false), 0.0003451054686025578);
7925-assertEquals(FDIST$LEFTTAILED(15.35, 7, 6, true), 0.9980694465675269);
7926-assertEquals(FDIST$LEFTTAILED(15.35, 7, 6, 1), 0.9980694465675269);
7927-assertEquals(FDIST$LEFTTAILED(15.35, "7", [6], 1), 0.9980694465675269);
7928-assertEquals(FDIST$LEFTTAILED(15.35, "7", [6], 10), 0.9980694465675269);
7929-catchAndAssertEquals(function() {
7930-  FDIST$LEFTTAILED(15.35, 7, 6, "10");
7931-}, ERRORS.VALUE_ERROR);
7932-catchAndAssertEquals(function() {
7933-  FDIST$LEFTTAILED(-15.35, 7, 6, 1);
7934-}, ERRORS.NUM_ERROR);
7935-catchAndAssertEquals(function() {
7936-  FDIST$LEFTTAILED(15.35, 7, 6);
7937-}, ERRORS.NA_ERROR);
7938-catchAndAssertEquals(function() {
7939-  FDIST$LEFTTAILED();
7940-}, ERRORS.NA_ERROR);
7941\ No newline at end of file
7942+// TODO: Test this more.
7943+test("FINV", function(){
7944+  assertEquals(FINV(0.42, 2, 3), 1.174597274485816);
7945+});
7946+
7947+
7948+
7949+test("FISHER", function(){
7950+  assertEquals(FISHER(0.962), 1.972066740199461);
7951+  assertEquals(FISHER([0.962]), 1.972066740199461);
7952+  assertEquals(FISHER("0.962"), 1.972066740199461);
7953+  assertEquals(FISHER(0), 0);
7954+  assertEquals(FISHER(false), 0);
7955+  assertEquals(FISHER(0.92), 1.589026915173973);
7956+  catchAndAssertEquals(function() {
7957+    FISHER("str");
7958+  }, ERRORS.VALUE_ERROR);
7959+  catchAndAssertEquals(function() {
7960+    FISHER(1);
7961+  }, ERRORS.NUM_ERROR);
7962+  catchAndAssertEquals(function() {
7963+    FISHER(-1);
7964+  }, ERRORS.NUM_ERROR);
7965+  catchAndAssertEquals(function() {
7966+    FISHER();
7967+  }, ERRORS.NA_ERROR);
7968+  catchAndAssertEquals(function() {
7969+    FISHER(0.55, 0.1);
7970+  }, ERRORS.NA_ERROR);
7971+});
7972+
7973+
7974+test("FISHERINV", function(){
7975+  assertEquals(FISHERINV(0.962), 0.7451676440945232);
7976+  assertEquals(FISHERINV(0.962), 0.7451676440945232);
7977+  assertEquals(FISHERINV([0.962]), 0.7451676440945232);
7978+  assertEquals(FISHERINV("0.962"), 0.7451676440945232);
7979+  assertEquals(FISHERINV(0), 0);
7980+  assertEquals(FISHERINV(false), 0);
7981+  assertEquals(FISHERINV(true), 0.761594155955765);
7982+  assertEquals(FISHERINV(0.92), 0.7258974148490807);
7983+  catchAndAssertEquals(function() {
7984+    FISHER("str");
7985+  }, ERRORS.VALUE_ERROR);
7986+  catchAndAssertEquals(function() {
7987+    FISHER();
7988+  }, ERRORS.NA_ERROR);
7989+  catchAndAssertEquals(function() {
7990+    FISHER(0.55, 0.1);
7991+  }, ERRORS.NA_ERROR);
7992+});
7993+
7994+
7995+test("MAX", function(){
7996+  assertEquals(MAX(100, 22), 100);
7997+  assertEquals(MAX(100, "22"), 100);
7998+  assertEquals(MAX(-100, false), 0);
7999+  assertEquals(MAX(-100, true), 1);
8000+  assertEquals(MAX(100, [101, 2]), 101);
8001+  assertEquals(MAX(100, [101, 2, "10000"]), 101);
8002+  assertEquals(MAX(100, ["10000"]), 100);
8003+  catchAndAssertEquals(function() {
8004+    MAX(100, []);
8005+  }, ERRORS.REF_ERROR);
8006+  catchAndAssertEquals(function() {
8007+    MAX([]);
8008+  }, ERRORS.REF_ERROR);
8009+  catchAndAssertEquals(function() {
8010+    MAX();
8011+  }, ERRORS.NA_ERROR);
8012+  catchAndAssertEquals(function() {
8013+    MAX(100, "str");
8014+  }, ERRORS.VALUE_ERROR);
8015+});
8016+
8017+
8018+// TODO: More tests here.
8019+test("MAXA", function(){
8020+  assertEquals(MAXA(100, 22, 44), 100);
8021+});
8022+
8023+
8024+test("MEDIAN", function(){
8025+  assertEquals(MEDIAN(100, 22, 54), 54);
8026+  assertEquals(MEDIAN(100, 22, "54"), 54);
8027+  assertEquals(MEDIAN(100, 22), 61);
8028+  assertEquals(MEDIAN(2), 2);
8029+  assertEquals(MEDIAN(false), 0);
8030+  assertEquals(MEDIAN(1, 1, 2, 6, 6, 9, 5), 5);
8031+  assertEquals(MEDIAN(6, 6, 1, 1, 2, 9), 4);
8032+  assertEquals(MEDIAN(1, 1, 2, [5, 6, 6, 9]), 5);
8033+  catchAndAssertEquals(function() {
8034+    MEDIAN(1, 1, 2, 5, "mmm", 6, 6, 9);
8035+  }, ERRORS.VALUE_ERROR);
8036+  assertEquals(MEDIAN(1, 1, 2, [5, "mmm", 6, 6, 9]), 5);
8037+  assertEquals(MEDIAN(1, 1, 2, ["mm"]), 1);
8038+  assertEquals(MEDIAN(100, 22, 1, 14), 18);
8039+  assertEquals(MEDIAN(100, 22, 1, 1), 11.5);
8040+  assertEquals(MEDIAN(100, 22, 1), 22);
8041+  assertEquals(MEDIAN(100, 22, [54]), 54);
8042+  assertEquals(MEDIAN(100, 22, ["str"]), 61);
8043+  catchAndAssertEquals(function() {
8044+    MEDIAN(10, 22, "str");
8045+  }, ERRORS.VALUE_ERROR);
8046+  catchAndAssertEquals(function() {
8047+    MEDIAN();
8048+  }, ERRORS.NA_ERROR);
8049+  catchAndAssertEquals(function() {
8050+    MEDIAN(["str"]);
8051+  }, ERRORS.NUM_ERROR);
8052+});
8053+
8054+
8055+test("MIN", function(){
8056+  assertEquals(MIN(100, 22, 44), 22);
8057+  assertEquals(MIN(100, "22"), 22);
8058+  assertEquals(MIN(100, false), 0);
8059+  assertEquals(MIN(100, true), 1);
8060+  assertEquals(MIN(100, [101, 2]), 2);
8061+  assertEquals(MIN(100, [101, 2, "-10"]), 2);
8062+  assertEquals(MIN(100, ["-10"]), 100);
8063+  catchAndAssertEquals(function() {
8064+    MIN(100, []);
8065+  }, ERRORS.REF_ERROR);
8066+  catchAndAssertEquals(function() {
8067+    MIN([]);
8068+  }, ERRORS.REF_ERROR);
8069+  catchAndAssertEquals(function() {
8070+    MIN();
8071+  }, ERRORS.NA_ERROR);
8072+  catchAndAssertEquals(function() {
8073+    MIN(100, "str");
8074+  }, ERRORS.VALUE_ERROR);
8075+});
8076+
8077+
8078+// TODO: More tests for MINA
8079+test("MINA", function(){
8080+  assertEquals(MINA(100, 22, 44), 22);
8081+});
8082+
8083+
8084+test("F.DIST", function(){
8085+  assertEquals(FDIST$LEFTTAILED(15.35, 7, 6, false), 0.0003451054686025578);
8086+  assertEquals(FDIST$LEFTTAILED(15.35, 7, 6, true), 0.9980694465675269);
8087+  assertEquals(FDIST$LEFTTAILED(15.35, 7, 6, 1), 0.9980694465675269);
8088+  assertEquals(FDIST$LEFTTAILED(15.35, "7", [6], 1), 0.9980694465675269);
8089+  assertEquals(FDIST$LEFTTAILED(15.35, "7", [6], 10), 0.9980694465675269);
8090+  catchAndAssertEquals(function() {
8091+    FDIST$LEFTTAILED(15.35, 7, 6, "10");
8092+  }, ERRORS.VALUE_ERROR);
8093+  catchAndAssertEquals(function() {
8094+    FDIST$LEFTTAILED(-15.35, 7, 6, 1);
8095+  }, ERRORS.NUM_ERROR);
8096+  catchAndAssertEquals(function() {
8097+    FDIST$LEFTTAILED(15.35, 7, 6);
8098+  }, ERRORS.NA_ERROR);
8099+  catchAndAssertEquals(function() {
8100+    FDIST$LEFTTAILED();
8101+  }, ERRORS.NA_ERROR);
8102+});
8103diff --git a/tests/Formulas/TextTest.ts b/tests/Formulas/TextTest.ts
8104index d3d60ab..ff50705 100644
8105--- a/tests/Formulas/TextTest.ts
8106+++ b/tests/Formulas/TextTest.ts
8107@@ -10,103 +10,111 @@ import * as ERRORS from "../../src/Errors";
8108 import {
8109   assertEquals,
8110   assertArrayEquals,
8111-  catchAndAssertEquals
8112+  catchAndAssertEquals,
8113+  test
8114 } from "../utils/Asserts";
8115 
8116 
8117-// Test SPLIT
8118-assertArrayEquals(SPLIT("1,2,3", ","), ['1', '2', '3']);
8119-assertArrayEquals(SPLIT("little kitty cat", "i"), ['l', 'ttle k', 'tty cat']);
8120-assertArrayEquals(SPLIT("father sister berzerker", "er", true), ['fath', ' sist', ' b', 'z', 'k']);
8121-assertArrayEquals(SPLIT("father sister berzerker", "er", [true]), ['fath', ' sist', ' b', 'z', 'k']);
8122-assertArrayEquals(SPLIT("father  sister   berzerker", "er", true), ['fath', '  sist', '   b', 'z', 'k']);
8123-assertArrayEquals(SPLIT(["father sister berzerker"], ["er"], true), ['fath', ' sist', ' b', 'z', 'k']);
8124-catchAndAssertEquals(function() {
8125-  SPLIT([], "er");
8126-}, ERRORS.REF_ERROR);
8127-catchAndAssertEquals(function() {
8128-  SPLIT("er", "er", true, 10);
8129-}, ERRORS.NA_ERROR);
8130+test("SPLIT", function(){
8131+  assertArrayEquals(SPLIT("1,2,3", ","), ['1', '2', '3']);
8132+  assertArrayEquals(SPLIT("little kitty cat", "i"), ['l', 'ttle k', 'tty cat']);
8133+  assertArrayEquals(SPLIT("father sister berzerker", "er", true), ['fath', ' sist', ' b', 'z', 'k']);
8134+  assertArrayEquals(SPLIT("father sister berzerker", "er", [true]), ['fath', ' sist', ' b', 'z', 'k']);
8135+  assertArrayEquals(SPLIT("father  sister   berzerker", "er", true), ['fath', '  sist', '   b', 'z', 'k']);
8136+  assertArrayEquals(SPLIT(["father sister berzerker"], ["er"], true), ['fath', ' sist', ' b', 'z', 'k']);
8137+  catchAndAssertEquals(function() {
8138+    SPLIT([], "er");
8139+  }, ERRORS.REF_ERROR);
8140+  catchAndAssertEquals(function() {
8141+    SPLIT("er", "er", true, 10);
8142+  }, ERRORS.NA_ERROR);
8143+});
8144 
8145 
8146-// Test CHAR
8147-assertEquals(CHAR(97), "a");
8148-assertEquals(CHAR("97"), "a");
8149-assertEquals(CHAR([97, "m"]), "a");
8150-assertEquals(CHAR([[97], "m"]), "a");
8151-catchAndAssertEquals(function() {
8152-  CHAR([[], [97], "m"]);
8153-}, ERRORS.REF_ERROR);
8154-catchAndAssertEquals(function() {
8155-  CHAR(false);
8156-}, ERRORS.NUM_ERROR);
8157-catchAndAssertEquals(function() {
8158-  CHAR(10000000);
8159-}, ERRORS.NUM_ERROR);
8160-catchAndAssertEquals(function() {
8161-  CHAR(0);
8162-}, ERRORS.NUM_ERROR);
8163-catchAndAssertEquals(function() {
8164-  CHAR();
8165-}, ERRORS.NA_ERROR);
8166+test("CHAR", function(){
8167+  assertEquals(CHAR(97), "a");
8168+  assertEquals(CHAR("97"), "a");
8169+  assertEquals(CHAR([97, "m"]), "a");
8170+  assertEquals(CHAR([[97], "m"]), "a");
8171+  catchAndAssertEquals(function() {
8172+    CHAR([[], [97], "m"]);
8173+  }, ERRORS.REF_ERROR);
8174+  catchAndAssertEquals(function() {
8175+    CHAR(false);
8176+  }, ERRORS.NUM_ERROR);
8177+  catchAndAssertEquals(function() {
8178+    CHAR(10000000);
8179+  }, ERRORS.NUM_ERROR);
8180+  catchAndAssertEquals(function() {
8181+    CHAR(0);
8182+  }, ERRORS.NUM_ERROR);
8183+  catchAndAssertEquals(function() {
8184+    CHAR();
8185+  }, ERRORS.NA_ERROR);
8186+});
8187 
8188 
8189-// Test CODE
8190-assertEquals(CODE('a'), 97);
8191-assertEquals(CODE('aa'), 97);
8192-assertEquals(CODE('aM'), 97);
8193-assertEquals(CODE('#'), 35);
8194-assertEquals(CODE(false), 70);
8195-assertEquals(CODE(true), 84);
8196-catchAndAssertEquals(function() {
8197-  CODE();
8198-}, ERRORS.NA_ERROR);
8199-catchAndAssertEquals(function() {
8200-  CODE("a", "m");
8201-}, ERRORS.NA_ERROR);
8202-catchAndAssertEquals(function() {
8203-  CODE("");
8204-}, ERRORS.VALUE_ERROR);
8205-assertEquals(CODE(['a']), 97);
8206-assertEquals(CODE([['a'], 'p']), 97);
8207+test("CODE", function(){
8208+  assertEquals(CODE('a'), 97);
8209+  assertEquals(CODE('aa'), 97);
8210+  assertEquals(CODE('aM'), 97);
8211+  assertEquals(CODE('#'), 35);
8212+  assertEquals(CODE(false), 70);
8213+  assertEquals(CODE(true), 84);
8214+  catchAndAssertEquals(function() {
8215+    CODE();
8216+  }, ERRORS.NA_ERROR);
8217+  catchAndAssertEquals(function() {
8218+    CODE("a", "m");
8219+  }, ERRORS.NA_ERROR);
8220+  catchAndAssertEquals(function() {
8221+    CODE("");
8222+  }, ERRORS.VALUE_ERROR);
8223+  assertEquals(CODE(['a']), 97);
8224+  assertEquals(CODE([['a'], 'p']), 97);
8225+});
8226 
8227 
8228-// Test CONCATENATE
8229-assertEquals(CONCATENATE("hey", " ", "there"), "hey there");
8230-assertEquals(CONCATENATE(["hey", " ", "there"]), "hey there");
8231-assertEquals(CONCATENATE("hey"), "hey");
8232-assertEquals(CONCATENATE("hey", 2), "hey2");
8233-assertEquals(CONCATENATE("hey", false), "heyFALSE");
8234-assertEquals(CONCATENATE([22, 14, "m", false]), "2214mFALSE");
8235-assertEquals(CONCATENATE([22, 14, ["m", false]]), "2214mFALSE");
8236-catchAndAssertEquals(function() {
8237-  CONCATENATE();
8238-}, ERRORS.NA_ERROR);
8239-catchAndAssertEquals(function() {
8240-  CONCATENATE("10", 4, false, []);
8241-}, ERRORS.REF_ERROR);
8242-catchAndAssertEquals(function() {
8243-  CONCATENATE([]);
8244-}, ERRORS.REF_ERROR);
8245+test("CONCATENATE", function(){
8246+  assertEquals(CONCATENATE("hey", " ", "there"), "hey there");
8247+  assertEquals(CONCATENATE(["hey", " ", "there"]), "hey there");
8248+  assertEquals(CONCATENATE("hey"), "hey");
8249+  assertEquals(CONCATENATE("hey", 2), "hey2");
8250+  assertEquals(CONCATENATE("hey", false), "heyFALSE");
8251+  assertEquals(CONCATENATE([22, 14, "m", false]), "2214mFALSE");
8252+  assertEquals(CONCATENATE([22, 14, ["m", false]]), "2214mFALSE");
8253+  catchAndAssertEquals(function() {
8254+    CONCATENATE();
8255+  }, ERRORS.NA_ERROR);
8256+  catchAndAssertEquals(function() {
8257+    CONCATENATE("10", 4, false, []);
8258+  }, ERRORS.REF_ERROR);
8259+  catchAndAssertEquals(function() {
8260+    CONCATENATE([]);
8261+  }, ERRORS.REF_ERROR);
8262+});
8263 
8264 
8265-// Test CONVERT
8266-assertEquals(CONVERT(5.1, "mm", "m"), 0.0050999999999999995);
8267-assertEquals(CONVERT(5.1, "mm", "km"), 0.0000050999999999999995);
8268-assertEquals(CONVERT(5.1, "g", "kg"), 0.0050999999999999995);
8269-assertEquals(CONVERT(35.7, "in^2", "m^2"), 0.023032212);
8270+// TODO: More tests for CONVERT.
8271+test("CONVERT", function(){
8272+  assertEquals(CONVERT(5.1, "mm", "m"), 0.0050999999999999995);
8273+  assertEquals(CONVERT(5.1, "mm", "km"), 0.0000050999999999999995);
8274+  assertEquals(CONVERT(5.1, "g", "kg"), 0.0050999999999999995);
8275+  assertEquals(CONVERT(35.7, "in^2", "m^2"), 0.023032212);
8276+});
8277 
8278 
8279-// Test ARABIC
8280-assertEquals(ARABIC("XIV"), 14);
8281-assertEquals(ARABIC("M"), 1000);
8282-assertEquals(ARABIC("-IV"), -4);
8283-catchAndAssertEquals(function() {
8284-  ARABIC("b");
8285-}, ERRORS.VALUE_ERROR);
8286-catchAndAssertEquals(function() {
8287-  ARABIC(false);
8288-}, ERRORS.VALUE_ERROR);
8289-catchAndAssertEquals(function() {
8290-  ARABIC(10);
8291-}, ERRORS.VALUE_ERROR);
8292\ No newline at end of file
8293+test("ARABIC", function(){
8294+  assertEquals(ARABIC("XIV"), 14);
8295+  assertEquals(ARABIC("M"), 1000);
8296+  assertEquals(ARABIC("-IV"), -4);
8297+  catchAndAssertEquals(function() {
8298+    ARABIC("b");
8299+  }, ERRORS.VALUE_ERROR);
8300+  catchAndAssertEquals(function() {
8301+    ARABIC(false);
8302+  }, ERRORS.VALUE_ERROR);
8303+  catchAndAssertEquals(function() {
8304+    ARABIC(10);
8305+  }, ERRORS.VALUE_ERROR);
8306+});
8307diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
8308index eb8e20b..7eed83e 100644
8309--- a/tests/SheetFormulaTest.ts
8310+++ b/tests/SheetFormulaTest.ts
8311@@ -2,10 +2,11 @@ import {
8312   Sheet
8313 } from "../src/Sheet";
8314 import {
8315-  assertEquals
8316+  assertEquals,
8317+  test
8318 } from "./utils/Asserts";
8319 
8320-function testFormula(formula: string, expectation: any) {
8321+function assertFormulaEquals(formula: string, expectation: any) {
8322   var sheet  = new Sheet();
8323   sheet.setCell("A1", formula);
8324   var cell = sheet.getCell("A1");
8325@@ -24,186 +25,235 @@ function testFormulaToArray(formula: string, expectation: any) {
8326   }
8327 }
8328 
8329-// Test ABS formula
8330-testFormula("=ABS(-10)", 10);
8331-testFormula("=ABS(0)", 0);
8332+test("Sheet ABS", function(){
8333+  assertFormulaEquals("=ABS(-10)", 10);
8334+  assertFormulaEquals("=ABS(0)", 0);
8335+});
8336 
8337-// Test ACOS
8338-testFormula("=ACOS(0)", 1.5707963267948966);
8339+test("Sheet ACOS", function(){
8340+  assertFormulaEquals("=ACOS(0)", 1.5707963267948966);
8341+});
8342 
8343-// Test ACOSH
8344-testFormula("=ACOSH(22)", 3.783672704329451);
8345+test("Sheet ACOSH", function(){
8346+  assertFormulaEquals("=ACOSH(22)", 3.783672704329451);
8347+});
8348 
8349-// Test ACOTH
8350-testFormula("=ACOTH(22)", 0.04548588910286339);
8351+test("Sheet ACOTH", function(){
8352+  assertFormulaEquals("=ACOTH(22)", 0.04548588910286339);
8353+});
8354 
8355-// Test AND
8356-testFormula("=AND(10, 10)", true);
8357-testFormula("=AND(10, 0)", false);
8358+test("Sheet AND", function(){
8359+  assertFormulaEquals("=AND(10, 10)", true);
8360+  assertFormulaEquals("=AND(10, 0)", false);
8361+});
8362 
8363-// Test ARABIC
8364-testFormula('=ARABIC("XIV")', 14);
8365+test("Sheet ARABIC", function(){
8366+  assertFormulaEquals('=ARABIC("XIV")', 14);
8367+});
8368 
8369-// Test ASIN
8370-testFormula("=ASIN(0.1)", 0.1001674211615598);
8371+test("Sheet ASIN", function(){
8372+  assertFormulaEquals("=ASIN(0.1)", 0.1001674211615598);
8373+});
8374 
8375-// Test ASINH
8376-testFormula("=ASINH(0.1)", 0.09983407889920758);
8377+test("Sheet ASINH", function(){
8378+  assertFormulaEquals("=ASINH(0.1)", 0.09983407889920758);
8379+});
8380 
8381-// Test ATAN
8382-testFormula("=ATAN(0.1)", 0.09966865249116204);
8383+test("Sheet ATAN", function(){
8384+  assertFormulaEquals("=ATAN(0.1)", 0.09966865249116204);
8385+});
8386 
8387-// Test ATAN2
8388-testFormula("=ATAN2(4, 3)", 0.6435011087932844);
8389+test("Sheet ATAN2", function(){
8390+  assertFormulaEquals("=ATAN2(4, 3)", 0.6435011087932844);
8391+});
8392 
8393-// Test ATANH
8394-testFormula("=ATANH(0.51)", 0.5627297693521489);
8395+test("Sheet ATANH", function(){
8396+  assertFormulaEquals("=ATANH(0.51)", 0.5627297693521489);
8397+});
8398 
8399-// Test AVEDEV
8400-testFormula("=AVEDEV(1, 2, 4, 56.7)", 20.387500000000003);
8401+test("Sheet AVEDEV", function(){
8402+  assertFormulaEquals("=AVEDEV(1, 2, 4, 56.7)", 20.387500000000003);
8403+});
8404 
8405-// Test AVERAGE
8406-testFormula("=AVERAGE(10, 20, 4.1)", 11.366666666666667);
8407+test("Sheet AVERAGE", function(){
8408+  assertFormulaEquals("=AVERAGE(10, 20, 4.1)", 11.366666666666667);
8409+});
8410 
8411-// Test AVERAGEA
8412-testFormula("=AVERAGEA(10, 20, 4.1)", 11.366666666666667);
8413+test("Sheet AVERAGEA", function(){
8414+  assertFormulaEquals("=AVERAGEA(10, 20, 4.1)", 11.366666666666667);
8415+});
8416 
8417-// Test AVERAGEIF
8418-testFormula("=AVERAGEIF([1, 5, 10], '>2')", 7.5);
8419+test("Sheet AVERAGEIF", function(){
8420+  assertFormulaEquals("=AVERAGEIF([1, 5, 10], '>2')", 7.5);
8421+});
8422 
8423-// Test BIN2DEC
8424-testFormula("=BIN2DEC('1010101010')", -342);
8425+test("Sheet BIN2DEC", function(){
8426+  assertFormulaEquals("=BIN2DEC('1010101010')", -342);
8427+});
8428 
8429-// Test BIN2HEX
8430-testFormula("=BIN2HEX(1010101010)", "FFFFFFFEAA");
8431+test("Sheet BIN2HEX", function(){
8432+  assertFormulaEquals("=BIN2HEX(1010101010)", "FFFFFFFEAA");
8433+});
8434 
8435-// Test BIN2OCT
8436-testFormula("=BIN2OCT(1010101010)", "7777777252");
8437+test("Sheet BIN2OCT", function(){
8438+  assertFormulaEquals("=BIN2OCT(1010101010)", "7777777252");
8439+});
8440 
8441-// Test CEIL
8442-testFormula("=CEILING(22.22, 0.1)", 22.3);
8443+test("Sheet CEILING", function(){
8444+  assertFormulaEquals("=CEILING(22.22, 0.1)", 22.3);
8445+});
8446 
8447-// Test CHAR
8448-testFormula("=CHAR(97)", "a");
8449+test("Sheet CHAR", function(){
8450+  assertFormulaEquals("=CHAR(97)", "a");
8451+});
8452 
8453-// Test CODE
8454-testFormula("=CODE('a')", 97);
8455+test("Sheet CODE", function(){
8456+  assertFormulaEquals("=CODE('a')", 97);
8457+});
8458 
8459-// Test COMBIN
8460-testFormula("=COMBIN(4, 2)", 6);
8461+test("Sheet COMBIN", function(){
8462+  assertFormulaEquals("=COMBIN(4, 2)", 6);
8463+});
8464 
8465-// Test CONCATENATE
8466-testFormula('=CONCATENATE("hey", " ", "there")', "hey there");
8467+test("Sheet CONCATENATE", function(){
8468+  assertFormulaEquals('=CONCATENATE("hey", " ", "there")', "hey there");
8469+});
8470 
8471-// Test CONVERT
8472-testFormula('=CONVERT(5.1, "mm", "m")', 0.0050999999999999995);
8473+test("Sheet CONVERT", function(){
8474+  assertFormulaEquals('=CONVERT(5.1, "mm", "m")', 0.0050999999999999995);
8475+});
8476 
8477-// Test CORREL
8478-testFormula('=CORREL([9, 5],[10, 4])', 1);
8479+test("Sheet CORREL", function(){
8480+  assertFormulaEquals('=CORREL([9, 5],[10, 4])', 1);
8481+});
8482 
8483-// Test COS
8484-testFormula("=COS(PI())", -1);
8485+test("Sheet COS", function(){
8486+  assertFormulaEquals("=COS(PI())", -1);
8487+});
8488 
8489-// Test COSH
8490-testFormula("=COSH(PI())", 11.591953275521522);
8491+test("Sheet COSH", function(){
8492+  assertFormulaEquals("=COSH(PI())", 11.591953275521522);
8493+});
8494 
8495-// Test COT
8496-testFormula('=COT(30)', -0.15611995216165922);
8497+test("Sheet COT", function(){
8498+  assertFormulaEquals('=COT(30)', -0.15611995216165922);
8499+});
8500 
8501-// Test COTH
8502-testFormula('=COTH(2)', 1.037314720727548);
8503+test("Sheet COTH", function(){
8504+  assertFormulaEquals('=COTH(2)', 1.037314720727548);
8505+});
8506 
8507-// Test COUNT
8508-testFormula('=COUNT([1, 5, 10])', 3);
8509+test("Sheet COUNT", function(){
8510+  assertFormulaEquals('=COUNT([1, 5, 10])', 3);
8511+});
8512 
8513-// Test COUNTA
8514-testFormula("=COUNTA(10, 10, 22)", 3);
8515+test("Sheet COUNTA", function(){
8516+  assertFormulaEquals("=COUNTA(10, 10, 22)", 3);
8517+});
8518 
8519-// Test COUNTIF
8520-testFormula('=COUNTIF([1, 5, 10], ">4")', 2);
8521+test("Sheet COUNTIF", function(){
8522+  assertFormulaEquals('=COUNTIF([1, 5, 10], ">4")', 2);
8523+});
8524 
8525-// Test COUNTIFS
8526-testFormula('=COUNTIFS([1, 5, 10], ">4", [1, 5, 10], ">4")', 2);
8527+test("Sheet COUNTIFS", function(){
8528+  assertFormulaEquals('=COUNTIFS([1, 5, 10], ">4", [1, 5, 10], ">4")', 2);
8529+});
8530 
8531-// Test COUNTUNIQUE
8532-testFormula('=COUNTUNIQUE([1, 1, 10])', 2);
8533+test("Sheet COUNTUNIQUE", function(){
8534+  assertFormulaEquals('=COUNTUNIQUE([1, 1, 10])', 2);
8535+});
8536 
8537-// Test CUMIPMT
8538-testFormula("=CUMIPMT(0.12, 12, 100, 1, 5, 0)", -54.39423242396348);
8539+test("Sheet CUMIPMT", function(){
8540+  assertFormulaEquals("=CUMIPMT(0.12, 12, 100, 1, 5, 0)", -54.39423242396348);
8541+});
8542 
8543-// Test CUMPRINC
8544-testFormula("=CUMPRINC(0.12, 12, 100, 1, 5, 0)", -26.324171373034403);
8545+test("Sheet COMPRINC", function(){
8546+  assertFormulaEquals("=CUMPRINC(0.12, 12, 100, 1, 5, 0)", -26.324171373034403);
8547+});
8548 
8549-// Test DB
8550-testFormula("=DB(100, 50, 10, 2, 12)", 6.2482428240683285);
8551+test("Sheet DB", function(){
8552+  assertFormulaEquals("=DB(100, 50, 10, 2, 12)", 6.2482428240683285);
8553+});
8554 
8555-// Test DDB
8556-testFormula("=DDB(100, 50, 10, 2, 2.25)", 17.4375);
8557+test("Sheet DDB", function(){
8558+  assertFormulaEquals("=DDB(100, 50, 10, 2, 2.25)", 17.4375);
8559+});
8560 
8561-// Test DEC2BIN
8562-testFormula('=DEC2BIN("100", 8)', "01100100");
8563+test("Sheet DEC2BIN", function(){
8564+  assertFormulaEquals('=DEC2BIN("100", 8)', "01100100");
8565+});
8566 
8567-// Test DEC2HEX
8568-testFormula('=DEC2HEX("100")', "64");
8569+test("Sheet DEC2HEX", function(){
8570+  assertFormulaEquals('=DEC2HEX("100")', "64");
8571+});
8572 
8573-// Test DEC2OCT
8574-testFormula('=DEC2OCT("100")', "144");
8575+test("Sheet DEC2OCT", function(){
8576+  assertFormulaEquals('=DEC2OCT("100")', "144");
8577+});
8578 
8579-// Test DEGREES
8580-testFormula('=DEGREES(PI())', 180);
8581+test("Sheet DEGREES", function(){
8582+  assertFormulaEquals('=DEGREES(PI())', 180);
8583+});
8584 
8585-// Test DELTA
8586-testFormula('=DELTA(2, 2)', 1);
8587+test("Sheet DELTA", function(){
8588+  assertFormulaEquals('=DELTA(2, 2)', 1);
8589+});
8590 
8591-// Test DEVSQ
8592-testFormula('=DEVSQ(1, 2)', 0.5);
8593+test("Sheet DEVSQ", function(){
8594+  assertFormulaEquals('=DEVSQ(1, 2)', 0.5);
8595+});
8596 
8597-// Test DOLLAR
8598-testFormula('=DOLLAR(1.2351, 4)', 1.2351);
8599+test("Sheet DOLLAR", function(){
8600+  assertFormulaEquals('=DOLLAR(1.2351, 4)', 1.2351);
8601+});
8602 
8603-// Test DOLLARDE
8604-testFormula('=DOLLARDE(100.1, 32)', 100.3125);
8605+test("Sheet DOLLARDE", function(){
8606+  assertFormulaEquals('=DOLLARDE(100.1, 32)', 100.3125);
8607+});
8608 
8609-// Test DOLLARFR
8610-testFormula('=DOLLARFR(100.1, 32)', 100.032);
8611+test("Sheet DOLLARFR", function(){
8612+  assertFormulaEquals('=DOLLARFR(100.1, 32)', 100.032);
8613+});
8614 
8615-// Test AND
8616-testFormula('=AND(10)', true);
8617+test("Sheet AND", function(){
8618+  assertFormulaEquals('=AND(10)', true);
8619+});
8620 
8621-// Test EDATE
8622-// testFormulaToDate('=EDATE(DATE(1992, 6, 24), 1)', new Date('7/24/1992').getTime());
8623+test("Sheet EFFECT", function(){
8624+  assertFormulaEquals('=EFFECT(0.99, 12)', 1.5890167507927795);
8625+});
8626 
8627-// Test EFFECT
8628-testFormula('=EFFECT(0.99, 12)', 1.5890167507927795);
8629+test("Sheet ERF", function(){
8630+  assertFormulaEquals('=ERF(2)', 0.9953222650189527);
8631+});
8632 
8633-// EOMONTH
8634-// testFormulaToDate('=EOMONTH(DATE(1992, 6, 24), 1)', new Date('7/31/1992').getTime());
8635+test("Sheet ERFC", function(){
8636+  assertFormulaEquals('=ERFC(2)', 0.004677734981047288);
8637+});
8638 
8639-// Test ERF
8640-testFormula('=ERF(2)', 0.9953222650189527);
8641+test("Sheet EVEN", function(){
8642+  assertFormulaEquals('=EVEN(3)', 4);
8643+});
8644 
8645-// Test ERFC
8646-testFormula('=ERFC(2)', 0.004677734981047288);
8647+test("Sheet EXACT", function(){
8648+  assertFormulaEquals('=EXACT("m", "M")', false);
8649+});
8650 
8651-// Test EVEN
8652-testFormula('=EVEN(3)', 4);
8653+test("Sheet EXPONDIST", function(){
8654+  assertFormulaEquals('=EXPONDIST(4, 0.5, false)', 0.06766764161830635);
8655+});
8656 
8657-// Test EXACT
8658-testFormula('=EXACT("m", "M")', false);
8659+test("Sheet FALSE", function(){
8660+  assertFormulaEquals('=FALSE()', false);
8661+});
8662 
8663-// Test EXPONDIST
8664-testFormula('=EXPONDIST(4, 0.5, false)', 0.06766764161830635);
8665-
8666-// Test FALSE
8667-testFormula('=FALSE()', false);
8668-
8669-// Test F.DIST
8670-
8671-testFormula('=F.DIST(15.35, 7, 6, false)', 0.0003451054686025578);
8672-testFormula('=F.DIST(15.35, 7, 6, true)', 0.9980694465675269);
8673+test("Sheet F.DIST", function(){
8674+  assertFormulaEquals('=F.DIST(15.35, 7, 6, false)', 0.0003451054686025578);
8675+  assertFormulaEquals('=F.DIST(15.35, 7, 6, true)', 0.9980694465675269);
8676+});
8677 
8678 // Test FDIST
8679-// TODO: This should work.
8680+// TODO: Test FDIST
8681 /*
8682  * F.DIST Calculates the left-tailed F probability distribution (degree of diversity) for two data sets with given input x. Alternately called Fisher-Snedecor distribution or Snedecor's F distribution.
8683  * FDIST Calculates the right-tailed F probability distribution (degree of diversity) for two data sets with given input x. Alternately called Fisher-Snedecor distribution or Snedecor's F distribution.
8684@@ -211,11 +261,12 @@ testFormula('=F.DIST(15.35, 7, 6, true)', 0.9980694465675269);
8685  * F.DIST is left-tailed. FDIST is right-tailed.
8686  */
8687 
8688-// Test FINV
8689-testFormula('=FINV(0.42, 2, 3)', 1.174597274485816);
8690+test("Sheet FINV", function(){
8691+  assertFormulaEquals('=FINV(0.42, 2, 3)', 1.174597274485816);
8692+});
8693 
8694 // Test F.INV
8695-// TODO: This should work.
8696+// TODO: Test F.INV
8697 /*
8698  * FINV Calculates the inverse of the right-tailed F probability distribution. Also called the Fisher-Snedecor distribution or Snedecor’s F distribution.
8699  * F.INV Calculates the inverse of the left-tailed F probability distribution. Also called the Fisher-Snedecor distribution or Snedecor’s F distribution.
8700@@ -223,138 +274,165 @@ testFormula('=FINV(0.42, 2, 3)', 1.174597274485816);
8701  * F.INV is left-tailed. FINV is right-tailed.
8702  */
8703 
8704-// Test FISHER
8705-testFormula('=FISHER(0.962)', 1.972066740199461);
8706-
8707-// Test FISHERINV
8708-testFormula('=FISHERINV(0.962)', 0.7451676440945232);
8709-
8710-// Test IF
8711-testFormula('=IF("m" = "m", "hit", "miss")', 'hit');
8712-
8713-// Test INT
8714-testFormula('=INT(99.33)', 99);
8715-
8716-// Test ISEVEN
8717-testFormula('=ISEVEN(4)', true);
8718-
8719-// Test ISODD
8720-testFormula('=ISODD(3)', true);
8721-
8722-// Test LN
8723-testFormula('=LN(100)', 4.605170185988092);
8724-
8725-// Test LOG
8726-testFormula('=LOG(256, 2)', 8);
8727-
8728-// Test LOG10
8729-testFormula('=LOG10(100)', 2);
8730-
8731-// Test MAX
8732-testFormula('=MAX(100, 22)', 100);
8733-
8734-// Test MAXA
8735-testFormula('=MAXA(100, 22, 44)', 100);
8736-
8737-// Test MEDIAN
8738-testFormula('=MEDIAN(100, 22, 54)', 54);
8739-
8740-// Test MIN
8741-testFormula('=MIN(100, 22, 44)', 22);
8742+test("Sheet FISHER", function(){
8743+  assertFormulaEquals('=FISHER(0.962)', 1.972066740199461);
8744+});
8745 
8746-// Test MINA
8747-testFormula('=MINA(100, 22, 44)', 22);
8748+test("Sheet FISHERINV", function(){
8749+  assertFormulaEquals('=FISHERINV(0.962)', 0.7451676440945232);
8750+});
8751 
8752-// Test MOD
8753-testFormula('=MOD(10, 3)', 1);
8754+test("Sheet IF", function(){
8755+  assertFormulaEquals('=IF("m" = "m", "hit", "miss")', 'hit');
8756+});
8757 
8758-// Test NOT
8759-testFormula('=NOT(TRUE())', false);
8760+test("Sheet INT", function(){
8761+  assertFormulaEquals('=INT(99.33)', 99);
8762+});
8763 
8764-// Test ODD
8765-testFormula('=ODD(2)', 3);
8766+test("Sheet ISEVEN", function(){
8767+  assertFormulaEquals('=ISEVEN(4)', true);
8768+});
8769 
8770-// Test OR
8771-testFormula('=OR("m" = "p", "n" = "n")', true);
8772+test("Sheet ISODD", function(){
8773+  assertFormulaEquals('=ISODD(3)', true);
8774 
8775-// Test PI()
8776-testFormula('=PI()', 3.141592653589793);
8777+});
8778 
8779-// Test POWER
8780-testFormula('=POWER(4, 10)', 1048576);
8781+test("Sheet LN", function(){
8782+  assertFormulaEquals('=LN(100)', 4.605170185988092);
8783+});
8784 
8785-// Test ROUND
8786-testFormula('=ROUND(99.44, 1)', 99.4);
8787+test("Sheet LOG", function(){
8788+  assertFormulaEquals('=LOG(256, 2)', 8);
8789+});
8790 
8791-// Test ROUNDDOWN
8792-testFormula('=ROUNDDOWN(99.46, 1)', 99.4);
8793+test("Sheet LOG10", function(){
8794+  assertFormulaEquals('=LOG10(100)', 2);
8795+});
8796 
8797-// Test ROUNDUP
8798-testFormula('=ROUNDUP(99.46, 1)', 99.5);
8799+test("Sheet MAX", function(){
8800+  assertFormulaEquals('=MAX(100, 22)', 100);
8801+});
8802 
8803-// Test SIN
8804-testFormula('=SIN(0)', 0);
8805-testFormula('=SIN(1)', 0.8414709848078965);
8806-testFormula('=SIN(PI() / 2)', 1);
8807-testFormula('=SIN(PI())', 0);
8808+test("Sheet MAXA", function(){
8809+  assertFormulaEquals('=MAXA(100, 22, 44)', 100);
8810+});
8811 
8812+test("Sheet MEDIAN", function(){
8813+  assertFormulaEquals('=MEDIAN(100, 22, 54)', 54);
8814+});
8815 
8816-// Test SINH
8817-testFormula('=SINH(PI())', 11.548739357257748);
8818+test("Sheet MIN", function(){
8819+  assertFormulaEquals('=MIN(100, 22, 44)', 22);
8820+});
8821 
8822-// Test SPLIT
8823-testFormulaToArray('=SPLIT("1,2,3", ",", TRUE)', [ '1', '2', '3' ]);
8824+test("Sheet MINA", function(){
8825+  assertFormulaEquals('=MINA(100, 22, 44)', 22);
8826+});
8827 
8828-// Test SQRT
8829-testFormula('=SQRT(9)', 3);
8830+test("Sheet MOD", function(){
8831+  assertFormulaEquals('=MOD(10, 3)', 1);
8832+});
8833 
8834-// Test SQRTPI
8835-testFormula('=SQRTPI(9)', 5.317361552716548);
8836+test("Sheet NOT", function(){
8837+  assertFormulaEquals('=NOT(TRUE())', false);
8838+});
8839 
8840-// Test SUM
8841-testFormula('=SUM(10, 10)', 20);
8842+test("Sheet ODD", function(){
8843+  assertFormulaEquals('=ODD(2)', 3);
8844+});
8845 
8846-// Test SUMIF
8847-testFormula('=SUMIF([1, 5, 10], 5)', 5);
8848+test("Sheet OR", function(){
8849+  assertFormulaEquals('=OR("m" = "p", "n" = "n")', true);
8850+});
8851 
8852-// Test SUMPRODUCT
8853-testFormula('=SUMPRODUCT([1, 5, 10], [2, 2, 2])', 32);
8854+test("Sheet PI", function(){
8855+  assertFormulaEquals('=PI()', 3.141592653589793);
8856+});
8857 
8858-// Test SUMSQ
8859-testFormula('=SUMSQ([1, 5, 10], 10)', 226);
8860+test("Sheet POWER", function(){
8861+  assertFormulaEquals('=POWER(4, 10)', 1048576);
8862+});
8863 
8864-// Test SUMX2MY2
8865-testFormula('=SUMX2MY2([1,2,3],[4,5,6])', -63);
8866+test("Sheet ROUND", function(){
8867+  assertFormulaEquals('=ROUND(99.44, 1)', 99.4);
8868+});
8869 
8870-// Test SUMX2PY2
8871-testFormula('=SUMX2PY2([1, 2, 3], [4, 5, 6])', 91);
8872+test("Sheet ROUNDDOWN", function(){
8873+  assertFormulaEquals('=ROUNDDOWN(99.46, 1)', 99.4);
8874+});
8875 
8876-// Test SUMXMY2
8877-// TODO: This should work.
8878-// testFormula('=SUMXMY2([1,2,3],[4,5,6])', 27);
8879+test("Sheet ROUNDUP", function(){
8880+  assertFormulaEquals('=ROUNDUP(99.46, 1)', 99.5);
8881+});
8882 
8883-// Test TAN
8884-testFormula('=TAN(0)', 0);
8885-testFormula('=TAN(1)', 1.5574077246549023);
8886-testFormula('=TAN(PI() / 2)', 16331239353195370);
8887-testFormula('=TAN(PI())', 0);
8888+test("Sheet SIN", function(){
8889+  assertFormulaEquals('=SIN(0)', 0);
8890+  assertFormulaEquals('=SIN(1)', 0.8414709848078965);
8891+  assertFormulaEquals('=SIN(PI() / 2)', 1);
8892+  assertFormulaEquals('=SIN(PI())', 0);
8893+});
8894 
8895-// Test TANH
8896-testFormula('=TANH(PI())', 0.9962720762207501);
8897+test("Sheet SINH", function(){
8898+  assertFormulaEquals('=SINH(PI())', 11.548739357257748);
8899+});
8900 
8901-// Test TRUE
8902-testFormula('=TRUE()', true);
8903+test("Sheet SPLIT", function(){
8904+  testFormulaToArray('=SPLIT("1,2,3", ",", TRUE)', [ '1', '2', '3' ]);
8905+});
8906 
8907-// Test TRUE
8908-testFormula('=TRUNC(3.1415, 2)', 3.14);
8909+test("Sheet SQRT", function(){
8910+  assertFormulaEquals('=SQRT(9)', 3);
8911+});
8912 
8913-// Test XOR
8914-testFormula('=XOR(1, 1)', false);
8915+test("Sheet SQRTPI", function(){
8916+  assertFormulaEquals('=SQRTPI(9)', 5.317361552716548);
8917+});
8918 
8919-// Test YEARFRAC
8920-// testFormula('=YEARFRAC(DATE(1969, 7, 6), DATE(1988, 7, 4), 0)', 18.994444444444444);
8921-// // testFormula('=YEARFRAC(DATE(1969, 7, 6), DATE(1988, 7, 4), 1)', 18.99587544); // This is slightly off
8922-// testFormula('=YEARFRAC(DATE(1969, 7, 6), DATE(1988, 7, 4), 2)', 19.272222222222222);
8923-// testFormula('=YEARFRAC(DATE(1969, 7, 6), DATE(1988, 7, 4), 3)', 19.008219178082193);
8924-// testFormula('=YEARFRAC(DATE(1969, 7, 6), DATE(1988, 7, 4), 4)', 18.994444444444444);
8925+test("Sheet SUM", function(){
8926+  assertFormulaEquals('=SUM(10, 10)', 20);
8927+});
8928 
8929+test("Sheet SUMIF", function(){
8930+  assertFormulaEquals('=SUMIF([1, 5, 10], 5)', 5);
8931+});
8932+
8933+test("Sheet SUMPRODUCT", function(){
8934+  assertFormulaEquals('=SUMPRODUCT([1, 5, 10], [2, 2, 2])', 32);
8935+});
8936+
8937+test("Sheet SUMSQ", function(){
8938+  assertFormulaEquals('=SUMSQ([1, 5, 10], 10)', 226);
8939+});
8940+
8941+test("Sheet SUMX2MY2", function(){
8942+  assertFormulaEquals('=SUMX2MY2([1,2,3],[4,5,6])', -63);
8943+});
8944+
8945+test("Sheet SUMX2PY2", function(){
8946+  assertFormulaEquals('=SUMX2PY2([1, 2, 3], [4, 5, 6])', 91);
8947+});
8948+
8949+test("Sheet TAN", function(){
8950+  assertFormulaEquals('=TAN(0)', 0);
8951+  assertFormulaEquals('=TAN(1)', 1.5574077246549023);
8952+  assertFormulaEquals('=TAN(PI() / 2)', 16331239353195370);
8953+  assertFormulaEquals('=TAN(PI())', 0);
8954+});
8955+
8956+test("Sheet TANH", function(){
8957+  assertFormulaEquals('=TANH(PI())', 0.9962720762207501);
8958+});
8959+
8960+test("Sheet TRUE", function(){
8961+  assertFormulaEquals('=TRUE()', true);
8962+});
8963+
8964+test("Sheet TRUNC", function(){
8965+  assertFormulaEquals('=TRUNC(3.1415, 2)', 3.14);
8966+});
8967+
8968+test("Sheet XOR", function(){
8969+  assertFormulaEquals('=XOR(1, 1)', false);
8970+});
8971diff --git a/tests/SheetParseTest.ts b/tests/SheetParseTest.ts
8972index e2d7f4a..272fd8b 100644
8973--- a/tests/SheetParseTest.ts
8974+++ b/tests/SheetParseTest.ts
8975@@ -1,13 +1,21 @@
8976-import { Sheet } from "../src/Sheet"
8977-import { assertEquals } from "./utils/Asserts"
8978-
8979-// Test parsing math formulas
8980-var sheet  = new Sheet();
8981-sheet.setCell("A1", "=10 * 10");
8982-var cell = sheet.getCell("A1");
8983-assertEquals(100, cell.getValue());
8984-
8985-var sheet  = new Sheet();
8986-sheet.setCell("A1", "=SUM(10) + 12");
8987-var cell = sheet.getCell("A1");
8988-assertEquals(22, cell.getValue());
8989+import {
8990+  Sheet
8991+} from "../src/Sheet";
8992+import {
8993+  assertEquals,
8994+  test
8995+} from "./utils/Asserts";
8996+
8997+
8998+test("Sheet parsing math formulas", function(){
8999+  var sheet  = new Sheet();
9000+  sheet.setCell("A1", "=10 * 10");
9001+  var cell = sheet.getCell("A1");
9002+  assertEquals(100, cell.getValue());
9003+
9004+  var sheet  = new Sheet();
9005+  sheet.setCell("A1", "=SUM(10) + 12");
9006+  var cell = sheet.getCell("A1");
9007+  assertEquals(22, cell.getValue());
9008+});
9009+
9010diff --git a/tests/SheetTest.ts b/tests/SheetTest.ts
9011index 940d225..7df93e2 100644
9012--- a/tests/SheetTest.ts
9013+++ b/tests/SheetTest.ts
9014@@ -1,147 +1,164 @@
9015-import { Sheet } from "../src/Sheet"
9016-import {assertEquals, assertArrayEquals} from "./utils/Asserts"
9017-import { Errors } from "../src/Errors"
9018+import {
9019+  Sheet
9020+} from "../src/Sheet";
9021+import {
9022+  assertEquals,
9023+  assertArrayEquals,
9024+  test
9025+} from "./utils/Asserts";
9026+import {
9027+  Errors
9028+} from "../src/Errors";
9029 
9030-// Test setCell, getCell, valid
9031-var sheet = new Sheet();
9032-sheet.setCell("A2", "22");
9033-var cell = sheet.getCell("A2");
9034-assertEquals(null, cell.getFormula());
9035-assertEquals("22", cell.getValue());
9036-assertEquals("A2", cell.getId());
9037-assertEquals(1, cell.getRow());
9038-assertEquals(0, cell.getColumn());
9039-assertEquals(null, cell.getError());
9040-assertArrayEquals([], cell.getDependencies());
9041+test("Sheet.setCell, Sheet.getCell", function(){
9042+  // Test setCell, getCell, valid
9043+  var sheet = new Sheet();
9044+  sheet.setCell("A2", "22");
9045+  var cell = sheet.getCell("A2");
9046+  assertEquals(null, cell.getFormula());
9047+  assertEquals("22", cell.getValue());
9048+  assertEquals("A2", cell.getId());
9049+  assertEquals(1, cell.getRow());
9050+  assertEquals(0, cell.getColumn());
9051+  assertEquals(null, cell.getError());
9052+  assertArrayEquals([], cell.getDependencies());
9053 
9054-// Test getCell, null value
9055-var nullCell = sheet.getCell("N1");
9056-assertEquals(null, nullCell);
9057+  // Test getCell, null value
9058+  var nullCell = sheet.getCell("N1");
9059+  assertEquals(null, nullCell);
9060 
9061-// Test setCell, with formula
9062-var sheet = new Sheet();
9063-var SUM_FORM = "=SUM(A1:A4)";
9064-sheet.setCell("A1", "1");
9065-sheet.setCell("A2", "20");
9066-sheet.setCell("A3", "3.4");
9067-sheet.setCell("A4", "45");
9068-sheet.setCell("A5", "=SUM(A1:A4)");
9069-var A5 = sheet.getCell("A5");
9070-assertEquals(69.4, A5.getValue());
9071-assertEquals(SUM_FORM.substr(1), A5.getFormula());
9072-assertEquals(null, cell.getError());
9073-assertArrayEquals(['A1', 'A2', 'A3', 'A4'], A5.getDependencies());
9074+  // Test setCell, with formula
9075+  var sheet = new Sheet();
9076+  var SUM_FORM = "=SUM(A1:A4)";
9077+  sheet.setCell("A1", "1");
9078+  sheet.setCell("A2", "20");
9079+  sheet.setCell("A3", "3.4");
9080+  sheet.setCell("A4", "45");
9081+  sheet.setCell("A5", "=SUM(A1:A4)");
9082+  var A5 = sheet.getCell("A5");
9083+  assertEquals(69.4, A5.getValue());
9084+  assertEquals(SUM_FORM.substr(1), A5.getFormula());
9085+  assertEquals(null, cell.getError());
9086+  assertArrayEquals(['A1', 'A2', 'A3', 'A4'], A5.getDependencies());
9087+});
9088 
9089+test("Sheet.load", function(){
9090+  var sheet = new Sheet();
9091+  var SUM_FORMULA = "=SUM(A1:D1, H1)";
9092+  var MAX_FORMULA = "=MAX(A2:J2)";
9093+  var MIN_FORMULA = "=MIN(A3:J3)";
9094+  var AVERAGE_FORMULA = "=AVERAGE(A4:J4)";
9095+  var SUM_IF_FORMULA = "=SUMIF(A5:J5,5)";
9096+  var SUM_REF_FORMULA = "=SUM(K1, K2, K3, K4)";
9097+  sheet.load([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, SUM_FORMULA],
9098+    [-1, -10, 2, 4, 100, 1, 50, 20, 200, -100, MAX_FORMULA],
9099+    [-1, -40, -53, 1, 10, 30, 10, 301, -1, -20, MIN_FORMULA],
9100+    [20, 50, 100, 20, 1, 5, 15, 25, 45, 23, AVERAGE_FORMULA],
9101+    [0, 10, 1, 10, 2, 10, 3, 10, 4, 10, SUM_IF_FORMULA],
9102+    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SUM_REF_FORMULA]]);
9103+  var K1 = sheet.getCell("K1");
9104+  assertEquals(18, K1.getValue());
9105+  assertEquals(SUM_FORMULA.substr(1), K1.getFormula());
9106+  assertEquals(null, K1.getError());
9107+  assertArrayEquals(['A1', 'B1', 'C1', 'D1', 'H1'], K1.getDependencies());
9108+  var K2 = sheet.getCell("K2");
9109+  assertEquals(200, K2.getValue());
9110+  assertEquals(MAX_FORMULA.substr(1), K2.getFormula());
9111+  assertEquals(null, K2.getError());
9112+  assertArrayEquals(['A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2', 'H2', 'I2', 'J2'], K2.getDependencies());
9113+  var K3 = sheet.getCell("K3");
9114+  assertEquals(-53, K3.getValue());
9115+  assertEquals(MIN_FORMULA.substr(1), K3.getFormula());
9116+  assertEquals(null, K3.getError());
9117+  assertArrayEquals(['A3', 'B3', 'C3', 'D3', 'E3', 'F3', 'G3', 'H3', 'I3', 'J3'], K3.getDependencies());
9118+  var K4 = sheet.getCell("K4");
9119+  assertEquals(30.4, K4.getValue());
9120+  assertEquals(AVERAGE_FORMULA.substr(1), K4.getFormula());
9121+  assertEquals(null, K4.getError());
9122+  assertArrayEquals(['A4', 'B4', 'C4', 'D4', 'E4', 'F4', 'G4', 'H4', 'I4', 'J4'], K4.getDependencies());
9123+  var K5 = sheet.getCell("K5");
9124+  assertEquals(0, K5.getValue());
9125+  assertEquals(SUM_IF_FORMULA.substr(1), K5.getFormula());
9126+  assertEquals(null, K5.getError());
9127+  assertArrayEquals(['A5', 'B5', 'C5', 'D5', 'E5', 'F5', 'G5', 'H5', 'I5', 'J5'], K5.getDependencies());
9128+  var K6 = sheet.getCell("K6");
9129+  assertEquals(195.4, K6.getValue());
9130+  assertEquals(SUM_REF_FORMULA.substr(1), K6.getFormula());
9131+  assertEquals(null, K6.getError());
9132+  assertArrayEquals(['K1', 'K2', 'K3', 'K4'], K6.getDependencies());
9133+});
9134 
9135-// Test load
9136-var sheet = new Sheet();
9137-var SUM_FORMULA = "=SUM(A1:D1, H1)";
9138-var MAX_FORMULA = "=MAX(A2:J2)";
9139-var MIN_FORMULA = "=MIN(A3:J3)";
9140-var AVERAGE_FORMULA = "=AVERAGE(A4:J4)";
9141-var SUM_IF_FORMULA = "=SUMIF(A5:J5,5)";
9142-var SUM_REF_FORMULA = "=SUM(K1, K2, K3, K4)";
9143-sheet.load([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, SUM_FORMULA],
9144-  [-1, -10, 2, 4, 100, 1, 50, 20, 200, -100, MAX_FORMULA],
9145-  [-1, -40, -53, 1, 10, 30, 10, 301, -1, -20, MIN_FORMULA],
9146-  [20, 50, 100, 20, 1, 5, 15, 25, 45, 23, AVERAGE_FORMULA],
9147-  [0, 10, 1, 10, 2, 10, 3, 10, 4, 10, SUM_IF_FORMULA],
9148-  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SUM_REF_FORMULA]]);
9149-var K1 = sheet.getCell("K1");
9150-assertEquals(18, K1.getValue());
9151-assertEquals(SUM_FORMULA.substr(1), K1.getFormula());
9152-assertEquals(null, K1.getError());
9153-assertArrayEquals(['A1', 'B1', 'C1', 'D1', 'H1'], K1.getDependencies());
9154-var K2 = sheet.getCell("K2");
9155-assertEquals(200, K2.getValue());
9156-assertEquals(MAX_FORMULA.substr(1), K2.getFormula());
9157-assertEquals(null, K2.getError());
9158-assertArrayEquals(['A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2', 'H2', 'I2', 'J2'], K2.getDependencies());
9159-var K3 = sheet.getCell("K3");
9160-assertEquals(-53, K3.getValue());
9161-assertEquals(MIN_FORMULA.substr(1), K3.getFormula());
9162-assertEquals(null, K3.getError());
9163-assertArrayEquals(['A3', 'B3', 'C3', 'D3', 'E3', 'F3', 'G3', 'H3', 'I3', 'J3'], K3.getDependencies());
9164-var K4 = sheet.getCell("K4");
9165-assertEquals(30.4, K4.getValue());
9166-assertEquals(AVERAGE_FORMULA.substr(1), K4.getFormula());
9167-assertEquals(null, K4.getError());
9168-assertArrayEquals(['A4', 'B4', 'C4', 'D4', 'E4', 'F4', 'G4', 'H4', 'I4', 'J4'], K4.getDependencies());
9169-var K5 = sheet.getCell("K5");
9170-assertEquals(0, K5.getValue());
9171-assertEquals(SUM_IF_FORMULA.substr(1), K5.getFormula());
9172-assertEquals(null, K5.getError());
9173-assertArrayEquals(['A5', 'B5', 'C5', 'D5', 'E5', 'F5', 'G5', 'H5', 'I5', 'J5'], K5.getDependencies());
9174-var K6 = sheet.getCell("K6");
9175-assertEquals(195.4, K6.getValue());
9176-assertEquals(SUM_REF_FORMULA.substr(1), K6.getFormula());
9177-assertEquals(null, K6.getError());
9178-assertArrayEquals(['K1', 'K2', 'K3', 'K4'], K6.getDependencies());
9179+test("Sheet REF error", function(){
9180+  var sheet  = new Sheet();
9181+  sheet.setCell("A1", "200");
9182+  sheet.setCell("A2", "200");
9183+  sheet.setCell("A3", "=SUM(A1, A2)");
9184+  sheet.setCell("B1", "=SUM(A3, B2)");
9185+  sheet.setCell("B2", "=SUM(A1, B1)");
9186+  var B1 = sheet.getCell("B1");
9187+  assertEquals(null, B1.getValue());
9188+  assertEquals(Errors.get("REF"), B1.getError());
9189+  assertArrayEquals(['A3', 'B2'], B1.getDependencies());
9190+  var B2 = sheet.getCell("B2");
9191+  assertEquals(null, B2.getValue());
9192+  assertEquals(Errors.get("REF"), B2.getError());
9193+  assertArrayEquals(['A1', 'B1'], B2.getDependencies());
9194+});
9195 
9196-//Test REF error
9197-var sheet  = new Sheet();
9198-sheet.setCell("A1", "200");
9199-sheet.setCell("A2", "200");
9200-sheet.setCell("A3", "=SUM(A1, A2)");
9201-sheet.setCell("B1", "=SUM(A3, B2)");
9202-sheet.setCell("B2", "=SUM(A1, B1)");
9203-var B1 = sheet.getCell("B1");
9204-assertEquals(null, B1.getValue());
9205-assertEquals(Errors.get("REF"), B1.getError());
9206-assertArrayEquals(['A3', 'B2'], B1.getDependencies());
9207-var B2 = sheet.getCell("B2");
9208-assertEquals(null, B2.getValue());
9209-assertEquals(Errors.get("REF"), B2.getError());
9210-assertArrayEquals(['A1', 'B1'], B2.getDependencies());
9211+test("Sheet cell NAME error", function(){
9212+  var sheet  = new Sheet();
9213+  sheet.setCell("A1", "1");
9214+  sheet.setCell("A2", "=SUM(A1, NN)");
9215+  var A2 = sheet.getCell("A2");
9216+  assertEquals(null, A2.getValue());
9217+  assertEquals(Errors.get("NAME"), A2.getError());
9218+  assertArrayEquals(['A1'], A2.getDependencies());
9219+});
9220 
9221-// Test NAME error
9222-var sheet  = new Sheet();
9223-sheet.setCell("A1", "1");
9224-sheet.setCell("A2", "=SUM(A1, NN)");
9225-var A2 = sheet.getCell("A2");
9226-assertEquals(null, A2.getValue());
9227-assertEquals(Errors.get("NAME"), A2.getError());
9228-assertArrayEquals(['A1'], A2.getDependencies());
9229-
9230-// Test unsupported formula
9231-var sheet  = new Sheet();
9232-sheet.setCell("A1", "1");
9233-sheet.setCell("A2", "=BEN(A1)");
9234-var A2 = sheet.getCell("A2");
9235-assertEquals(null, A2.getValue());
9236-assertEquals(Errors.get("NAME"), A2.getError());
9237-assertArrayEquals(['A1'], A2.getDependencies());
9238+test("Sheet unsupported formula NAME error", function(){
9239+  var sheet  = new Sheet();
9240+  sheet.setCell("A1", "1");
9241+  sheet.setCell("A2", "=BEN(A1)");
9242+  var A2 = sheet.getCell("A2");
9243+  assertEquals(null, A2.getValue());
9244+  assertEquals(Errors.get("NAME"), A2.getError());
9245+  assertArrayEquals(['A1'], A2.getDependencies());
9246+});
9247 
9248+test("Sheet nested formulas", function(){
9249 // Test nested formulas
9250-var sheet  = new Sheet();
9251-sheet.setCell("A1", "1");
9252-sheet.setCell("A2", "10");
9253-sheet.setCell("A3", "44.4");
9254-sheet.setCell("A4", "=SUM(A1:A3, MAX(A1, A3))");
9255-var A4 = sheet.getCell("A4");
9256-assertEquals(99.8, A4.getValue());
9257-assertEquals("SUM(A1:A3, MAX(A1, A3))", A4.getFormula());
9258-assertEquals(null, A4.getError());
9259-assertArrayEquals(['A1', 'A2', 'A3'], A4.getDependencies());
9260+  var sheet  = new Sheet();
9261+  sheet.setCell("A1", "1");
9262+  sheet.setCell("A2", "10");
9263+  sheet.setCell("A3", "44.4");
9264+  sheet.setCell("A4", "=SUM(A1:A3, MAX(A1, A3))");
9265+  var A4 = sheet.getCell("A4");
9266+  assertEquals(99.8, A4.getValue());
9267+  assertEquals("SUM(A1:A3, MAX(A1, A3))", A4.getFormula());
9268+  assertEquals(null, A4.getError());
9269+  assertArrayEquals(['A1', 'A2', 'A3'], A4.getDependencies());
9270+});
9271 
9272-// Test dependency calculation propagation
9273-var sheet  = new Sheet();
9274-sheet.setCell("A1", "1");
9275-sheet.setCell("A2", "=SUM(A1, 100)");
9276-var A2 = sheet.getCell("A2");
9277-assertEquals(101, A2.getValue());
9278-assertArrayEquals(['A1'], A2.getDependencies());
9279-sheet.setCell("A1", "2");
9280-assertEquals(102, A2.getValue());
9281-assertArrayEquals(['A1'], A2.getDependencies());
9282+test("Sheet dependency calculation propagation", function(){
9283+  var sheet  = new Sheet();
9284+  sheet.setCell("A1", "1");
9285+  sheet.setCell("A2", "=SUM(A1, 100)");
9286+  var A2 = sheet.getCell("A2");
9287+  assertEquals(101, A2.getValue());
9288+  assertArrayEquals(['A1'], A2.getDependencies());
9289+  sheet.setCell("A1", "2");
9290+  assertEquals(102, A2.getValue());
9291+  assertArrayEquals(['A1'], A2.getDependencies());
9292+});
9293 
9294-// Test cell formula update
9295-var sheet  = new Sheet();
9296-sheet.setCell("A1", "1");
9297-sheet.setCell("A2", "=SUM(A1, 100)");
9298-var A2 = sheet.getCell("A2");
9299-assertEquals(101, A2.getValue());
9300-assertArrayEquals(['A1'], A2.getDependencies());
9301-sheet.setCell("A2", "=MAX(A1, 100)");
9302-assertEquals(100, A2.getValue());
9303-assertArrayEquals(['A1'], A2.getDependencies());
9304\ No newline at end of file
9305+test("Sheet cell formula update", function(){
9306+  var sheet  = new Sheet();
9307+  sheet.setCell("A1", "1");
9308+  sheet.setCell("A2", "=SUM(A1, 100)");
9309+  var A2 = sheet.getCell("A2");
9310+  assertEquals(101, A2.getValue());
9311+  assertArrayEquals(['A1'], A2.getDependencies());
9312+  sheet.setCell("A2", "=MAX(A1, 100)");
9313+  assertEquals(100, A2.getValue());
9314+  assertArrayEquals(['A1'], A2.getDependencies());
9315+});
9316diff --git a/tests/utils/Asserts.ts b/tests/utils/Asserts.ts
9317index ffbdded..65e96be 100644
9318--- a/tests/utils/Asserts.ts
9319+++ b/tests/utils/Asserts.ts
9320@@ -60,8 +60,15 @@ function catchAndAssertEquals(toExecute : Function, expected) {
9321   }
9322 }
9323 
9324+function test(description: string, toRun: Function) {
9325+  console.log("Test:", description);
9326+  toRun();
9327+}
9328+
9329+
9330 export {
9331   assertEquals,
9332   assertArrayEquals,
9333-  catchAndAssertEquals
9334+  catchAndAssertEquals,
9335+  test
9336 }
9337\ No newline at end of file