Ejemplo n.º 1
0
        public void ReaderSelectTest()
        {
            var m11   = new MonadPrimus.Reader <string, int>(x => int.Parse(x) + 1);
            var m12   = m11.Select(x => x.ToString() + "2");
            var res11 = m12.RunReader("1");

            Assert.AreEqual("22", res11);
        }
Ejemplo n.º 2
0
        public void ReaderSelectManyTest01()
        {
            var m11   = new MonadPrimus.Reader <string, int>(x => int.Parse(x) + 1);
            var m12   = m11.SelectMany(x => new MonadPrimus.Reader <string, string>(s => x + s));
            var res11 = m12.RunReader("1");

            Assert.AreEqual("21", res11);
        }
Ejemplo n.º 3
0
        public void ReaderMonadRule2Test()
        {
            var m00   = new MonadPrimus.Reader <string, int>(x => int.Parse(x) + 1);
            var m11   = m00.SelectMany(MonadPrimus.ToReader <string, int>);
            var m12   = m00;
            var res11 = m11.RunReader("1");
            var res12 = m12.RunReader("1");

            Assert.AreEqual(2, res11);
            Assert.AreEqual(2, res12);
        }
Ejemplo n.º 4
0
        public void ReaderLocalTest()
        {
            var m11 = new MonadPrimus.Reader <string, int>(x => int.Parse(x) + 1);
            var m12 = MonadPrimus.Reader <string, int> .Local(x => x + x, m11);

            var m13 = MonadPrimus.Reader <string, int> .Local(x => x + x);

            var res11 = m12.RunReader("1");
            var res12 = m13(m11).RunReader("1");

            Assert.AreEqual(12, res11);
            Assert.AreEqual(12, res12);
        }