WithCheckForOverflow() 공개 메소드

Sets whether the current context is checked.
public WithCheckForOverflow ( bool checkForOverflow ) : CSharpResolver
checkForOverflow bool
리턴 CSharpResolver
예제 #1
0
        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)));
        }
예제 #2
0
 public void TestUnaryMinusCheckedOverflow()
 {
     AssertError(typeof(int), resolver.WithCheckForOverflow(true).ResolveUnaryOperator(UnaryOperatorType.Minus, MakeConstant(-2147483648)));
 }
예제 #3
0
 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));
		}