public void AssignmentAnalyzer_Quote() { var x = Expression.Parameter(typeof(int)); var b = Expression.Block( new[] { x }, Expression.Quote(Expression.Lambda <Func <int> >(x)) ); var analyze = new AssignmentAnalyzer(b.Variables); var res = analyze.Visit(b.Expressions); Assert.AreSame(b.Expressions, res); Assert.AreEqual(0, analyze.Unassigned.Count); }
public void AssignmentAnalyzer_RuntimeVariables() { var x = Expression.Parameter(typeof(int)); var b = Expression.Block( new[] { x }, Expression.RuntimeVariables(x) ); var analyze = new AssignmentAnalyzer(b.Variables); var res = analyze.Visit(b.Expressions); Assert.AreSame(b.Expressions, res); Assert.AreEqual(0, analyze.Unassigned.Count); }
public void AssignmentAnalyzer_Unassigned() { var x = Expression.Parameter(typeof(int)); var b = Expression.Block( new[] { x }, x ); var analyze = new AssignmentAnalyzer(b.Variables); var res = analyze.Visit(b.Expressions); Assert.AreSame(b.Expressions, res); Assert.IsTrue(new[] { x }.SequenceEqual(analyze.Unassigned)); }
public void AssignmentAnalyzer_Assign() { var x = Expression.Parameter(typeof(int)); var b = Expression.Block( new[] { x }, Expression.Constant(0), Expression.Assign(x, Expression.Constant(1)), Expression.Constant(2) ); var analyze = new AssignmentAnalyzer(b.Variables); var res = analyze.Visit(b.Expressions); Assert.AreSame(b.Expressions, res); Assert.AreEqual(0, analyze.Unassigned.Count); }
public void AssignmentAnalyzer_ByRef() { var read = typeof(Volatile).GetMethod(nameof(Volatile.Read), new[] { typeof(int).MakeByRefType() }); var x = Expression.Parameter(typeof(int)); var b = Expression.Block( new[] { x }, Expression.Constant(0), Expression.Call(read, x), Expression.Constant(2) ); var analyze = new AssignmentAnalyzer(b.Variables); var res = analyze.Visit(b.Expressions); Assert.AreSame(b.Expressions, res); Assert.AreEqual(0, analyze.Unassigned.Count); }