Ejemplo n.º 1
0
        public Interpreter(IGenericHelper genericHelper, IFunctionHelper functionHelper,
                           IIntegerHelper integerHelper, IRealHelper realHelper,
                           IBooleanHelper booleanHelper, ISetHelper setHelper,
                           IElementHelper elementHelper, IStringHelper stringHelper,
                           IGraphHelper graphHelper, bool catchExceptions)
        {
            _catchExceptions = catchExceptions;
            _exceptions      = new ComponentException();
            _functionHelper  = functionHelper;

            _integerHelper = integerHelper;
            _integerHelper.SetInterpreter(this);

            _realHelper = realHelper;
            _realHelper.SetInterpreter(this);

            _booleanHelper = booleanHelper;
            _booleanHelper.SetInterpreter(this);

            _genericHelper = genericHelper;
            _genericHelper.SetInterpreter(this);

            _setHelper = setHelper;
            _setHelper.SetInterpreter(this);

            _elementHelper = elementHelper;
            _elementHelper.SetInterpreter(this);

            _stringHelper = stringHelper;
            _stringHelper.SetInterpreter(this);

            _graphHelper = graphHelper;
            _graphHelper.SetInterpreter(this);
        }
 public TypeChecker(IDeclarationHelper declarationHelper, INumberHelper numberHelper,
                    ICommonOperatorHelper commonOperatorHelper, IBooleanHelper booleanHelper, ISetHelper setHelper)
 {
     _declarationHelper    = declarationHelper;
     _numberHelper         = numberHelper;
     _commonOperatorHelper = commonOperatorHelper;
     _booleanHelper        = booleanHelper;
     _setHelper            = setHelper;
 }
Ejemplo n.º 3
0
        public static ITypeChecker GetTypeCheckerOnlyWith(IBooleanHelper booleanHelper)
        {
            IDeclarationHelper    declarationHelper    = Substitute.For <IDeclarationHelper>();
            ICommonOperatorHelper commonOperatorHelper = Substitute.For <ICommonOperatorHelper>();
            INumberHelper         numberHelper         = Substitute.For <INumberHelper>();
            ISetHelper            setHelper            = Substitute.For <ISetHelper>();

            return(new TypeChecker(declarationHelper, numberHelper, commonOperatorHelper, booleanHelper, setHelper));
        }
        private void DispatchBool_ReturnsCorrect(ExpressionNode node, IBooleanHelper boolHelper, bool expected)
        {
            var parameters  = GetParameterList();
            var interpreter = Utilities.GetIntepreterOnlyWith(boolHelper);

            var res = interpreter.DispatchBoolean(node, parameters);

            Assert.AreEqual(expected, res);
        }
        public void DispatchBool_ReturnsCorrect_Equal(bool expected)
        {
            var            node       = GetEqualExp();
            IBooleanHelper boolHelper = GetBooleanHelper();

            boolHelper.EqualBoolean(Arg.Any <EqualExpression>(), Arg.Any <List <object> >())
            .Returns(expected);

            DispatchBool_ReturnsCorrect(node, boolHelper, expected);
        }
Ejemplo n.º 6
0
        public static Interpreter GetIntepreterOnlyWith(IBooleanHelper booleanHelper)
        {
            IFunctionHelper functionHelper = Substitute.For <IFunctionHelper>();
            IIntegerHelper  integerHelper  = Substitute.For <IIntegerHelper>();
            IRealHelper     realHelper     = Substitute.For <IRealHelper>();
            IGenericHelper  genericHelper  = Substitute.For <IGenericHelper>();
            ISetHelper      setHelper      = Substitute.For <ISetHelper>();
            IElementHelper  elemHelper     = Substitute.For <IElementHelper>();
            IStringHelper   stringHelper   = Substitute.For <IStringHelper>();
            IGraphHelper    graphHelper    = Substitute.For <IGraphHelper>();

            return(new Interpreter(genericHelper, functionHelper, integerHelper, realHelper, booleanHelper, setHelper, elemHelper, stringHelper, graphHelper, false));
        }
        public void DispatchBool_Or_PassParametersDown(object o)
        {
            var parameters = GetParameterList();
            var node       = GetOrExp();

            IBooleanHelper boolHelper = GetBooleanHelper();
            List <object>  res        = null;

            boolHelper.OrBoolean(Arg.Any <OrExpression>(), Arg.Do <List <object> >(x => res = x))
            .Returns(true);

            var interpreter = Utilities.GetIntepreterOnlyWith(boolHelper);

            interpreter.DispatchBoolean(node, parameters.ToList());

            res.Should().BeEquivalentTo(parameters);
        }