Пример #1
0
        public void TestPairs()
        {
            NumValue valueTwo = new NumValue(2);
            Value    pair     = new PairValue <NumValue, NumValue>(valueTwo, valueTwo);

            Assert.AreEqual("< 2 , 2 >", pair.ToString());

            Expression test = new PairExpression <NumExpression, NumExpression>(two, two);

            Assert.AreEqual("< 2 , 2 >", testAsync(test, 500).Result);

            var trueTest = new PairExpression <LogicExpression, LogicExpression>(logicTrue, logicTrue);

            Assert.AreEqual("< True , True >", testAsync(trueTest, 500).Result);

            var loopTest = new PairExpression <LogicExpression, LogicExpression>(logicLoop, logicTrue);

            Assert.AreEqual(False, testAsync(loopTest, 500).Result);

            var pairTest = new LogicProjL(trueTest);

            Assert.AreEqual(True, testAsync(pairTest, 500).Result);

            var pairLoop = new LogicProjR(loopTest);

            Assert.AreEqual(True, testAsync(pairLoop, 500).Result);

            var pairLoop2 = new LogicProjL(loopTest);

            Assert.AreEqual(Loop, testAsync(pairLoop2, 500).Result);
        }
Пример #2
0
 public T Visit <A, B>(PairExpression <A, B> expression)
     where A : Expression
     where B : Expression
 {
     expression.Left.Accept(this);
     expression.Right.Accept(this);
     return(default(T));
 }
Пример #3
0
        public Expression Visit <A, B>(PairExpression <A, B> expression)
            where A : Expression
            where B : Expression
        {
            var left  = (A)expression.Left.Accept(this);
            var right = (B)expression.Right.Accept(this);

            return(new PairExpression <A, B>(left, right));
        }
        public SortedSet <string> Visit <A, B>(PairExpression <A, B> expression)
            where A : Expression
            where B : Expression
        {
            var vars = Run(expression.Left);

            vars.UnionWith(Run(expression.Right));
            return(vars);
        }
Пример #5
0
        public async Task <Value> Visit <A, B>(PairExpression <A, B> expression)
            where A : Expression
            where B : Expression
        {
            // Don't actually do these, let someone else do them
            var left  = expression.Left.Accept(this);
            var right = expression.Right.Accept(this);

            return(new PotentialPairValue <Value, Value>(left, right));
        }
Пример #6
0
        public void TestString()
        {
            var step2   = x & m <= new NumConstant(5);
            var rec2    = new RecLogicExpression(n, logicTrue, "m", "x", step2);
            var testLog = new NumConstant(6) == new NumThe("n", n > new NumConstant(5) & rec2);

            Assert.AreEqual("(6 == The n. ((n > 5) & Rec(n, True, m.x. (x & (m <= 5)))))", testLog.ToString());

            var test5 = new Apply(new LambdaExpression("x", x | logicTrue), logicLoop);

            Assert.AreEqual("(Lambda x. (x | True) @ Exists n. (n < n))", test5.ToString());

            var loopTest = new PairExpression <LogicExpression, LogicExpression>(logicLoop, logicTrue);
            var pairLoop = new LogicProjR(loopTest);

            Assert.AreEqual("Snd <Exists n. (n < n), True>", pairLoop.ToString());
        }