@@ -1111,6 +1111,13 @@ public static IEnumerable<TestCaseData> TestCasesForWithCustomVariablesExpressio
1111
1111
yield return new TestCaseData ( "nullVar?[1][3]" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Null Conditional indexing" ) . Returns ( null ) ;
1112
1112
yield return new TestCaseData ( "simpleArray2?[3]?.Trim()" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Null Conditional indexing" ) . Returns ( null ) ;
1113
1113
1114
+ yield return new TestCaseData ( "false && 1/0 == 0" , onInstanceVariables , true ) . SetCategory ( "Instance Property,And Conditional" ) . Returns ( false ) ;
1115
+ yield return new TestCaseData ( "!string.IsNullOrEmpty(nullVar) && nullVar.StartsWith(\" ABC\" )" , onInstanceVariables , true ) . SetCategory ( "Instance Property,And Conditional" ) . Returns ( false ) ;
1116
+ yield return new TestCaseData ( "string.IsNullOrEmpty(nullVar) || nullVar.StartsWith(\" ABC\" )" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional" ) . Returns ( true ) ;
1117
+ yield return new TestCaseData ( "true || 1/0 == 0" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional" ) . Returns ( true ) ;
1118
+ yield return new TestCaseData ( "false && true || true" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional,And Conditional,Precedence check" ) . Returns ( true ) ;
1119
+ yield return new TestCaseData ( "true || true && false" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional,And Conditional,Precedence check" ) . Returns ( true ) ;
1120
+
1114
1121
yield return new TestCaseData ( "simpleInt.ToString()" , onInstanceVariables , true ) . SetCategory ( "Instance Method" ) . Returns ( "42" ) ;
1115
1122
yield return new TestCaseData ( "simpleInt.ToString().Length" , onInstanceVariables , true ) . SetCategory ( "Instance Method,Instance Property" ) . Returns ( 2 ) ;
1116
1123
@@ -1141,6 +1148,11 @@ public static IEnumerable<TestCaseData> TestCasesForWithCustomVariablesExpressio
1141
1148
yield return new TestCaseData ( "simpleInt++ - simpleInt" , onInstanceVariables , true ) . SetCategory ( "Postfix operator, ++" ) . Returns ( - 1 ) ;
1142
1149
yield return new TestCaseData ( "simpleInt--" , onInstanceVariables , true ) . SetCategory ( "Postfix operator, --" ) . Returns ( 42 ) ;
1143
1150
yield return new TestCaseData ( "simpleInt-- - simpleInt" , onInstanceVariables , true ) . SetCategory ( "Postfix operator, --" ) . Returns ( 1 ) ;
1151
+
1152
+ yield return new TestCaseData ( "false && 1/0>0" , onInstanceVariables , true ) . SetCategory ( "Conditional And, negative left operand (should respect left associativity)" ) . Returns ( false ) ;
1153
+ yield return new TestCaseData ( "true || 1/0>0" , onInstanceVariables , true ) . SetCategory ( "Conditional Or, positive left operand (should respect left associativity)" ) . Returns ( true ) ;
1154
+ yield return new TestCaseData ( "false && (true && 1/0>0)" , onInstanceVariables , true ) . SetCategory ( "Conditional And, negative left operand (should respect left associativity)" ) . Returns ( false ) ;
1155
+ yield return new TestCaseData ( "true || (false || 1/0>0)" , onInstanceVariables , true ) . SetCategory ( "Conditional Or, positive left operand (should respect left associativity)" ) . Returns ( true ) ;
1144
1156
#endregion
1145
1157
1146
1158
#region Delegates as a variable
@@ -1426,7 +1438,7 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingEvaluation
1426
1438
evaluator = new ExpressionEvaluator ( new Dictionary < string , object >
1427
1439
{
1428
1440
{ "P1var" , "P1" } ,
1429
- { "myObj" , new ClassForTest1 ( ) } ,
1441
+ { "myObj" , new ClassForTest1 ( ) }
1430
1442
} ) ;
1431
1443
1432
1444
evaluator . PreEvaluateVariable += ( sender , e ) =>
@@ -1446,7 +1458,10 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingEvaluation
1446
1458
yield return new TestCaseData ( evaluator , "myObj.PropertyThatWillFailed" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Var" ) ;
1447
1459
yield return new TestCaseData ( evaluator , "myObj.Add3To(5)" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Func" ) ;
1448
1460
yield return new TestCaseData ( evaluator , "Abs(-5)" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Func" ) ;
1449
-
1461
+ yield return new TestCaseData ( evaluator , "true && 1/0>0" , typeof ( DivideByZeroException ) ) . SetCategory ( "Conditional And, positive left operand (should lead to exception)" ) ;
1462
+ yield return new TestCaseData ( evaluator , "false || 1/0>0" , typeof ( DivideByZeroException ) ) . SetCategory ( "Conditional Or, positive left operand (should lead to exception associativity)" ) ;
1463
+ yield return new TestCaseData ( evaluator , "true && (true && 1/0>0)" , typeof ( DivideByZeroException ) ) . SetCategory ( "Conditional And, positive left operand (should lead to exception)" ) ;
1464
+ yield return new TestCaseData ( evaluator , "false || (false || 1/0>0)" , typeof ( DivideByZeroException ) ) . SetCategory ( "Conditional Or, positive left operand (should lead to exception associativity)" ) ;
1450
1465
#endregion
1451
1466
}
1452
1467
}
0 commit comments