public void Test003() { var e2 = Expression.Default(typeof(int)); var e3 = Expression.Parameter(typeof(string)); var e1 = Expression.Lambda(e2, e3); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.ProductionHas(e1, o1 => o1.Body == e1.Body); assert.ProductionHas(e1, o1 => o1.TailCall == e1.TailCall); assert.ProductionHas(e1, o1 => o1.Parameters.Count == e1.Parameters.Count); assert.ProductionHas(e1, o1 => o1.Parameters[0] == e3); assert.ProductionHas(e1, o1 => o1.Name == e1.Name); assert.ProductionHas(e1, o1 => o1.ReturnType == e1.ReturnType); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasNotVisited(e3); assert.WasNotProduced(e3); assert.TotalVisits(2); assert.TotalProduced(2); }
public void Test004() { var e2 = Expression.Default(typeof(int)); var e3 = Expression.Parameter(typeof(string)); var e1 = Expression.Lambda(e2, e3); var replace = new Dictionary <Expression, Expression> { { e3, Expression.Parameter(typeof(string)) } }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.ProductionHas(e1, o1 => o1.Body == e1.Body); assert.ProductionHas(e1, o1 => o1.TailCall == e1.TailCall); assert.ProductionHas(e1, o1 => o1.Parameters.Count == e1.Parameters.Count); // TODO: This is how the code is right now, it doesn't replace the parameter, but maybe it should? assert.ProductionHas(e1, o1 => o1.Parameters[0] == e3); assert.ProductionHas(e1, o1 => o1.Name == e1.Name); assert.ProductionHas(e1, o1 => o1.ReturnType == e1.ReturnType); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasNotVisited(e3); assert.WasNotProduced(e3); assert.TotalVisits(2); assert.TotalProduced(2); }
public void Test035() { var e2 = Expression.Parameter(typeof(object)); var e1 = Expression.Unbox(e2, typeof(int)); var replace = new Dictionary <Expression, Expression> { { e2, Expression.Parameter(typeof(object)) } }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.IsLifted == e1.IsLifted); assert.ProductionHas(e1, o1 => o1.IsLiftedToNull == e1.IsLiftedToNull); assert.ProductionHas(e1, o1 => o1.CanReduce == e1.CanReduce); assert.ProductionHas(e1, o1 => o1.Operand == replace[e2]); assert.ProductionHas(e1, o1 => o1.Method == e1.Method); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.ProductionHas(e1, o1 => o1.NodeType == e1.NodeType); assert.WasVisited(e2); assert.WasNotProduced(e2); assert.WasProduced(replace[e2]); assert.TotalVisits(2); assert.TotalProduced(2); }
public void Test003() { var e2 = Expression.Parameter(typeof(bool)); var e3 = Expression.Parameter(typeof(int)); var e4 = Expression.Parameter(typeof(int)); var e1 = Expression.Condition(e2, e3, e4); var replace = new Dictionary <Expression, Expression> { { e3, Expression.Parameter(typeof(int)) } }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.Test == e2); assert.ProductionHas(e1, o1 => o1.IfTrue == replace[e3]); assert.ProductionHas(e1, o1 => o1.IfFalse == e4); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(replace[e3]); assert.WasNotProduced(e3); assert.WasVisited(e4); assert.WasProduced(e4); assert.TotalVisits(4); assert.TotalProduced(4); }
public void Test032() { var e2 = Expression.Parameter(typeof(int)); var e1 = Expression.PostDecrementAssign(e2); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.ProductionHas(e1, o1 => o1.IsLifted == e1.IsLifted); assert.ProductionHas(e1, o1 => o1.IsLiftedToNull == e1.IsLiftedToNull); assert.ProductionHas(e1, o1 => o1.CanReduce == e1.CanReduce); assert.ProductionHas(e1, o1 => o1.Operand == e1.Operand); assert.ProductionHas(e1, o1 => o1.Method == e1.Method); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.ProductionHas(e1, o1 => o1.NodeType == e1.NodeType); assert.WasVisited(e2); assert.WasProduced(e2); assert.TotalVisits(2); assert.TotalProduced(2); }
public void Test004() { var e2 = Expression.Default(typeof(short)); var e1 = Expression.NegateChecked(e2); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.ProductionHas(e1, o1 => o1.IsLifted == e1.IsLifted); assert.ProductionHas(e1, o1 => o1.IsLiftedToNull == e1.IsLiftedToNull); assert.ProductionHas(e1, o1 => o1.CanReduce == e1.CanReduce); assert.ProductionHas(e1, o1 => o1.Operand == e1.Operand); assert.ProductionHas(e1, o1 => o1.Method == e1.Method); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.ProductionHas(e1, o1 => o1.NodeType == e1.NodeType); assert.WasVisited(e2); assert.WasProduced(e2); assert.TotalVisits(2); assert.TotalProduced(2); }
public void Test018() { var e3 = Expression.Default(typeof(long)); var e2 = Expression.Lambda(e3); var e1 = Expression.Quote(e2); var replace = new Dictionary <Expression, Expression> { { e3, Expression.Default(typeof(long)) } }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.IsLifted == e1.IsLifted); assert.ProductionHas(e1, o1 => o1.IsLiftedToNull == e1.IsLiftedToNull); assert.ProductionHas(e1, o1 => o1.CanReduce == e1.CanReduce); assert.ProductionHas(e1, o1 => o1.Operand is LambdaExpression); assert.ProductionHas(e1, o1 => ((LambdaExpression)o1.Operand).Body == replace[e3]); assert.ProductionHas(e1, o1 => o1.Method == e1.Method); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.ProductionHas(e1, o1 => o1.NodeType == e1.NodeType); assert.WasVisited(e2); assert.WasNotProduced(e2); assert.ProductionHas(e2, o2 => o2.Body == replace[e3]); assert.WasVisited(e3); assert.WasNotProduced(e3); assert.WasProduced(replace[e3]); assert.TotalVisits(3); assert.TotalProduced(3); }
public void Test016() { var mi = typeof(MethodCallData).GetMethod(nameof(MethodCallData.MethodFive)); var e2 = Expression.Default(typeof(MethodCallData)); var e3 = Expression.Parameter(typeof(int)); var e4 = Expression.Parameter(typeof(int)); var e1 = Expression.Call(e2, mi, e3, e4); var replace = new Dictionary <Expression, Expression> { { e3, Expression.Parameter(typeof(int)) }, { e4, Expression.Parameter(typeof(int)) } }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.Object == e2); assert.ProductionHas(e1, o1 => o1.Arguments.Count == e1.Arguments.Count); assert.ProductionHas(e1, o1 => o1.Arguments[0] == replace[e3]); assert.ProductionHas(e1, o1 => o1.Arguments[1] == replace[e4]); assert.ProductionHas(e1, o1 => o1.Method == e1.Method); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(replace[e3]); assert.WasNotProduced(e3); assert.WasVisited(e4); assert.WasProduced(replace[e4]); assert.WasNotProduced(e4); assert.TotalVisits(4); assert.TotalProduced(4); }
public void Test013() { var e2 = Expression.New(typeof(List <string>)); var e3 = Expression.Default(typeof(string)); var e4 = Expression.Default(typeof(string)); var e5 = Expression.Default(typeof(string)); var e1 = Expression.ListInit(e2, e3, e4, e5); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.ProductionHas(e1, o1 => o1.NewExpression == e2); assert.ProductionHas(e1, o1 => o1.Initializers.Count == e1.Initializers.Count); assert.ProductionHas(e1, o1 => o1.Initializers[0].Arguments.Count == e1.Initializers[0].Arguments.Count); assert.ProductionHas(e1, o1 => o1.Initializers[0].Arguments[0] == e3); assert.ProductionHas(e1, o1 => o1.Initializers[1].Arguments.Count == e1.Initializers[0].Arguments.Count); assert.ProductionHas(e1, o1 => o1.Initializers[1].Arguments[0] == e4); assert.ProductionHas(e1, o1 => o1.Initializers[2].Arguments.Count == e1.Initializers[2].Arguments.Count); assert.ProductionHas(e1, o1 => o1.Initializers[2].Arguments[0] == e5); assert.WasProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e4); assert.WasProduced(e4); assert.WasVisited(e5); assert.WasProduced(e5); assert.TotalVisits(5); assert.TotalProduced(5); }
public void Test004() { var e2 = Expression.New(typeof(List <string>)); var e3 = Expression.Default(typeof(string)); var e1 = Expression.ListInit(e2, e3); var replace = new Dictionary <Expression, Expression> { { e2, Expression.New(typeof(List <string>)) }, { e3, Expression.Constant("ABC") }, }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.ProductionHas(e1, o1 => o1.NewExpression == replace[e2]); assert.ProductionHas(e1, o1 => o1.Initializers.Count == e1.Initializers.Count); assert.ProductionHas(e1, o1 => o1.Initializers[0].Arguments.Count == e1.Initializers[0].Arguments.Count); assert.ProductionHas(e1, o1 => o1.Initializers[0].Arguments[0] == replace[e3]); assert.WasNotProduced(e1); assert.WasVisited(e2); assert.WasProduced(replace[e2]); assert.WasNotProduced(e2); assert.WasVisited(e3); assert.WasProduced(replace[e3]); assert.WasNotProduced(e3); assert.TotalVisits(3); assert.TotalProduced(3); }
public void Test030() { var e2 = Expression.Default(typeof(int)); var e3 = Expression.Default(typeof(int)); var e4 = Expression.Default(typeof(int)); var e1 = Expression.NewArrayBounds(typeof(string), e2, e3, e4); var replace = new Dictionary <Expression, Expression> { { e3, Expression.Constant(2) }, { e4, Expression.Constant(3) }, }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.ProductionHas(e1, o1 => o1.Expressions.Count == e1.Expressions.Count); assert.ProductionHas(e1, o1 => o1.Expressions[0] == e2); assert.ProductionHas(e1, o1 => o1.Expressions[1] == replace[e3]); assert.ProductionHas(e1, o1 => o1.Expressions[2] == replace[e4]); assert.WasNotProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(replace[e3]); assert.WasNotProduced(e3); assert.WasVisited(e4); assert.WasProduced(replace[e4]); assert.WasNotProduced(e4); assert.TotalVisits(4); assert.TotalProduced(4); }
public void Test018() { var e2 = Expression.Default(typeof(int)); var e3 = Expression.Default(typeof(int)); var e1 = Expression.NewArrayBounds(typeof(string), e2, e3); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.ProductionHas(e1, o1 => o1.Expressions.Count == e1.Expressions.Count); assert.ProductionHas(e1, o1 => o1.Expressions[0] == e2); assert.ProductionHas(e1, o1 => o1.Expressions[1] == e3); assert.WasProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.TotalVisits(3); assert.TotalProduced(3); }
public void Test013() { var e2 = Expression.Parameter(typeof(string)); var e3 = Expression.Parameter(typeof(string)); var e4 = Expression.Parameter(typeof(string)); var e1 = Expression.NewArrayInit(typeof(string), e2, e3, e4); var replace = new Dictionary <Expression, Expression> { { e2, Expression.Default(typeof(string)) }, { e4, Expression.Default(typeof(string)) }, }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.Expressions.Count == e1.Expressions.Count); assert.ProductionHas(e1, o1 => o1.Expressions[0] == replace[e2]); assert.ProductionHas(e1, o1 => o1.Expressions[1] == e3); assert.ProductionHas(e1, o1 => o1.Expressions[2] == replace[e4]); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(e2); assert.WasProduced(replace[e2]); assert.WasNotProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e4); assert.WasProduced(replace[e4]); assert.WasNotProduced(e4); assert.TotalVisits(4); assert.TotalProduced(4); }
public void Test010() { var e2 = Expression.Default(typeof(CustomIndexerData001)); var e3 = Expression.Default(typeof(int)); var e4 = Expression.Default(typeof(int)); var e5 = Expression.Default(typeof(int)); var prop = e2.Type.GetProperty("Item", new Type[] { typeof(int), typeof(int), typeof(int) }); var e1 = Expression.MakeIndex(e2, prop, new[] { e3, e4, e5 }); var replace = new Dictionary <Expression, Expression> { { e2, Expression.Constant(null, typeof(CustomIndexerData001)) }, }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.Arguments.Count == 3); assert.ProductionHas(e1, o1 => o1.Arguments[0] == e3); assert.ProductionHas(e1, o1 => o1.Arguments[1] == e4); assert.ProductionHas(e1, o1 => o1.Arguments[2] == e5); assert.ProductionHas(e1, o1 => o1.Object == replace[e2]); assert.ProductionHas(e1, o1 => o1.Indexer == prop); assert.WasVisited(e2); assert.WasNotProduced(e2); assert.WasProduced(replace[e2]); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e4); assert.WasProduced(e4); assert.WasVisited(e5); assert.WasProduced(e5); assert.TotalVisits(5); assert.TotalProduced(5); }
public void Test025() { var e2 = Expression.Default(typeof(int)); var e1 = Expression.OnesComplement(e2); var replace = new Dictionary <Expression, Expression> { { e2, Expression.Constant(1, typeof(int)) } }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.IsLifted == e1.IsLifted); assert.ProductionHas(e1, o1 => o1.IsLiftedToNull == e1.IsLiftedToNull); assert.ProductionHas(e1, o1 => o1.CanReduce == e1.CanReduce); assert.ProductionHas(e1, o1 => o1.Operand == replace[e2]); assert.ProductionHas(e1, o1 => o1.Method == e1.Method); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.ProductionHas(e1, o1 => o1.NodeType == e1.NodeType); assert.WasVisited(e2); assert.WasNotProduced(e2); assert.WasProduced(replace[e2]); assert.TotalVisits(2); assert.TotalProduced(2); }
public void Test009() { var mi = typeof(MethodCallData).GetMethod(nameof(MethodCallData.MethodFour)); var e2 = Expression.Default(typeof(int)); var e1 = Expression.Call(mi, e2); var replace = new Dictionary <Expression, Expression> { { e2, Expression.Default(typeof(int)) } }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.Object == null); assert.ProductionHas(e1, o1 => o1.Arguments.Count == e1.Arguments.Count); assert.ProductionHas(e1, o1 => o1.Arguments[0] == replace[e2]); assert.ProductionHas(e1, o1 => o1.Method == e1.Method); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(null, 1); assert.WasProduced(null, 1); assert.WasVisited(e2); assert.WasProduced(replace[e2]); assert.WasNotProduced(e2); assert.TotalVisits(3); assert.TotalProduced(3); }
public void Test004() { var mi = typeof(MethodCallData).GetMethod(nameof(MethodCallData.MethodThree)); var e2 = Expression.Default(typeof(MethodCallData)); var e3 = Expression.Parameter(typeof(int)); var e1 = Expression.Call(e2, mi, e3); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.ProductionHas(e1, o1 => o1.Object == e2); assert.ProductionHas(e1, o1 => o1.Arguments.Count == e1.Arguments.Count); assert.ProductionHas(e1, o1 => o1.Arguments[0] == e3); assert.ProductionHas(e1, o1 => o1.Method == e1.Method); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.TotalVisits(3); assert.TotalProduced(3); }
public void Test004() { var e2 = Expression.Default(typeof(int)); var e3 = Expression.Default(typeof(int)); var e4 = Expression.Default(typeof(int)); var e1 = Expression.Block(e2, e3, e4); var replace = new Dictionary <Expression, Expression> { { e2, Expression.Default(typeof(int)) } }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasNotProduced(e1); assert.ProductionHas(e1, o1 => o1.Expressions[0] == replace[e2]); assert.ProductionHas(e1, o1 => o1.Expressions[1] == e3); assert.ProductionHas(e1, o1 => o1.Expressions[2] == e4); assert.ProductionHas(e1, o1 => o1.Variables == null || o1.Variables.Count == 0); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(e2); assert.WasNotProduced(e2); assert.WasProduced(replace[e2]); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e4); assert.WasProduced(e4); assert.TotalVisits(4); assert.TotalProduced(4); }
public void Test006() { var e2 = Expression.Default(typeof(CustomIndexerData001)); var e3 = Expression.Default(typeof(int)); var e4 = Expression.Default(typeof(int)); var e5 = Expression.Default(typeof(int)); var prop = e2.Type.GetProperty("Item", new Type[] { typeof(int), typeof(int), typeof(int) }); var e1 = Expression.MakeIndex(e2, prop, new[] { e3, e4, e5 }); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e4); assert.WasProduced(e4); assert.WasVisited(e5); assert.WasProduced(e5); assert.TotalVisits(5); assert.TotalProduced(5); }
public static ExpressionVisitorVerifierTool Test(Expression exp, Dictionary <Expression, Expression> replace) { var visitor = new ExpressionVisitorVerifierTool(null, replace); visitor.Result = visitor.Visit(exp); return(visitor); }
public void Test011() { var varDefs = new[] { Expression.Parameter(typeof(int)) }; var e2 = Expression.Default(typeof(int)); var e3 = Expression.Default(typeof(int)); var e4 = Expression.Default(typeof(int)); var e1 = Expression.Block(varDefs, e2, e3, e4); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.ProductionHas(e1, o1 => o1.Expressions[0] == e2); assert.ProductionHas(e1, o1 => o1.Expressions[1] == e3); assert.ProductionHas(e1, o1 => o1.Expressions[2] == e4); assert.ProductionHas(e1, o1 => o1.Variables.Count == varDefs.Length); assert.ProductionHas(e1, o1 => o1.Variables[0] == varDefs[0]); assert.ProductionHas(e1, o1 => o1.Type == e1.Type); assert.WasVisited(varDefs[0]); assert.WasProduced(varDefs[0]); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e4); assert.WasProduced(e4); assert.TotalVisits(5); assert.TotalProduced(5); }
public void Test011() { var e1 = Expression.Constant(9, typeof(int)); var e2 = Expression.Parameter(typeof(Exception)); var e3 = Expression.Constant(10, typeof(int)); var e4 = Expression.Catch(e2, e3); var e6 = Expression.Constant(20, typeof(int)); var e5 = Expression.TryCatchFinally(e1, e6, e4); var assert = ExpressionVisitorVerifierTool.Test(e5); assert.WasVisited(e1); assert.WasProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e6); assert.WasProduced(e6); assert.WasVisited(e5); assert.WasProduced(e5); // fault and catch block filter assert.WasVisited(null, 2); assert.WasProduced(null, 2); assert.TotalVisits(7); assert.TotalProduced(7); }
public static ExpressionVisitorVerifierTool Test(Expression exp) { var visitor = new ExpressionVisitorVerifierTool(null, null); visitor.Result = visitor.Visit(exp); return(visitor); }
public void Test001() { var e1 = Expression.Default(typeof(int)); var e2 = Expression.Parameter(typeof(Exception)); var e3 = Expression.Constant(10, typeof(int)); var e4 = Expression.Catch(e2, e3); var e5 = Expression.TryCatch(e1, e4); var assert = ExpressionVisitorVerifierTool.Test(e5); assert.WasVisited(e1); assert.WasProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e5); assert.WasProduced(e5); // fault, finally, and catch block filter assert.WasVisited(null, 3); assert.WasProduced(null, 3); assert.TotalVisits(7); assert.TotalProduced(7); var cbResult = (TryExpression)assert.Result; Assert.AreEqual(cbResult.Handlers[0], e4); }
public void Test043() { var e1 = Expression.Constant(10, typeof(int)); var e2 = Expression.Parameter(typeof(Exception)); var e3 = Expression.Constant(11, typeof(int)); var e4 = Expression.Catch(e2, e3); var e6 = Expression.Parameter(typeof(NullReferenceException)); var e7 = Expression.Constant(13, typeof(int)); var e8 = Expression.Catch(e6, e7); var e10 = Expression.Parameter(typeof(AggregateException)); var e11 = Expression.Constant(15, typeof(int)); var e12 = Expression.Catch(e10, e11); var e12n = Expression.Catch(e10, e11); var e14 = Expression.TryCatch(e1, e4, e8, e12); var assert = ExpressionVisitorVerifierTool.Create(); assert.CatchBlockReplace.Add(e12, e12n); assert.Execute(e14); assert.WasVisited(e1); assert.WasProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e6); assert.WasProduced(e6); assert.WasVisited(e7); assert.WasProduced(e7); assert.WasVisited(e10); assert.WasProduced(e10); assert.WasVisited(e11); assert.WasProduced(e11); assert.WasVisited(e14); assert.WasNotProduced(e14); assert.WasProduced(assert.Result); // fault, finally, and 3x catch block filter assert.WasVisited(null, 5); assert.WasProduced(null, 5); assert.TotalVisits(13); assert.TotalProduced(13); var cbResult = (TryExpression)assert.Result; Assert.AreEqual(cbResult.Handlers[0], e4); Assert.AreEqual(cbResult.Handlers[1], e8); Assert.AreEqual(cbResult.Handlers[2], e12n); }
public void Test013() { var e1 = Expression.Constant(10, typeof(int)); var e2 = Expression.Parameter(typeof(Exception)); var e3 = Expression.Constant(11, typeof(int)); var e4 = Expression.Catch(e2, e3); var e6 = Expression.Parameter(typeof(NullReferenceException)); var e7 = Expression.Constant(13, typeof(int)); var e8 = Expression.Catch(e6, e7); var e10 = Expression.Parameter(typeof(AggregateException)); var e11 = Expression.Constant(15, typeof(int)); var e12 = Expression.Catch(e10, e11); var e13 = Expression.Constant(20, typeof(int)); var e14 = Expression.TryCatchFinally(e1, e13, e4, e8, e12); var assert = ExpressionVisitorVerifierTool.Test(e14); assert.WasVisited(e1); assert.WasProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.WasVisited(e3); assert.WasProduced(e3); assert.WasVisited(e6); assert.WasProduced(e6); assert.WasVisited(e7); assert.WasProduced(e7); assert.WasVisited(e10); assert.WasProduced(e10); assert.WasVisited(e11); assert.WasProduced(e11); assert.WasVisited(e13); assert.WasProduced(e13); assert.WasVisited(e14); assert.WasProduced(e14); // fault and 3x catch block filter assert.WasVisited(null, 4); assert.WasProduced(null, 4); assert.TotalVisits(13); assert.TotalProduced(13); }
public void Test001() { var e1 = Expression.Constant(null, typeof(object)); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.TotalVisits(1); assert.TotalProduced(1); }
public void Test001() { var e2 = Expression.Default(typeof(int)); var e1 = Expression.Block(e2); var assert = ExpressionVisitorVerifierTool.Test(e1); assert.WasVisited(e1); assert.WasProduced(e1); assert.WasVisited(e2); assert.WasProduced(e2); assert.TotalVisits(2); assert.TotalProduced(2); }
public void Test002() { var t1 = Expression.Label("testName"); var e1 = Expression.Goto(t1); var assert = ExpressionVisitorVerifierTool.Test(e1); assert.WasVisited(e1); assert.WasProduced(e1); assert.WasVisited(null); assert.WasProduced(null); assert.TotalVisits(2); assert.TotalProduced(2); }
public void Test003() { var e1 = Expression.Constant(Enumerable.Range(0, 2).Where(x => x > 1).AsQueryable(), typeof(IQueryable)); var replace = new Dictionary <Expression, Expression> { }; var assert = ExpressionVisitorVerifierTool.Test(e1, replace); assert.WasVisited(e1); assert.WasProduced(e1); assert.TotalVisits(1); assert.TotalProduced(1); }