private static void VerifyStructWithStringAndFieldConstant(Scs value, bool useInterpreter) { Expression <Func <Scs> > e = Expression.Lambda <Func <Scs> >( Expression.Constant(value, typeof(Scs)), Enumerable.Empty <ParameterExpression>()); Func <Scs> f = e.Compile(useInterpreter); Assert.Equal(value, f()); }
private static void VerifyStructWithStringAndFieldCoalesce(Scs?a, Scs b, bool useInterpreter) { Expression <Func <Scs> > e = Expression.Lambda <Func <Scs> >( Expression.Coalesce( Expression.Constant(a, typeof(Scs?)), Expression.Constant(b, typeof(Scs))), Enumerable.Empty <ParameterExpression>()); Func <Scs> f = e.Compile(useInterpreter); Assert.Equal(a ?? b, f()); }
public static void CheckStructWithStringAndFieldCoalesceTest(bool useInterpreter) { Scs?[] array1 = new Scs?[] { null, default(Scs), new Scs(), new Scs(null, new S()) }; Scs[] array2 = new Scs[] { default(Scs), new Scs(), new Scs(null, new S()) }; for (int i = 0; i < array1.Length; i++) { for (int j = 0; j < array2.Length; j++) { VerifyStructWithStringAndFieldCoalesce(array1[i], array2[j], useInterpreter); } } }
private static void VerifyStructWithStringAndField(bool condition, Scs a, Scs b, bool useInterpreter) { Expression <Func <Scs> > e = Expression.Lambda <Func <Scs> >( Expression.Condition( Expression.Constant(condition, typeof(bool)), Expression.Constant(a, typeof(Scs)), Expression.Constant(b, typeof(Scs))), Enumerable.Empty <ParameterExpression>()); Func <Scs> f = e.Compile(useInterpreter); Assert.Equal(condition ? a : b, f()); }
private static void VerifyWithParameterStructWithStringAndField(Scs value) { ConstructorInfo constructor = typeof(Scs?).GetConstructor(new Type[] { typeof(Scs) }); Expression[] exprArgs = new Expression[] { Expression.Constant(value, typeof(Scs)) }; Expression <Func <Scs?> > e = Expression.Lambda <Func <Scs?> >( Expression.New(constructor, exprArgs), Enumerable.Empty <ParameterExpression>()); Func <Scs?> f = e.Compile(); Assert.Equal(new Scs?(value), f()); }
public static void CheckTernaryStructWithStringAndFieldTest(bool useInterpreter) { bool[] array1 = new bool[] { false, true }; Scs[] array2 = new Scs[] { default(Scs), new Scs(), new Scs(null, new S()) }; for (int i = 0; i < array1.Length; i++) { for (int j = 0; j < array2.Length; j++) { for (int k = 0; k < array2.Length; k++) { VerifyStructWithStringAndField(array1[i], array2[j], array2[k], useInterpreter); } } } }