예제 #1
0
파일: TestEach.cs 프로젝트: TzarIvan/ratel
        [Test] public void testEach()
        {
            var result = new List <string>();

            O.each(LETTERS, result.Add);
            AreEqual(LETTERS, result);
            result.Clear();
            O.eachIt(LETTERS, (i, s) => result.Add(i + " " + s));
            AreEqual(O.list("0 a", "1 b", "2 c"), result);
            int[] sum = { 0 };
            O.eachIt(START, delegate(int i, int val) { sum[0] += val + i; });
            AreEqual(sum[0], 21);
            sum[0] = 0;
            O.eachIt(O.list(7, 8, 9), delegate(int i, int val) { sum[0] += val * i; });
            AreEqual(sum[0], 26);
        }