public void CanBuildFnStatements()
        {
            repository.ReplayAll();

            var eProcessor = new ExpressionProcessor();
            PushFxOfPowX2(eProcessor);

            var stackVal = eProcessor.Pop().ToString();
            Assert.AreEqual("f(x) = ((x^2) * t)", stackVal);

            repository.VerifyAll();
        }
        public void Input_4_5_x_add_eval_returns_9()
        {
            repository.ReplayAll();

            var eProcessor = new ExpressionProcessor();
            eProcessor.Push(new DoubleExpression(4));
            eProcessor.Push(new DoubleExpression(5));
            eProcessor.Push(new StringExpression("x"));
            eProcessor.Eval(StackOpExpression.Add);
            eProcessor.Eval((IFuncExpression)VIMExpression.FromString("eval"));
            var expr = eProcessor.Pop();

            Assert.IsInstanceOfType(typeof(INumericExpression), expr);
            var numExpr = (INumericExpression)expr;

            Assert.AreEqual(9, numExpr.dVal);

            repository.VerifyAll();
        }
        public void InputEvalsLargeExpressions()
        {
            repository.ReplayAll();

            var eProcessor = new ExpressionProcessor();
            eProcessor.Push(new DoubleExpression(2));
            eProcessor.Push(new StringExpression("x"));
            eProcessor.Push(new DoubleExpression(3));
            eProcessor.Eval(StackOpExpression.Power);
            eProcessor.Push(new DoubleExpression(3));
            eProcessor.Eval(StackOpExpression.Multiply);
            eProcessor.Push(new DoubleExpression(5));
            eProcessor.Eval(StackOpExpression.Add);
            eProcessor.Eval((IFuncExpression)VIMExpression.FromString("eval"));
            var expr = eProcessor.Pop();
            var numExpr = (INumericExpression) expr;

            Assert.AreEqual(29, numExpr.dVal);

            repository.VerifyAll();
        }
        public void Input_x_2_pow_t_mul_1_evals_to_4_when_t_is_4()
        {
            repository.ReplayAll();

            var eProcessor = new ExpressionProcessor();
            eProcessor.Push(new DoubleExpression(4));
            eProcessor.Push(new StringExpression("t"));
            eProcessor.Eval((IFuncExpression)VIMExpression.FromString("sto"));
            eProcessor.Push(new DoubleExpression(2));
            PushFxOfPowX2(eProcessor);

            eProcessor.Eval((IFuncExpression)VIMExpression.FromString("eval"));
            //might need some sort of context eval

            var stackVal = eProcessor.Pop().ToString();
            Assert.AreEqual("16", stackVal);

            repository.VerifyAll();
        }
        public void ProperlyHandlesMultipleInstancesOfOneVariable()
        {
            repository.ReplayAll();

            var eProcessor = new ExpressionProcessor();
            eProcessor.Push(new DoubleExpression(2));

            eProcessor.Push(new StringExpression("x"));
            eProcessor.Push(new DoubleExpression(3));
            eProcessor.Eval(StackOpExpression.Power);

            eProcessor.Push(new StringExpression("x"));
            eProcessor.Push(new DoubleExpression(2));
            eProcessor.Eval(StackOpExpression.Power);

            eProcessor.Eval(StackOpExpression.Add);
            eProcessor.Eval((IFuncExpression)VIMExpression.FromString("eval"));

            var expr = eProcessor.Pop();
            var numExpr = (INumericExpression) expr;

            Assert.AreEqual(12, numExpr.dVal);

            repository.VerifyAll();
        }