예제 #1
0
        public void MAppendAssociativity()
        {
            // x <> (y <> z) = (x <> y) <> z
            var x       = new ListMonoid <int>(1, 2, 3);
            var y       = new ListMonoid <int>(4, 5, 6);
            var z       = new ListMonoid <int>(7, 8, 9);
            var actual1 = x.MAppend(y.MAppend(z));
            var actual2 = x.MAppend(y).MAppend(z);

            Assert.That(actual1.List, Is.EqualTo(actual2.List));
        }
예제 #2
0
        public void MAppendOfXAndMEmptyIsX()
        {
            // x <> mempty = x
            var x      = new ListMonoid <int>(1, 2, 3);
            var actual = x.MAppend(ListMonoid.MEmpty <int>());

            Assert.That(actual.List, Is.EqualTo(x.List));
        }
예제 #3
0
        public void MAppend()
        {
            var lm1    = new ListMonoid <int>(1, 2, 3);
            var lm2    = new ListMonoid <int>(4, 5, 6);
            var actual = lm1.MAppend(lm2);

            Assert.That(actual.List, Is.EqualTo(new[] { 1, 2, 3, 4, 5, 6 }));
        }