commit
message
[Sheet, README.md] adding tests for mathMatch, adding TODOs
author
Ben Vogt <[email protected]>
date
2017-05-11 02:31:15
stats
3 file(s) changed,
23 insertions(+),
8 deletions(-)
files
README.md
src/Sheet.ts
tests/SheetFormulaTest.ts
1diff --git a/README.md b/README.md
2index bf226fc..d3d9d9e 100644
3--- a/README.md
4+++ b/README.md
5@@ -69,7 +69,19 @@ TypeConverter.
6 ### Ensure all formulas are tested inside of SheetFormulaTest.ts
7
8
9-### Test all functions in src/Utilities
10+### Test ArgsChecker
11+
12+
13+### Test CriteriaFunctionFactory
14+
15+
16+### Test Filter
17+
18+
19+### Test Serilaizer
20+
21+
22+### Test TypeConverter
23
24
25 ### CONVERT could offer more accurate conversions for units in the same system
26diff --git a/src/Sheet.ts b/src/Sheet.ts
27index f83020c..01df1e7 100644
28--- a/src/Sheet.ts
29+++ b/src/Sheet.ts
30@@ -398,14 +398,9 @@ var Sheet = (function () {
31 mathMatch: function (type, number1, number2) {
32 var result;
33
34- // TODO: These should convert
35 number1 = helper.number(number1);
36 number2 = helper.number(number2);
37
38- if (isNaN(number1) || isNaN(number2)) {
39- throw Error('VALUE'); // TODO: we should catch and handle this when we convert the numbers...
40- }
41-
42 switch (type) {
43 case '+':
44 result = number1 + number2;
45diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
46index 38f5f74..26dbb19 100644
47--- a/tests/SheetFormulaTest.ts
48+++ b/tests/SheetFormulaTest.ts
49@@ -5,7 +5,7 @@ import {
50 assertEquals,
51 test
52 } from "./utils/Asserts";
53-import {DIV_ZERO_ERROR} from "../src/Errors";
54+import {DIV_ZERO_ERROR, VALUE_ERROR} from "../src/Errors";
55
56 function assertFormulaEqualsError(formula: string, errorString: string) {
57 var sheet = new Sheet();
58@@ -451,4 +451,13 @@ test("Sheet ^", function(){
59 assertFormulaEquals('= 10 ^ 0', 1);
60 assertFormulaEquals('= 1 ^ 1', 1);
61 assertFormulaEquals('= 2 ^ 10', 1024);
62+});
63+
64+test("Sheet mathMathc", function(){
65+ assertFormulaEquals('= "10" + 10', 20);
66+ // TODO: throws parse error, should clean up
67+ // assertFormulaEqualsError('= 10e / 1', VALUE_ERROR);
68+ // TODO: Should fail, but doesn't because 10e parses to a string
69+ // assertFormulaEqualsError('= "10e" + 10', VALUE_ERROR);
70+ assertFormulaEqualsError('= "MR" + 10', VALUE_ERROR);
71 });
72\ No newline at end of file