コード例 #1
0
        public void TestUnrollingWithHigherIndexThanZero()
        {
            SourceCode           source          = new SourceCode("abc123");
            SourceTransformation transformation1 = new SourceTransformation(new SourceContext(2, 3), n => "2");
            SourceTransformation transformation2 = new SourceTransformation(new SourceContext(3, 1), n => "3");
            var unrolled = SourceFormatter.UnrollNested(new[] { transformation1, transformation2 }).ToArray();

            Assert.IsNotNull(unrolled);
            Assert.AreEqual(unrolled.Length, 3);
            Assert.AreEqual(unrolled[0].Context, new SourceContext(2, 1));
            Assert.AreEqual(unrolled[1].Context, new SourceContext(3, 1));
            Assert.AreEqual(unrolled[2].Context, new SourceContext(4, 1));
        }
コード例 #2
0
        public void TestUnrolling()
        {
            SourceCode           source               = new SourceCode("abc123");
            SourceTransformation transformation       = new SourceTransformation(new SourceContext(0, 4), n => "a");
            SourceTransformation transformationNested = new SourceTransformation(new SourceContext(1, 1), n => "b");
            var unrolled = SourceFormatter.UnrollNested(new[] { transformation, transformationNested }).ToArray();

            Assert.IsNotNull(unrolled);
            Assert.AreEqual(unrolled.Length, 4);
            Assert.AreEqual(unrolled[0].Context, new SourceContext(0, 1));
            Assert.AreEqual(unrolled[1].Context, new SourceContext(1, 1));
            Assert.AreEqual(unrolled[2].Context, new SourceContext(2, 1));
            Assert.AreEqual(unrolled[3].Context, new SourceContext(3, 1));
        }