Пример #1
0
        public void TestVisitLambdaPredicateNode_CheckLambdaPredicateGeneration_ReturnsLambdaPredicate(E_LOGIC_OP_TYPE type, int x, int value, bool res)
        {
            IVisitor <Object> interpreter = new CInterpreter();

            Func <int, bool> lambdaPredicate = null;

            Assert.DoesNotThrow(() => {
                lambdaPredicate = (Func <int, bool>)interpreter.VisitLambdaPredicateNode(
                    new CLambdaPredicateASTNode(type, new CValueASTNode(new int[] { value }), null));
            });

            Assert.AreEqual(res, lambdaPredicate(x));
        }
Пример #2
0
        public void TestVisitLambdaPredicateNode_CheckModuloComparisonLambdaPredicate_ReturnsLambdaPredicate(int x, int value, int secondOp, bool res)
        {
            IVisitor <Object> interpreter = new CInterpreter();

            Func <int, bool> lambdaPredicate = null;

            Assert.DoesNotThrow(() => {
                lambdaPredicate = (Func <int, bool>)interpreter.VisitLambdaPredicateNode(
                    new CLambdaPredicateASTNode(E_LOGIC_OP_TYPE.LOT_MOD, new CValueASTNode(new int[] { value }),
                                                new CValueASTNode(new int[] { secondOp })));
            });

            Assert.AreEqual(res, lambdaPredicate(x));
        }