fable 3.1.27 → 3.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fable.js +169 -161
- package/dist/fable.js.map +1 -1
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Postfix.js +12 -0
- package/test/ExpressionParser_tests.js +22 -0
package/package.json
CHANGED
package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Postfix.js
CHANGED
|
@@ -407,6 +407,12 @@ class ExpressionParserPostfix extends libExpressionParserOperationBase
|
|
|
407
407
|
else if (tmpPostfixTokenObject.Token === ')')
|
|
408
408
|
{
|
|
409
409
|
let tmpOpenParenthesis = tmpFunctionCacheLIFOStack.pop();
|
|
410
|
+
if (!tmpOpenParenthesis)
|
|
411
|
+
{
|
|
412
|
+
tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.buildPostfixedSolveList found a closing parenthesis at token index ${i} with no corresponding opening parenthesis.`);
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
|
|
410
416
|
if (tmpOpenParenthesis.IsFunction)
|
|
411
417
|
{
|
|
412
418
|
tmpPostfixTokenObject.IsFunction = true;
|
|
@@ -471,6 +477,12 @@ class ExpressionParserPostfix extends libExpressionParserOperationBase
|
|
|
471
477
|
}
|
|
472
478
|
}
|
|
473
479
|
}
|
|
480
|
+
if (!tmpOpenParenthesis)
|
|
481
|
+
{
|
|
482
|
+
tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.buildPostfixedSolveList found a closing parenthesis at token index ${i} with no corresponding opening parenthesis.`);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
|
|
474
486
|
if (tmpOpenParenthesis.PreviousOperator && tmpOpenParenthesis.NextOperator)
|
|
475
487
|
{
|
|
476
488
|
if (tmpOpenParenthesis.PreviousOperator.Descriptor.Precedence <= tmpOpenParenthesis.NextOperator.Descriptor.Precedence)
|
|
@@ -54,6 +54,8 @@ suite
|
|
|
54
54
|
let tokenizedNegativeParams = _Parser.tokenize('SUM(10, -10)');
|
|
55
55
|
//Expect(tokenizedNegativeParams.length).to.equal(6);
|
|
56
56
|
Expect(tokenizedNegativeParams).to.deep.equal(['SUM', '(', '10', ',', '-', '10', ')']);
|
|
57
|
+
let unbalancedParens = _Parser.tokenize('ROUND(5 + (2 * 10), 10))');
|
|
58
|
+
Expect(unbalancedParens).to.deep.equal(['ROUND', '(', '5', '+', '(', '2', '*', '10', ')', ',', '10', ')', ')']);
|
|
57
59
|
return fDone();
|
|
58
60
|
}
|
|
59
61
|
);
|
|
@@ -78,6 +80,12 @@ suite
|
|
|
78
80
|
let brokenLintedResults = _Parser.lintTokenizedExpression(brokenTokenizedResults, tmpResultObject);
|
|
79
81
|
// The */ is invalid!!!!
|
|
80
82
|
Expect(brokenLintedResults.length).to.equal(1);
|
|
83
|
+
|
|
84
|
+
let unbalancedParensTokenizedResults = _Parser.tokenize('Value = ROUND(5 + (2 * 10), 10))');
|
|
85
|
+
let unbalancedParensLintedResults = _Parser.lintTokenizedExpression(unbalancedParensTokenizedResults, tmpResultObject);
|
|
86
|
+
// The unbalanced parens should be caught
|
|
87
|
+
Expect(unbalancedParensLintedResults.length).to.equal(1);
|
|
88
|
+
Expect(unbalancedParensLintedResults[0]).to.contain('unbalanced parenthesis');
|
|
81
89
|
return fDone();
|
|
82
90
|
}
|
|
83
91
|
);
|
|
@@ -173,6 +181,20 @@ suite
|
|
|
173
181
|
testFable.ExpressionParser.Messaging.logFunctionSolve(tmpResultObject);
|
|
174
182
|
Expect(tmpDestinationObject.EGS).to.equal("0.0061");
|
|
175
183
|
|
|
184
|
+
tmpDataObject.EJBinderGb1 = '15.5';
|
|
185
|
+
tmpDataObject.EKPctBinderPb2 = '2.55555';
|
|
186
|
+
_Parser.solve('EGse1 = Round((100 - EJBinderGb1) / EKPctBinderPb2), 2)', tmpDataObject, tmpResultObject, false, tmpDestinationObject);
|
|
187
|
+
//TODO: we can consider solving and ignoring this paren, but for now, the error is fatal
|
|
188
|
+
Expect(tmpDestinationObject.EGse1).to.not.exist;
|
|
189
|
+
testFable.ExpressionParser.Messaging.logFunctionSolve(tmpResultObject);
|
|
190
|
+
|
|
191
|
+
_Parser.solve('EGse1 = Round((100 - EJBinderGb1) / EKPctBinderPb2, 2)', tmpDataObject, tmpResultObject, false, tmpDestinationObject);
|
|
192
|
+
Expect(tmpDestinationObject.EGse1).to.equal('33.07');
|
|
193
|
+
|
|
194
|
+
_Parser.solve('EGse1 = Round((100 - EJBinderGb1) / EKPctBinderPb2), 2)', tmpDataObject, tmpResultObject, false, tmpDestinationObject);
|
|
195
|
+
// ensure that this does mutate the output on error
|
|
196
|
+
Expect(tmpDestinationObject.EGse1).to.not.exist;
|
|
197
|
+
|
|
176
198
|
return fDone();
|
|
177
199
|
}
|
|
178
200
|
);
|