Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7736f26b7 | |||
| 1a878fe4e7 | |||
| 75f5c948ed | |||
| ad9e3e6bad |
@@ -664,7 +664,7 @@ namespace VAR.ExpressionEvaluator.Tests
|
||||
|
||||
#endregion String coercions
|
||||
|
||||
#region Excepctions
|
||||
#region Exceptions
|
||||
|
||||
[Fact]
|
||||
public void Exceptions__HelloAtEnd__UnexpectedCharactersAtEndException()
|
||||
@@ -848,6 +848,33 @@ namespace VAR.ExpressionEvaluator.Tests
|
||||
}
|
||||
|
||||
|
||||
#endregion Exceptions
|
||||
|
||||
#region Misc
|
||||
|
||||
[Fact()]
|
||||
public void Misc__MixedExpression_EqualsFalse()
|
||||
{
|
||||
EvaluationContext evaluationContex = new EvaluationContext();
|
||||
evaluationContex.SetVariable("QI_86", null);
|
||||
evaluationContex.SetVariable("QI_87", null);
|
||||
evaluationContex.SetVariable("QI_104", null);
|
||||
string expression = "( QI_86 = 0 Or QI_86 = null ) And ( QI_87 = 0 Or QI_87 = null ) And QI_104 > 0";
|
||||
object result = Parser.EvaluateString(expression, evaluationContex);
|
||||
Assert.False((bool?)result);
|
||||
}
|
||||
|
||||
[Fact()]
|
||||
public void Misc__ProductWithStringDecimals_EqualsFalse()
|
||||
{
|
||||
EvaluationContext evaluationContex = new EvaluationContext();
|
||||
evaluationContex.SetVariable("$1109", "1933");
|
||||
evaluationContex.SetVariable("$1150", "02.00000");
|
||||
string expression = "$1109 * $1150";
|
||||
object result = Parser.EvaluateString(expression, evaluationContex);
|
||||
Assert.Equal(3866.00000M, result);
|
||||
}
|
||||
|
||||
#endregion Misc
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace VAR.ExpressionEvaluator
|
||||
|
||||
if (leftValue is string)
|
||||
{
|
||||
if (decimal.TryParse((string)leftValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)leftValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)leftValue));
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
if (rightValue is string)
|
||||
{
|
||||
if (decimal.TryParse((string)rightValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)rightValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)rightValue));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
// Decimal
|
||||
if (leftValue is string)
|
||||
{
|
||||
if (decimal.TryParse((string)leftValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)leftValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
leftValue = null;
|
||||
}
|
||||
@@ -55,7 +55,7 @@
|
||||
}
|
||||
if (rightValue is string)
|
||||
{
|
||||
if (decimal.TryParse((string)rightValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)rightValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
rightValue = null;
|
||||
}
|
||||
@@ -85,7 +85,7 @@
|
||||
return null;
|
||||
}
|
||||
decimal decValue;
|
||||
if (decimal.TryParse(text, out decValue))
|
||||
if (decimal.TryParse(text, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decValue))
|
||||
{
|
||||
return decValue != 0;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimal.TryParse((string)leftValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)leftValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)leftValue));
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimal.TryParse((string)rightValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)rightValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)rightValue));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimal.TryParse((string)leftValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)leftValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)leftValue));
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimal.TryParse((string)rightValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)rightValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)rightValue));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimal.TryParse((string)leftValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)leftValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)leftValue));
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimal.TryParse((string)rightValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)rightValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)rightValue));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimal.TryParse((string)leftValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)leftValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)leftValue));
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimal.TryParse((string)rightValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)rightValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)rightValue));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace VAR.ExpressionEvaluator
|
||||
|
||||
if (leftValue is string)
|
||||
{
|
||||
if (decimal.TryParse((string)leftValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)leftValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)leftValue));
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
if (rightValue is string)
|
||||
{
|
||||
if (decimal.TryParse((string)rightValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)rightValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)rightValue));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace VAR.ExpressionEvaluator
|
||||
|
||||
if (leftValue is string)
|
||||
{
|
||||
if (decimal.TryParse((string)leftValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)leftValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)leftValue));
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace VAR.ExpressionEvaluator
|
||||
}
|
||||
if (rightValue is string)
|
||||
{
|
||||
if (decimal.TryParse((string)rightValue, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)rightValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)rightValue));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace VAR.ExpressionEvaluator
|
||||
|
||||
if (value is string)
|
||||
{
|
||||
if (decimal.TryParse((string)value, out decimal dec) == false)
|
||||
if (decimal.TryParse((string)value, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out decimal dec) == false)
|
||||
{
|
||||
throw new Exception(string.Format("Can't convert to decimal string value \"{0}\"", (string)value));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace VAR.ExpressionEvaluator
|
||||
|
||||
#region Creator
|
||||
|
||||
private ITokenizer _tokenizer;
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public Parser(ITokenizer tokenizer)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ namespace VAR.ExpressionEvaluator
|
||||
IExpressionNode rightNode = ParseRelations();
|
||||
leftNode = new ExpressionBooleanAndNode(leftNode, rightNode);
|
||||
}
|
||||
if (_tokenizer.Token == Token.Or)
|
||||
else if (_tokenizer.Token == Token.Or)
|
||||
{
|
||||
_tokenizer.NextToken();
|
||||
IExpressionNode rightNode = ParseRelations();
|
||||
@@ -84,7 +84,7 @@ namespace VAR.ExpressionEvaluator
|
||||
IExpressionNode rightNode = ParsePlusAndMinus();
|
||||
leftNode = new ExpressionEqualsNode(leftNode, rightNode);
|
||||
}
|
||||
if (_tokenizer.Token == Token.ExclusiveEquals)
|
||||
else if (_tokenizer.Token == Token.ExclusiveEquals)
|
||||
{
|
||||
// TODO: Implement ExpressionExclusiveEqualsNode
|
||||
_tokenizer.NextToken();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<PropertyGroup>
|
||||
<PackageId>VAR.ExpressionEvaluator</PackageId>
|
||||
<Title>VAR.ExpressionEvaluator</Title>
|
||||
<Version>0.2.5</Version>
|
||||
<Version>0.2.7</Version>
|
||||
<Description>Expression Evaluation Library</Description>
|
||||
<Authors>VAR</Authors>
|
||||
<Company>VAR</Company>
|
||||
|
||||
Reference in New Issue
Block a user