public void DynamicUnaryOperation()
        {
            dynamic d = new NegatableNum(23);
            dynamic r = -d;

            Assert.Equal(-23, r.Value);
            d = new NegatableNum(int.MinValue);
            r = -d;
            Assert.Equal(int.MinValue, r.Value);
        }
            public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
            {
                if (binder.Operation == ExpressionType.Negate)
                {
                    result = new NegatableNum(unchecked (-Value));
                    return(true);
                }

                result = null;
                return(false);
            }
        public void DynamicUnaryOperationNotSupported()
        {
            dynamic d = new NegatableNum(23);

            Assert.Throws <RuntimeBinderException>(() => ~d);
        }
Exemple #4
0
 public void DynamicUnaryOperationNotSupported()
 {
     dynamic d = new NegatableNum(23);
     Assert.Throws<RuntimeBinderException>(() => ~d);
 }
Exemple #5
0
 public void DynamicUnaryOperation()
 {
     dynamic d = new NegatableNum(23);
     dynamic r = -d;
     Assert.Equal(-23, r.Value);
     d = new NegatableNum(int.MinValue);
     r = -d;
     Assert.Equal(int.MinValue, r.Value);
 }
Exemple #6
0
            public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
            {
                if (binder.Operation == ExpressionType.Negate)
                {
                    result = new NegatableNum(unchecked(-Value));
                    return true;
                }

                result = null;
                return false;
            }