예제 #1
0
        public void CloneTest()
        {
            var exp   = new SubAssign(Variable.X, new Number(2));
            var clone = exp.Clone();

            Assert.Equal(exp, clone);
        }
예제 #2
0
        public void BoolSubNumberTest()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", true)
            };
            var add = new SubAssign(Variable.X, new Number(2));

            Assert.Throws <NotSupportedException>(() => add.Execute(parameters));
        }
예제 #3
0
        public void SubAssignCalc()
        {
            var parameters = new ParameterCollection()
            {
                new Parameter("x", 10)
            };
            var sub      = new SubAssign(Variable.X, new Number(2));
            var result   = sub.Execute(parameters);
            var expected = 8.0;

            Assert.Equal(expected, result);
            Assert.Equal(expected, parameters["x"]);
        }
예제 #4
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>
 /// The result of analysis.
 /// </returns>
 /// <exception cref="System.NotSupportedException">Always.</exception>
 public virtual TResult Analyze(SubAssign exp)
 {
     throw new NotSupportedException();
 }
예제 #5
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>The result of analysis.</returns>
 public string Analyze(SubAssign exp)
 {
     return(ToString(exp, "{0} -= {1}"));
 }
예제 #6
0
        public void SubAssignToString()
        {
            var exp = new SubAssign(Variable.X, new Number(5));

            Assert.Equal("x -= 5", exp.ToString(commoonFormatter));
        }
예제 #7
0
        public void TestSubAssignException()
        {
            var exp = new SubAssign(Variable.X, new Bool(false));

            TestException(exp);
        }
예제 #8
0
        public void TestSubAssignNumber()
        {
            var exp = new SubAssign(Variable.X, new Number(10));

            Test(exp, ResultType.Number);
        }
예제 #9
0
        public void TestSubAssignUndefined()
        {
            var exp = new SubAssign(Variable.X, Variable.X);

            Test(exp, ResultType.Undefined);
        }