public WithCheckForOverflow ( bool checkForOverflow ) : CSharpResolver | ||
checkForOverflow | bool | |
return | CSharpResolver |
public void AdditionWithOverflow() { AssertConstant(int.MinValue, resolver.WithCheckForOverflow(false).ResolveBinaryOperator( BinaryOperatorType.Add, MakeConstant(int.MaxValue), MakeConstant(1))); AssertError(typeof(int), resolver.WithCheckForOverflow(true).ResolveBinaryOperator( BinaryOperatorType.Add, MakeConstant(int.MaxValue), MakeConstant(1))); }
public void TestUnaryMinusCheckedOverflow() { AssertError(typeof(int), resolver.WithCheckForOverflow(true).ResolveUnaryOperator(UnaryOperatorType.Minus, MakeConstant(-2147483648))); }
public void OverflowingCast() { AssertConstant(uint.MaxValue, resolver.WithCheckForOverflow(false).ResolveCast(ResolveType(typeof(uint)), MakeConstant(-1.6))); AssertError(typeof(uint), resolver.WithCheckForOverflow(true).ResolveCast(ResolveType(typeof(uint)), MakeConstant(-1.6))); }
public override ResolveResult Resolve(CSharpResolver resolver) { return expression.Resolve(resolver.WithCheckForOverflow(checkForOverflow)); }