Beispiel #1
0
        [Test] public void Bind_Predicate()
        {
            Functional.UnaryPredicate <int> func1 = Functional.Bind1stPred(Functional.LessThan <int>, 29);
            Assert.IsFalse(func1(12)); // 29 < 12 == false;
            Assert.IsTrue(func1(30));  // 29 < 30 == true;
            Assert.IsFalse(func1(29)); // 29 < 29 == false;

            Functional.UnaryPredicate <int> func2 = Functional.Bind2ndPred(Functional.LessThan <int>, 29);
            Assert.IsTrue(func2(12));  // 12 < 29 == true;
            Assert.IsFalse(func2(30)); // 30 < 12 == false;
            Assert.IsFalse(func2(29)); // 29 < 29 == false;
        }
Beispiel #2
0
        [Test] public void Not_Predicate()
        {
            Functional.UnaryPredicate <int> func1 = Functional.Not1Pred(Functional.Bind1stPred(Functional.LessThan <int>, 29));
            Assert.IsTrue(func1(12));  // !(29 < 12) == false;
            Assert.IsFalse(func1(30)); // !(29 < 30) == true;
            Assert.IsTrue(func1(29));  // !(29 < 29) == false;

            Functional.BinaryPredicate <int> func2 = Functional.Not2Pred <int>(Functional.LessThan <int>);
            Assert.IsFalse(func2(12, 29)); // !(29 < 12) == false;
            Assert.IsTrue(func2(30, 29));  // !(29 < 30) == true;
            Assert.IsTrue(func2(29, 29));  // !(29 < 29) == false;
        }