public static void CustomOpDecrement(Decrementable operand, Decrementable expected, bool useInterpreter) { Func <Decrementable> func = Expression.Lambda <Func <Decrementable> >( Expression.Decrement(Expression.Constant(operand))).Compile(useInterpreter); Assert.Equal(expected.Value, func().Value); }
public static void UserDefinedOpDecrement(Decrementable operand, Decrementable expected, bool useInterpreter) { MethodInfo method = typeof(IncrementDecrementTests).GetMethod(nameof(DoublyDecrement)); Func <Decrementable> func = Expression.Lambda <Func <Decrementable> >( Expression.Decrement(Expression.Constant(operand), method)).Compile(useInterpreter); Assert.Equal(expected.Value, func().Value); }
public static Decrementable DoublyDecrement(Decrementable operand) => new Decrementable(operand.Value - 2);
public static Decrementable DoublyDecrement(Decrementable operand) => new Decrementable(unchecked (operand.Value - 2));
public static void UserDefinedOpDecrement(Decrementable? operand, Decrementable? expected, bool useInterpreter) { MethodInfo method = typeof(IncrementDecrementTests).GetMethod(nameof(DoublyDecrement)); Func<Decrementable?> func = Expression.Lambda<Func<Decrementable?>>( Expression.Decrement(Expression.Constant(operand, typeof(Decrementable?)), method)).Compile(useInterpreter); Assert.Equal(expected, func()); }
public static void CustomOpDecrement(Decrementable? operand, Decrementable? expected, bool useInterpreter) { Func<Decrementable?> func = Expression.Lambda<Func<Decrementable?>>( Expression.Decrement(Expression.Constant(operand, typeof(Decrementable?)))).Compile(useInterpreter); Assert.Equal(expected, func()); }