예제 #1
0
 public Set DispatchSet(ExpressionNode node, List <Object> parameters)
 {
     return(node switch
     {
         SetExpression e => _setHelper.SetExpression(e, parameters),
         UnionExpression e => _setHelper.UnionSet(e, parameters),
         IntersectionExpression e => _setHelper.IntersectionSet(e, parameters),
         SubtractionExpression e => _setHelper.SubtractionSet(e, parameters),
         IdentifierExpression e => _genericHelper.Identifier <Set>(e, parameters),
         FunctionCallExpression e => _genericHelper.FunctionCall <Set>(e, parameters),
         VerticesGraphField e => _setHelper.VerticesField(e, parameters),
         EdgesGraphField e => _setHelper.EdgesField(e, parameters),
         EmptySetLiteralExpression e => _setHelper.EmptySetLiteral(e, parameters),
         _ => throw new UnimplementedInterpreterException(node, "DispatctSet")
     });
예제 #2
0
        public void DispatchInteger_FunctionCallAndObjectList_CorrectValueReturned()
        {
            int expected = 17;
            FunctionCallExpression input1 = new FunctionCallExpression("", null, 0, 0);
            List <Object>          input2 = new List <Object>()
            {
                23, 2.334, null
            };
            IGenericHelper ihelper     = Substitute.For <IGenericHelper>();
            Interpreter    interpreter = Utilities.GetIntepreterOnlyWith(ihelper);

            ihelper.FunctionCall <int>(Arg.Any <FunctionCallExpression>(), Arg.Any <List <Object> >()).Returns(expected);

            int res = interpreter.DispatchInt(input1, input2);

            Assert.AreEqual(expected, res);
        }
예제 #3
0
        public void DispatchInteger_FunctionCallAndObjectList_CorrectListPassed()
        {
            List <Object> expected = new List <Object>()
            {
                23, 2.334, null
            };
            FunctionCallExpression input1      = new FunctionCallExpression("", null, 0, 0);
            IGenericHelper         ihelper     = Substitute.For <IGenericHelper>();
            Interpreter            interpreter = Utilities.GetIntepreterOnlyWith(ihelper);
            List <Object>          res         = null;

            ihelper.FunctionCall <int>(Arg.Any <FunctionCallExpression>(), Arg.Do <List <Object> >(x => res = x));

            interpreter.DispatchInt(input1, expected);

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