Skip to content

Commit 76963c0

Browse files
committed
Test with chained all Right,Left and both operand pass
1 parent ede5646 commit 76963c0

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,28 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
21512151
.SetCategory("inherits ExpressionEvaluator")
21522152
.SetCategory("Custom operators");
21532153

2154+
yield return new TestCaseData(xExpressionEvaluator2
2155+
, "2##", null)
2156+
.Returns(1.4142135623730952d)
2157+
.SetCategory("ExpressionEvaluator extend")
2158+
.SetCategory("inherits ExpressionEvaluator")
2159+
.SetCategory("Custom operators");
2160+
2161+
yield return new TestCaseData(xExpressionEvaluator2
2162+
, "2## + 1", null)
2163+
.Returns(2.4142135623730949d)
2164+
.SetCategory("ExpressionEvaluator extend")
2165+
.SetCategory("inherits ExpressionEvaluator")
2166+
.SetCategory("Custom operators");
2167+
2168+
2169+
yield return new TestCaseData(xExpressionEvaluator2
2170+
, "2## + +-+-~+1", null)
2171+
.Returns(-0.58578643762690485d)
2172+
.SetCategory("ExpressionEvaluator extend")
2173+
.SetCategory("inherits ExpressionEvaluator")
2174+
.SetCategory("Custom operators");
2175+
21542176
yield return new TestCaseData(xExpressionEvaluator2
21552177
, "1 love 2", null)
21562178
.Returns(6)

CodingSeb.ExpressionEvaluator.Tests/TestsUtils/XExpressionEvaluator2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class XExpressionEvaluator2 : ExpressionEvaluator
1818
protected new static readonly IList<IDictionary<ExpressionOperator, Func<dynamic, dynamic, object>>> operatorsEvaluations =
1919
ExpressionEvaluator.operatorsEvaluations
2020
.Copy()
21-
.AddOperatorEvaluationAtNewLevelAfter(XExpressionOperator2.Sharp, (left, _) => Math.Pow(left, -left), ExpressionOperator.UnaryPlus)
21+
.AddOperatorEvaluationAtNewLevelAfter(XExpressionOperator2.Sharp, (left, _) => Math.Pow(left, -left), ExpressionOperator.Cast)
2222
.AddOperatorEvaluationAtLevelOf(XExpressionOperator2.Love, (left, right) => (left | right) << 1, ExpressionOperator.ShiftBitsLeft);
2323

2424
protected override IList<ExpressionOperator> LeftOperandOnlyOperatorsEvaluationDictionary => leftOperandOnlyOperatorsEvaluationDictionary;

0 commit comments

Comments
 (0)