public void ParseDelegateTest_Other() { { string code = @"()=>new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 }.Member1 == 3 ? new Test_Zhucai.LambdaParser.TestClass[] { new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 } }[4-4].Member1 + 3 * new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5 }.Member2 : new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5, Member1 = 9, }.GetMemberAll();"; int expected = new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 }.Member1 == 3 ? new Test_Zhucai.LambdaParser.TestClass[] { new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 } }[4 - 4].Member1 + 3 * new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5 }.Member2 : new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5, Member1 = 9, }.GetMemberAll(); Func <int> func = ExpressionParser.Compile <Func <int> >(code); int actual = func(); Assert.AreEqual(expected, actual); } { string code = @"()=>new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 }.Member1 != 3 ? new Test_Zhucai.LambdaParser.TestClass[] { new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 } }[new Test_Zhucai.LambdaParser.TestClass().Member1].Member1 + 3 * new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5 }.Member2 : new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5, Member1 = 9, }.GetMemberAll();"; int expected = new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 }.Member1 != 3 ? new Test_Zhucai.LambdaParser.TestClass[] { new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 } }[new Test_Zhucai.LambdaParser.TestClass().Member1].Member1 + 3 * new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5 }.Member2 : new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5, Member1 = 9, }.GetMemberAll(); Func <int> func = ExpressionParser.Compile <Func <int> >(code); int actual = func(); Assert.AreEqual(expected, actual); } }
public void ParseDelegateTest_Other() { { string code = @"()=>new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 }.Member1 == 3 ? new Test_Zhucai.LambdaParser.TestClass[] { new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 } }[4-4].Member1 + 3 * new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5 }.Member2 : new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5, Member1 = 9, }.GetMemberAll();"; int expected = new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 }.Member1 == 3 ? new Test_Zhucai.LambdaParser.TestClass[] { new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 } }[4 - 4].Member1 + 3 * new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5 }.Member2 : new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5, Member1 = 9, }.GetMemberAll(); Func<int> func = ExpressionParser.Compile<Func<int>>(code); int actual = func(); Assert.AreEqual(expected, actual); } { string code = @"()=>new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 }.Member1 != 3 ? new Test_Zhucai.LambdaParser.TestClass[] { new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 } }[new Test_Zhucai.LambdaParser.TestClass().Member1].Member1 + 3 * new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5 }.Member2 : new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5, Member1 = 9, }.GetMemberAll();"; int expected = new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 }.Member1 != 3 ? new Test_Zhucai.LambdaParser.TestClass[] { new Test_Zhucai.LambdaParser.TestClass() { Member1 = 3 } }[new Test_Zhucai.LambdaParser.TestClass().Member1].Member1 + 3 * new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5 }.Member2 : new Test_Zhucai.LambdaParser.TestClass() { Member2 = 5, Member1 = 9, }.GetMemberAll(); Func<int> func = ExpressionParser.Compile<Func<int>>(code); int actual = func(); Assert.AreEqual(expected, actual); } }