spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
Writing tests for parsing math functions
author
Ben Vogt <[email protected]>
date
2017-01-05 23:43:33
stats
3 file(s) changed, 14 insertions(+), 5 deletions(-)
files
README.md
tests/HelperTest.ts
tests/SheetParseTest.ts
 1diff --git a/README.md b/README.md
 2index 6cea5a0..89ab3ac 100644
 3--- a/README.md
 4+++ b/README.md
 5@@ -10,10 +10,5 @@ Things I should do.
 6 * If I set a cell with a formula, update a dependency, the value of that cell should change.
 7 * If I set a cell with a formula, update it, the value of that cell should change.
 8 
 9-### Write tests for parsing types
10-* If I add a cell with a decimal, what's the most precision I can get?
11-* If I add `=10 * 10` will it parse to 100?
12-* If I add `=SUM(10) + 22` will it parse to 32?
13-
14 ### Parsing interesting values
15 * Expand tests greatly.
16\ No newline at end of file
17diff --git a/tests/HelperTest.ts b/tests/HelperTest.ts
18index 734ddbe..c69491f 100644
19--- a/tests/HelperTest.ts
20+++ b/tests/HelperTest.ts
21@@ -12,3 +12,4 @@ assertEquals(111, Helpers.number("000111"));
22 assertEquals("10 + 10", Helpers.number("10 + 10"));
23 assertEquals("10/10", Helpers.number("10/10"));
24 assertEquals("10*10", Helpers.number("10*10"));
25+assertEquals(10.18239817293872, Helpers.number("10.18239817293871982379817157562"));
26diff --git a/tests/SheetParseTest.ts b/tests/SheetParseTest.ts
27new file mode 100644
28index 0000000..e2d7f4a
29--- /dev/null
30+++ b/tests/SheetParseTest.ts
31@@ -0,0 +1,13 @@
32+import { Sheet } from "../src/Sheet"
33+import { assertEquals } from "./utils/Asserts"
34+
35+// Test parsing math formulas
36+var sheet  = new Sheet();
37+sheet.setCell("A1", "=10 * 10");
38+var cell = sheet.getCell("A1");
39+assertEquals(100, cell.getValue());
40+
41+var sheet  = new Sheet();
42+sheet.setCell("A1", "=SUM(10) + 12");
43+var cell = sheet.getCell("A1");
44+assertEquals(22, cell.getValue());