예제 #1
0
        public void TextAndExpressionInterleaved()
        {
            var line = Tools.CreateFileLine(@"\A#{B}C#{D}E", 0);
            var rule = new InterpolationRule();
            List <AsbtractRenderCommand> fragments = rule.Parse(line, new NullMessageHandler());

            Assert.AreEqual(6, fragments.Count);
            Assert.AreEqual(RenderCommandTypes.TargetIndentation, fragments[0].Type);
            Assert.AreEqual("", fragments[0].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginText, fragments[1].Type);
            Assert.AreEqual("A", fragments[1].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginExpression, fragments[2].Type);
            Assert.AreEqual("B", fragments[2].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginText, fragments[3].Type);
            Assert.AreEqual("C", fragments[3].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginExpression, fragments[4].Type);
            Assert.AreEqual("D", fragments[4].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginText, fragments[5].Type);
            Assert.AreEqual("E", fragments[5].Span.Text);
        }
예제 #2
0
        public void IncludePragmaNoFileDirective()
        {
            var line = Tools.CreateFileLine("#pragma include", 0);
            var rule = new PreprocessorRule();
            List <AsbtractRenderCommand> fragments = rule.Parse(line, new NullMessageHandler());

            Assert.AreEqual(1, fragments.Count);

            Assert.AreEqual(RenderCommandTypes.OriginScript, fragments[0].Type);
            Assert.AreEqual("#pragma include", fragments[0].Span.Text);
        }
예제 #3
0
        public void Text()
        {
            var line = Tools.CreateFileLine(@"A B", 0);
            var rule = new PassThroughRule();
            List <AsbtractRenderCommand> fragments = rule.Parse(line, new NullMessageHandler());

            Assert.AreEqual(1, fragments.Count);

            Assert.AreEqual(RenderCommandTypes.OriginScript, fragments[0].Type);
            Assert.AreEqual("A B", fragments[0].Span.Text);
        }
예제 #4
0
        public void Empty()
        {
            var line = Tools.CreateFileLine(@"|", 0);
            var rule = new InterpolationLineRule();
            List <AsbtractRenderCommand> fragments = rule.Parse(line, new NullMessageHandler());

            Assert.AreEqual(3, fragments.Count);
            // ...
            // First elements are tested by InterpolationLine
            // ...
            Assert.AreEqual(RenderCommandTypes.TargetNewLine, fragments[2].Type);
            Assert.AreEqual("", fragments[2].Span.Text);
        }
예제 #5
0
        public void IndentationText()
        {
            var line = Tools.CreateFileLine(@"\   A", 0);
            var rule = new InterpolationRule();
            List <AsbtractRenderCommand> fragments = rule.Parse(line, new NullMessageHandler());

            Assert.AreEqual(2, fragments.Count);
            Assert.AreEqual(RenderCommandTypes.TargetIndentation, fragments[0].Type);
            Assert.AreEqual("   ", fragments[0].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginText, fragments[1].Type);
            Assert.AreEqual("A", fragments[1].Span.Text);
        }
예제 #6
0
        public void Indentation()
        {
            var line = Tools.CreateFileLine(@"=   A;", 0);
            var rule = new CallRule();
            List <AsbtractRenderCommand> fragments = rule.Parse(line, new NullMessageHandler());

            Assert.AreEqual(3, fragments.Count);

            Assert.AreEqual(RenderCommandTypes.TargetPushIndentation, fragments[0].Type);
            Assert.AreEqual("   ", fragments[0].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginScript, fragments[1].Type);
            Assert.AreEqual("A;", fragments[1].Span.Text);

            Assert.AreEqual(RenderCommandTypes.TargetPopIndentation, fragments[2].Type);
            Assert.AreEqual("", fragments[2].Span.Text);
        }
예제 #7
0
        public void EscapedSharp()
        {
            var line = Tools.CreateFileLine(@"\##include #{A}", 0);
            var rule = new InterpolationRule();
            List <AsbtractRenderCommand> fragments = rule.Parse(line, new NullMessageHandler());

            Assert.AreEqual(5, fragments.Count);
            Assert.AreEqual(RenderCommandTypes.TargetIndentation, fragments[0].Type);
            Assert.AreEqual("", fragments[0].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginText, fragments[1].Type);
            Assert.AreEqual("#", fragments[1].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginText, fragments[2].Type);
            Assert.AreEqual("include ", fragments[2].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginExpression, fragments[3].Type);
            Assert.AreEqual("A", fragments[3].Span.Text);

            Assert.AreEqual(RenderCommandTypes.OriginText, fragments[4].Type);
            Assert.AreEqual("", fragments[4].Span.Text);
        }