Esempio n. 1
0
        public static void UnsafeTest()
        {
            var x = new IntWithAddMonoid(5);
            var y = new IntWithAddMonoid(7);

            Assert.Equal(0, Monoid.NeutralUnsafe <IntWithAddMonoid, IntWithAddMonoid>().Value);
            Assert.Equal(12, Monoid.OpUnsafe <IntWithAddMonoid, IntWithAddMonoid>()(x, y).Value);

            Assert.Equal(new GenericPerson <Info>("", new Info()), Monoid.NeutralUnsafe <GenericPerson <Info>, PersonMonoid <Info> >());
        }
Esempio n. 2
0
        public static void ImmutableListAppendMonoidTest_String()
        {
            var m = Monoid.ImmutableListAppend <string>();

            var xs = new List <string> {
            };
            var ys = new List <string> {
                "a", "b", "c"
            };
            var zs = new List <string> {
                "d", "a", "b"
            };

            Assert.Empty(m.Neutral);
            Assert.Empty(Monoid.NeutralUnsafe <IList <string>, Monoid.ListAppendImmutableMonoid <string> >());
            Assert.Equal(new string[] { "a", "b", "c", "d", "a", "b" }, Monoid.OpUnsafe <IList <string>, Monoid.ListAppendImmutableMonoid <string> >()(ys, zs));
            Assert.Equal(new string[] { "a", "b", "c" }, m.Op(xs, ys));
            Assert.Equal(new string[] { "a", "b", "c" }, m.Op(ys, xs));
            Assert.Equal(new string[] { "a", "b", "c", "d", "a", "b" }, m.Op(ys, zs));

            Assert.Empty(xs);
            Assert.Equal(new string[] { "a", "b", "c" }, ys);
            Assert.Equal(new string[] { "d", "a", "b" }, zs);
        }