예제 #1
0
파일: LazyTest.cs 프로젝트: Eyas/Ibra
        public static void LazyFunc_ManyInputs_Simple()
        {
            LazyFunc<int, int, int> adder = new LazyFunc<int, int, int>((a, b) => a + b);

            Assert.Equal(adder.Get(0, 0), 0);
            Assert.Equal(adder.Get(1, 0), 1);
            Assert.Equal(adder.Get(0, 1), 1);
            Assert.Equal(adder.Get(5, 3), 8);
            Assert.Equal(adder.Get(3, 5), 8);
        }
예제 #2
0
        public static void LazyFunc_ManyInputs_Simple()
        {
            LazyFunc <int, int, int> adder = new LazyFunc <int, int, int>((a, b) => a + b);

            Assert.Equal(adder.Get(0, 0), 0);
            Assert.Equal(adder.Get(1, 0), 1);
            Assert.Equal(adder.Get(0, 1), 1);
            Assert.Equal(adder.Get(5, 3), 8);
            Assert.Equal(adder.Get(3, 5), 8);
        }
예제 #3
0
파일: LazyTest.cs 프로젝트: Eyas/Ibra
        public static void LazyFunc_ManyInputs_ThrowingRecursive()
        {
            LazyFunc<int, int, int> adder = null;
            adder = new LazyFunc<int, int, int>((a, b) => adder.Get(b, a));

            Assert.Throws<System.InvalidOperationException>(() => adder.Get(0, 0));
            Assert.Throws<System.InvalidOperationException>(() => adder.Get(1, 0));
            Assert.Throws<System.InvalidOperationException>(() => adder.Get(0, 1));
            Assert.Throws<System.InvalidOperationException>(() => adder.Get(5, 3));
            Assert.Throws<System.InvalidOperationException>(() => adder.Get(3, 5));
        }
예제 #4
0
        public static void LazyFunc_ManyInputs_ThrowingRecursive()
        {
            LazyFunc <int, int, int> adder = null;

            adder = new LazyFunc <int, int, int>((a, b) => adder.Get(b, a));

            Assert.Throws <System.InvalidOperationException>(() => adder.Get(0, 0));
            Assert.Throws <System.InvalidOperationException>(() => adder.Get(1, 0));
            Assert.Throws <System.InvalidOperationException>(() => adder.Get(0, 1));
            Assert.Throws <System.InvalidOperationException>(() => adder.Get(5, 3));
            Assert.Throws <System.InvalidOperationException>(() => adder.Get(3, 5));
        }
예제 #5
0
파일: LazyTest.cs 프로젝트: Eyas/Ibra
        public static void LazyFunc_ManyInputs_SafeRecursive()
        {
            LazyFunc<int, int, int> adder = null;
            adder = new LazyFunc<int, int, int>((a, b) =>
            {
                if (a < b) return adder.Get(b, a);
                return a + b;
            });

            Assert.Equal(adder.Get(0, 0), 0);
            Assert.Equal(adder.Get(1, 0), 1);
            Assert.Equal(adder.Get(0, 1), 1);
            Assert.Equal(adder.Get(5, 3), 8);
            Assert.Equal(adder.Get(3, 5), 8);
        }
예제 #6
0
        public static void LazyFunc_ManyInputs_SafeRecursive()
        {
            LazyFunc <int, int, int> adder = null;

            adder = new LazyFunc <int, int, int>((a, b) =>
            {
                if (a < b)
                {
                    return(adder.Get(b, a));
                }
                return(a + b);
            });

            Assert.Equal(adder.Get(0, 0), 0);
            Assert.Equal(adder.Get(1, 0), 1);
            Assert.Equal(adder.Get(0, 1), 1);
            Assert.Equal(adder.Get(5, 3), 8);
            Assert.Equal(adder.Get(3, 5), 8);
        }