コード例 #1
0
        public void TestFunctionK()
        {
            var zero = new FunctionZero();
            var one = new FunctionSucc().exec(zero);
            var two = new FunctionDbl().exec(one);
            var four = new FunctionDbl().exec(two);

            var Kpart = new FunctionK().exec(four);
            Assert.AreEqual(false, Kpart.isDigit());

            var final = Kpart.exec(two);

            Assert.AreEqual(true, final.isDigit());
            Assert.AreEqual(4, (final as Digit).digit);
        }
コード例 #2
0
        public void TestFunctionS()
        {
            var eng = new Engine.BaseTypes.Engine(0);

            var cell = eng.getPlayerCells()[2];
            cell.setValue(new FunctionDbl());

            var zero = new FunctionZero();
            var one = new FunctionSucc().exec(zero);
            var two = new FunctionDbl().exec(one);

            var g = new FunctionDbl();

            var f = new FunctionGet();

            var part1 = new FunctionS().exec(f);
            var part2 = part1.exec(g);
            var res = part2.exec(two);

            Assert.AreEqual(true, res.isDigit());
            Assert.AreEqual(8, (res as Digit).digit);
        }
コード例 #3
0
        public void TestFunctionsComposition()
        {
            var zero = new FunctionZero();
            var succ = new FunctionSucc();

            var res = succ.exec(zero);
            var idn = new FunctionI().exec(res);
            var dubl = new FunctionDbl().exec(idn);

            Assert.AreEqual(1, (res as Digit).digit);
            Assert.AreEqual(1, (idn as Digit).digit);
            Assert.AreEqual(2, (dubl as Digit).digit);
        }
コード例 #4
0
        public void TestFunctionsSuccAndDbl()
        {
            var funf = new Digit(5);
            var succ = new FunctionSucc();
            var res = succ.exec(funf);

            Assert.AreEqual(true, res.isDigit());
            Assert.AreEqual(6, (res as Digit).digit);

            var dbl = new FunctionDbl();
            var res2 = dbl.exec(funf);

            Assert.AreEqual(true, res2.isDigit());
            Assert.AreEqual(10, (res2 as Digit).digit);
        }