@@ -800,10 +800,10 @@ public void TypeTesting(string expression, Type type)
800
800
[ TestCase ( "ListOfType(typeof(int), 1,2,3 )[0]" , ExpectedResult = 1 , Category = "Standard Functions,ListOfType Function,Indexing" ) ]
801
801
[ TestCase ( "ListOfType(typeof(int), 1,2,3 )[1]" , ExpectedResult = 2 , Category = "Standard Functions,ListOfType Function,Indexing" ) ]
802
802
[ TestCase ( "ListOfType(typeof(int), 1,2,3 )[2]" , ExpectedResult = 3 , Category = "Standard Functions,ListOfType Function,Indexing" ) ]
803
- [ TestCase ( "ListOfType(typeof(string), \" hello\" ,\" Test\" ).GetType()" , ExpectedResult = typeof ( List < string > ) , Category = "Standard Functions,ListOfType Function,Instance Property" ) ]
804
- [ TestCase ( "ListOfType(typeof(string), \" hello\" ,\" Test\" ).Count" , ExpectedResult = 2 , Category = "Standard Functions,ListOfType Function,Instance Property" ) ]
805
- [ TestCase ( "ListOfType(typeof(string), \" hello\" ,\" Test\" )[0]" , ExpectedResult = "hello" , Category = "Standard Functions,ListOfType Function,Indexing" ) ]
806
- [ TestCase ( "ListOfType(typeof(string), \" hello\" ,\" Test\" )[1]" , ExpectedResult = "Test" , Category = "Standard Functions,ListOfType Function,Indexing" ) ]
803
+ [ TestCase ( "ListOfType(typeof(string), \" hello\" ,\" Test\" ).GetType()" , ExpectedResult = typeof ( List < string > ) , Category = "Standard Functions,ListOfType Function,Instance Property" ) ]
804
+ [ TestCase ( "ListOfType(typeof(string), \" hello\" ,\" Test\" ).Count" , ExpectedResult = 2 , Category = "Standard Functions,ListOfType Function,Instance Property" ) ]
805
+ [ TestCase ( "ListOfType(typeof(string), \" hello\" ,\" Test\" )[0]" , ExpectedResult = "hello" , Category = "Standard Functions,ListOfType Function,Indexing" ) ]
806
+ [ TestCase ( "ListOfType(typeof(string), \" hello\" ,\" Test\" )[1]" , ExpectedResult = "Test" , Category = "Standard Functions,ListOfType Function,Indexing" ) ]
807
807
#endregion
808
808
809
809
#region Log Function
@@ -1111,23 +1111,16 @@ 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
-
1121
- yield return new TestCaseData ( "simpleInt.ToString()" , onInstanceVariables , true ) . SetCategory ( "Instance Method" ) . Returns ( "42" ) ;
1122
- yield return new TestCaseData ( "simpleInt.ToString().Length" , onInstanceVariables , true ) . SetCategory ( "Instance Method,Instance Property" ) . Returns ( 2 ) ;
1123
-
1124
1114
yield return new TestCaseData ( "customObject.IntProperty" , onInstanceVariables , true ) . SetCategory ( "Instance Property" ) . Returns ( 25 ) ;
1125
1115
yield return new TestCaseData ( "customObject?.IntProperty" , onInstanceVariables , true ) . SetCategory ( "Instance Property" ) . Returns ( 25 ) ;
1126
1116
yield return new TestCaseData ( "customObject.intField" , onInstanceVariables , true ) . SetCategory ( "Instance Field" ) . Returns ( 12 ) ;
1127
1117
yield return new TestCaseData ( "customObject?.intField" , onInstanceVariables , true ) . SetCategory ( "Instance Field" ) . Returns ( 12 ) ;
1128
1118
yield return new TestCaseData ( "customObject.Add3To(9)" , onInstanceVariables , true ) . SetCategory ( "Instance Method" ) . Returns ( 12 ) ;
1129
1119
yield return new TestCaseData ( "customObject?.Add3To(5)" , onInstanceVariables , true ) . SetCategory ( "Instance Method" ) . Returns ( 8 ) ;
1130
1120
1121
+ yield return new TestCaseData ( "simpleInt.ToString()" , onInstanceVariables , true ) . SetCategory ( "Instance Method" ) . Returns ( "42" ) ;
1122
+ yield return new TestCaseData ( "simpleInt.ToString().Length" , onInstanceVariables , true ) . SetCategory ( "Instance Method,Instance Property" ) . Returns ( 2 ) ;
1123
+
1131
1124
yield return new TestCaseData ( "ClassForTest1.StaticIntProperty" , onInstanceVariables , true ) . SetCategory ( "Static Property" ) . Returns ( 67 ) ;
1132
1125
yield return new TestCaseData ( "ClassForTest1.StaticStringMethod(\" Bob\" )" , onInstanceVariables , true ) . SetCategory ( "Static Method" ) . Returns ( "Hello Bob" ) ;
1133
1126
@@ -1149,10 +1142,24 @@ public static IEnumerable<TestCaseData> TestCasesForWithCustomVariablesExpressio
1149
1142
yield return new TestCaseData ( "simpleInt--" , onInstanceVariables , true ) . SetCategory ( "Postfix operator, --" ) . Returns ( 42 ) ;
1150
1143
yield return new TestCaseData ( "simpleInt-- - simpleInt" , onInstanceVariables , true ) . SetCategory ( "Postfix operator, --" ) . Returns ( 1 ) ;
1151
1144
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 ) ;
1145
+ yield return new TestCaseData ( "false && 1/0>0" , onInstanceVariables , true ) . SetCategory ( "Conditional And, negative left operand (should respect left associativity)" ) . Returns ( false ) ;
1146
+ yield return new TestCaseData ( "true || 1/0>0" , onInstanceVariables , true ) . SetCategory ( "Conditional Or, positive left operand (should respect left associativity)" ) . Returns ( true ) ;
1147
+ yield return new TestCaseData ( "false && (true && 1/0>0)" , onInstanceVariables , true ) . SetCategory ( "Conditional And, negative left operand (should respect left associativity)" ) . Returns ( false ) ;
1148
+ yield return new TestCaseData ( "true || (false || 1/0>0)" , onInstanceVariables , true ) . SetCategory ( "Conditional Or, positive left operand (should respect left associativity)" ) . Returns ( true ) ;
1149
+ yield return new TestCaseData ( "false && 1/0 == 0" , onInstanceVariables , true ) . SetCategory ( "Instance Property,And Conditional" ) . Returns ( false ) ;
1150
+ yield return new TestCaseData ( "!string.IsNullOrEmpty(nullVar) && nullVar.StartsWith(\" ABC\" )" , onInstanceVariables , true ) . SetCategory ( "Instance Property,And Conditional" ) . Returns ( false ) ;
1151
+ yield return new TestCaseData ( "string.IsNullOrEmpty(nullVar) || nullVar.StartsWith(\" ABC\" )" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional" ) . Returns ( true ) ;
1152
+ yield return new TestCaseData ( "!string.IsNullOrEmpty(nullVar) && nullVar.StartsWith(\" ABC\" ) == false" , onInstanceVariables , true ) . SetCategory ( "Instance Property,And Conditional" ) . Returns ( false ) ;
1153
+ yield return new TestCaseData ( "string.IsNullOrEmpty(nullVar) || nullVar.StartsWith(\" ABC\" ) == false" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional" ) . Returns ( true ) ;
1154
+ yield return new TestCaseData ( "!string.IsNullOrEmpty(nullVar) && nullVar.Length < 2" , onInstanceVariables , true ) . SetCategory ( "Instance Property,And Conditional" ) . Returns ( false ) ;
1155
+ yield return new TestCaseData ( "string.IsNullOrEmpty(nullVar) || nullVar.Length < 2" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional" ) . Returns ( true ) ;
1156
+ yield return new TestCaseData ( "true || 1/0 == 0" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional" ) . Returns ( true ) ;
1157
+ yield return new TestCaseData ( "false && true || true" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional,And Conditional,Precedence check" ) . Returns ( true ) ;
1158
+ yield return new TestCaseData ( "true || true && false" , onInstanceVariables , true ) . SetCategory ( "Instance Property,Or Conditional,And Conditional,Precedence check" ) . Returns ( true ) ;
1159
+ yield return new TestCaseData ( "false && nullVar.What ? nullVar.Text : \" Hello\" " , onInstanceVariables , true ) . SetCategory ( "Instance Property,Ternary operator, And Conditional" ) . Returns ( "Hello" ) ;
1160
+ yield return new TestCaseData ( "false && (false && nullVar.What ? nullVar.boolValue : true) ? nullVar.Text : \" Hello\" " , onInstanceVariables , true ) . SetCategory ( "Instance Property,Ternary operator, And Conditional" ) . Returns ( "Hello" ) ;
1161
+
1162
+
1156
1163
#endregion
1157
1164
1158
1165
#region Delegates as a variable
@@ -1438,7 +1445,8 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingEvaluation
1438
1445
evaluator = new ExpressionEvaluator ( new Dictionary < string , object >
1439
1446
{
1440
1447
{ "P1var" , "P1" } ,
1441
- { "myObj" , new ClassForTest1 ( ) }
1448
+ { "myObj" , new ClassForTest1 ( ) } ,
1449
+ { "nullVar" , null } ,
1442
1450
} ) ;
1443
1451
1444
1452
evaluator . PreEvaluateVariable += ( sender , e ) =>
@@ -1458,10 +1466,15 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingEvaluation
1458
1466
yield return new TestCaseData ( evaluator , "myObj.PropertyThatWillFailed" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Var" ) ;
1459
1467
yield return new TestCaseData ( evaluator , "myObj.Add3To(5)" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Func" ) ;
1460
1468
yield return new TestCaseData ( evaluator , "Abs(-5)" , typeof ( ExpressionEvaluatorSyntaxErrorException ) ) . SetCategory ( "OnTheFly canceled Func" ) ;
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)" ) ;
1469
+ #endregion
1470
+
1471
+ #region Bugs corrections
1472
+
1473
+ yield return new TestCaseData ( evaluator , "true && 1/0>0" , typeof ( DivideByZeroException ) ) . SetCategory ( "Conditional And, positive left operand (should lead to exception)" ) ;
1474
+ yield return new TestCaseData ( evaluator , "false || 1/0>0" , typeof ( DivideByZeroException ) ) . SetCategory ( "Conditional Or, positive left operand (should lead to exception associativity)" ) ;
1475
+ yield return new TestCaseData ( evaluator , "true && (true && 1/0>0)" , typeof ( DivideByZeroException ) ) . SetCategory ( "Conditional And, positive left operand (should lead to exception)" ) ;
1476
+ yield return new TestCaseData ( evaluator , "false || (false || 1/0>0)" , typeof ( DivideByZeroException ) ) . SetCategory ( "Conditional Or, positive left operand (should lead to exception associativity)" ) ;
1477
+
1465
1478
#endregion
1466
1479
}
1467
1480
}
0 commit comments