spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[SheetFormulaTest] ensuring all formulas have parsing tests
author
Ben Vogt <[email protected]>
date
2017-05-19 00:00:06
stats
2 file(s) changed, 103 insertions(+), 13 deletions(-)
files
README.md
tests/SheetFormulaTest.ts
  1diff --git a/README.md b/README.md
  2index 6588f88..d64ec50 100644
  3--- a/README.md
  4+++ b/README.md
  5@@ -14,9 +14,6 @@ Things I should do.
  6 ### COUNT and COUNTA should be different.
  7 
  8 
  9-### All formulas should used TypeConverter to pull parameters from `values`
 10-
 11-
 12 ### Cells should have `formatAs` fields.
 13 Instead of having non-primitives, (i.e. Date, DateTime, Time, Dollar), cells should have formats based on the
 14 highest-order type that was used during the compilation and execution of a cell's dependency. For example, `DATE` might
 15@@ -35,17 +32,9 @@ Contingent upon cells having formats or types for primitives.
 16 ### Verify that all N-times ({2,9}) are correct, and we're not parsing numbers too big inside Date formulas.
 17 
 18 
 19-### Sheet.ts and Helpers.ts should be check conversion capabilities in same way as TypeConverter
 20-When we check to see if a value taken from a cell is of a certain type, we should check in the same way as the
 21-TypeConverter.
 22-
 23-
 24 ### Scrape jsdocs for functions, put in simple index.html, doc.md files to serve up simple documentation
 25 
 26 
 27-### Ensure all formulas are tested inside of SheetFormulaTest.ts
 28-
 29-
 30 ### Pull static functions outside of formulas, declare once.
 31 
 32 
 33diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
 34index 60a38a6..ef42e40 100644
 35--- a/tests/SheetFormulaTest.ts
 36+++ b/tests/SheetFormulaTest.ts
 37@@ -43,6 +43,12 @@ test("Sheet ACOS", function(){
 38   assertFormulaEquals("=ACOS(0)", 1.5707963267948966);
 39 });
 40 
 41+test("Sheet ACCRINT", function(){
 42+  assertFormulaEquals("=ACCRINT(DATE(2000, 1, 1), DATE(2000, 2, 1), DATE(2002, 12, 31), 0.05, 100, 4)",
 43+    14.98631386861314);
 44+});
 45+
 46+
 47 test("Sheet ACOSH", function(){
 48   assertFormulaEquals("=ACOSH(22)", 3.783672704329451);
 49 });
 50@@ -180,6 +186,26 @@ test("Sheet COMPRINC", function(){
 51   assertFormulaEquals("=CUMPRINC(0.12, 12, 100, 1, 5, 0)", -26.324171373034403);
 52 });
 53 
 54+test("Sheet DATE", function(){
 55+  assertFormulaEquals("=DATE(2017, 6, 24)", 42910);
 56+});
 57+
 58+test("Sheet DATEVALUE", function(){
 59+  assertFormulaEquals("=DATEVALUE('2017/6/24')", 42910);
 60+});
 61+
 62+test("Sheet DAY", function(){
 63+  assertFormulaEquals("=DAY(DATE(1992, 6, 24))", 24);
 64+});
 65+
 66+test("Sheet DAYS", function(){
 67+  assertFormulaEquals("=DAYS(DATE(1992, 6, 24), DATE(1991, 6, 24))", 366);
 68+});
 69+
 70+test("Sheet DAYS360", function(){
 71+  assertFormulaEquals("=DAYS360(DATE(1992, 6, 24), DATE(1991, 6, 24))", -360);
 72+});
 73+
 74 test("Sheet DB", function(){
 75   assertFormulaEquals("=DB(100, 50, 10, 2, 12)", 6.2482428240683285);
 76 });
 77@@ -228,6 +254,14 @@ test("Sheet AND", function(){
 78   assertFormulaEquals('=AND(10)', true);
 79 });
 80 
 81+test("Sheet EDATE", function(){
 82+  assertFormulaEquals('=EDATE(DATE(1992, 6, 24), 1)', 33809);
 83+});
 84+
 85+test("Sheet EOMONTH", function(){
 86+  assertFormulaEquals('=EOMONTH(DATE(1992, 6, 24), 0)', 33785);
 87+});
 88+
 89 test("Sheet EFFECT", function(){
 90   assertFormulaEquals('=EFFECT(0.99, 12)', 1.5890167507927795);
 91 });
 92@@ -287,7 +321,6 @@ test("Sheet ISEVEN", function(){
 93 
 94 test("Sheet ISODD", function(){
 95   assertFormulaEquals('=ISODD(3)', true);
 96-
 97 });
 98 
 99 test("Sheet LN", function(){
100@@ -326,6 +359,10 @@ test("Sheet MOD", function(){
101   assertFormulaEquals('=MOD(10, 3)', 1);
102 });
103 
104+test("Sheet TRUE", function(){
105+  assertFormulaEquals('=TRUE()', true);
106+});
107+
108 test("Sheet NOT", function(){
109   assertFormulaEquals('=NOT(TRUE())', false);
110 });
111@@ -428,6 +465,70 @@ test("Sheet XOR", function(){
112   assertFormulaEquals('=XOR(1, 1)', false);
113 });
114 
115+test("Sheet YEARFRAC", function(){
116+  assertFormulaEquals('=YEARFRAC(1, 1461, 2)', 4.055555555555555);
117+});
118+
119+test("Sheet RADIANS", function(){
120+  assertFormulaEquals('=RADIANS(180)', 3.141592653589793);
121+});
122+
123+test("Sheet MONTH", function(){
124+  assertFormulaEquals('=MONTH(DATE(1992, 6, 24))', 6);
125+});
126+
127+test("Sheet YEAR", function(){
128+  assertFormulaEquals('=YEAR(DATE(1992, 6, 24))', 1992);
129+});
130+
131+test("Sheet WEEKDAY", function(){
132+  assertFormulaEquals('=WEEKDAY(DATE(1992, 6, 20))', 7);
133+});
134+
135+test("Sheet WEEKNUM", function(){
136+  assertFormulaEquals('=WEEKNUM(DATE(1992, 6, 19))', 25);
137+});
138+
139+test("Sheet DATEDIF", function(){
140+  assertFormulaEquals('=DATEDIF("1992-6-19", "1996-6-19", "Y")', 4);
141+});
142+
143+test("Sheet TIMEVALUE", function(){
144+  assertFormulaEquals('=TIMEVALUE("8:10")', 0.3402777777777778);
145+});
146+
147+test("Sheet HOUR", function(){
148+  assertFormulaEquals('=HOUR("8:10")', 8);
149+});
150+
151+test("Sheet MINUTE", function(){
152+  assertFormulaEquals('=MINUTE("8:10:29")', 10);
153+});
154+
155+test("Sheet SECOND", function(){
156+  assertFormulaEquals('=SECOND("8:10:29")', 29);
157+});
158+
159+test("Sheet NETWORKDAYS", function(){
160+  assertFormulaEquals('=NETWORKDAYS("1992-1-1", "1992-1-30")', 22);
161+});
162+
163+test("Sheet NETWORKDAYS.INTL", function(){
164+  assertFormulaEquals('=NETWORKDAYS.INTL("1992-1-1", "1992-1-30")', 22);
165+});
166+
167+test("Sheet TIME", function(){
168+  assertFormulaEquals('=TIME(10, 10, 10)', 0.4237268518518518);
169+});
170+
171+test("Sheet WORKDAY", function(){
172+  assertFormulaEquals('=WORKDAY(DATE(1999, 2, 2), 10)', 36207);
173+});
174+
175+test("Sheet WORKDAY.INTL", function(){
176+  assertFormulaEquals('=WORKDAY.INTL(DATE(1999, 2, 2), 10)', 36207);
177+});
178+
179 test("Sheet *", function(){
180   assertFormulaEquals('= 10 * 10', 100);
181   assertFormulaEquals('= 10 * 0', 0);