HasVariable() публичный Метод

public HasVariable ( ) : bool
Результат bool
Пример #1
0
        public void CreateSimpleList()
        {
            Context context = new Context();
            var expr = new ListExpression(new IExpression[] { new ConstantExpression(1), new AtomExpression(new Atom("x")), new AtomExpression(new Atom("y")) });

            Assert.IsFalse(expr.HasVariable());

            var result = expr.Evaluate(context, true);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(List));

            var list = (List)result;

            Assert.IsNotNull(list.Head);
            Assert.IsNotNull(list.Tail);

            Assert.AreEqual("[1,x,y]", list.ToString());
        }
Пример #2
0
        public void RaiseWhenUnboundVariable()
        {
            Context context = new Context();
            var expr = new ListExpression(new IExpression[] { new ConstantExpression(1), new VariableExpression(new Variable("X")), new AtomExpression(new Atom("y")) });

            Assert.IsTrue(expr.HasVariable());

            try
            {
                expr.Evaluate(context, false);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("variable 'X' is unbound", ex.Message);
            }
        }