Fixed all the tests to reflect HtmlComment block type support
This commit is contained in:
parent
e1fbea24f1
commit
6f515bb763
|
|
@ -214,7 +214,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
[Fact]
|
||||
public void ParseDocumentReturnsOneMarkupSegmentIfNoCodeBlocksEncountered()
|
||||
{
|
||||
SingleSpanDocumentTest("Foo Baz<!--Foo-->Bar<!--F> Qux", BlockKindInternal.Markup, SpanKindInternal.Markup);
|
||||
ParseDocumentTest("Foo Baz<!--Foo-->Bar<!--F> Qux",
|
||||
new MarkupBlock(
|
||||
Factory.Markup("Foo Baz"),
|
||||
BlockFactory.HtmlCommentBlock("Foo"),
|
||||
Factory.Markup("Bar"),
|
||||
new HtmlCommentBlock(Factory.Markup("<!--").Accepts(AcceptedCharactersInternal.None)),
|
||||
Factory.Markup("F> Qux").Accepts(AcceptedCharactersInternal.WhiteSpace)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
{
|
||||
ParseBlockTest("<!--Foo--> Bar",
|
||||
new MarkupBlock(
|
||||
Factory.Markup("<!--Foo-->").Accepts(AcceptedCharactersInternal.None),
|
||||
BlockFactory.HtmlCommentBlock("Foo"),
|
||||
Factory.Markup(" ").Accepts(AcceptedCharactersInternal.None)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,13 +112,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("<foo>").Accepts(AcceptedCharactersInternal.None)),
|
||||
Factory.Markup("<!-- "),
|
||||
new ExpressionBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.Code("foo")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||
Factory.Markup(" -->").Accepts(AcceptedCharactersInternal.None),
|
||||
BlockFactory.HtmlCommentBlock(Factory, f => new SyntaxTreeNode[] {
|
||||
f.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace),
|
||||
new ExpressionBlock(
|
||||
f.CodeTransition(),
|
||||
f.Code("foo")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||
f.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace) }),
|
||||
new MarkupTagBlock(
|
||||
Factory.Markup("</foo>").Accepts(AcceptedCharactersInternal.None))));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1278,13 +1278,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
blockFactory.MarkupTagBlock("<b>"),
|
||||
factory.Markup(literal),
|
||||
blockFactory.MarkupTagBlock("</b>"),
|
||||
blockFactory.HtmlCommentBlock(
|
||||
factory.Markup(part1).Accepts(AcceptedCharactersInternal.WhiteSpace),
|
||||
BlockFactory.HtmlCommentBlock(factory, f => new SyntaxTreeNode[] {
|
||||
f.Markup(part1).Accepts(AcceptedCharactersInternal.WhiteSpace),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code(part2)
|
||||
f.CodeTransition(),
|
||||
f.Code(part2)
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)))));
|
||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)) })));
|
||||
|
||||
// Act & Assert
|
||||
EvaluateData(
|
||||
|
|
@ -4104,14 +4104,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
factory.Markup("<foo>")),
|
||||
blockFactory.HtmlCommentBlock(
|
||||
factory.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace),
|
||||
BlockFactory.HtmlCommentBlock(factory, f=> new SyntaxTreeNode[]{
|
||||
f.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace),
|
||||
new ExpressionBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("foo")
|
||||
f.CodeTransition(),
|
||||
f.Code("foo")
|
||||
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
|
||||
.Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
|
||||
factory.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace)),
|
||||
factory.Markup(" ").Accepts(AcceptedCharactersInternal.WhiteSpace) }),
|
||||
new MarkupTagBlock(
|
||||
factory.Markup("</foo>")))
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ Document -
|
|||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Double.cshtml)
|
||||
IntermediateToken - (0:0,0 [10] HtmlCommentWithQuote_Double.cshtml) - Html - <!-- " -->
|
||||
IntermediateToken - (0:0,0 [4] HtmlCommentWithQuote_Double.cshtml) - Html - <!--
|
||||
IntermediateToken - (4:0,4 [3] HtmlCommentWithQuote_Double.cshtml) - Html - "
|
||||
IntermediateToken - (7:0,7 [3] HtmlCommentWithQuote_Double.cshtml) - Html - -->
|
||||
IntermediateToken - (10:0,10 [2] HtmlCommentWithQuote_Double.cshtml) - Html - \n
|
||||
IntermediateToken - (12:1,0 [4] HtmlCommentWithQuote_Double.cshtml) - Html - <img
|
||||
IntermediateToken - (16:1,4 [26] HtmlCommentWithQuote_Double.cshtml) - Html - src="~/images/submit.png"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ Document -
|
|||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_Runtime - -
|
||||
MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Double.cshtml)
|
||||
IntermediateToken - (0:0,0 [10] HtmlCommentWithQuote_Double.cshtml) - Html - <!-- " -->
|
||||
IntermediateToken - (0:0,0 [4] HtmlCommentWithQuote_Double.cshtml) - Html - <!--
|
||||
IntermediateToken - (4:0,4 [3] HtmlCommentWithQuote_Double.cshtml) - Html - "
|
||||
IntermediateToken - (7:0,7 [3] HtmlCommentWithQuote_Double.cshtml) - Html - -->
|
||||
IntermediateToken - (10:0,10 [2] HtmlCommentWithQuote_Double.cshtml) - Html - \n
|
||||
IntermediateToken - (12:1,0 [4] HtmlCommentWithQuote_Double.cshtml) - Html - <img
|
||||
IntermediateToken - (16:1,4 [26] HtmlCommentWithQuote_Double.cshtml) - Html - src="~/images/submit.png"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ Document -
|
|||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Single.cshtml)
|
||||
IntermediateToken - (0:0,0 [10] HtmlCommentWithQuote_Single.cshtml) - Html - <!-- ' -->
|
||||
IntermediateToken - (0:0,0 [4] HtmlCommentWithQuote_Single.cshtml) - Html - <!--
|
||||
IntermediateToken - (4:0,4 [3] HtmlCommentWithQuote_Single.cshtml) - Html - '
|
||||
IntermediateToken - (7:0,7 [3] HtmlCommentWithQuote_Single.cshtml) - Html - -->
|
||||
IntermediateToken - (10:0,10 [2] HtmlCommentWithQuote_Single.cshtml) - Html - \n
|
||||
IntermediateToken - (12:1,0 [4] HtmlCommentWithQuote_Single.cshtml) - Html - <img
|
||||
IntermediateToken - (16:1,4 [26] HtmlCommentWithQuote_Single.cshtml) - Html - src="~/images/submit.png"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ Document -
|
|||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_Runtime - -
|
||||
MethodDeclaration - - public async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [45] HtmlCommentWithQuote_Single.cshtml)
|
||||
IntermediateToken - (0:0,0 [10] HtmlCommentWithQuote_Single.cshtml) - Html - <!-- ' -->
|
||||
IntermediateToken - (0:0,0 [4] HtmlCommentWithQuote_Single.cshtml) - Html - <!--
|
||||
IntermediateToken - (4:0,4 [3] HtmlCommentWithQuote_Single.cshtml) - Html - '
|
||||
IntermediateToken - (7:0,7 [3] HtmlCommentWithQuote_Single.cshtml) - Html - -->
|
||||
IntermediateToken - (10:0,10 [2] HtmlCommentWithQuote_Single.cshtml) - Html - \n
|
||||
IntermediateToken - (12:1,0 [4] HtmlCommentWithQuote_Single.cshtml) - Html - <img
|
||||
IntermediateToken - (16:1,4 [26] HtmlCommentWithQuote_Single.cshtml) - Html - src="~/images/submit.png"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||
|
|
@ -57,21 +58,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
|
||||
public HtmlCommentBlock HtmlCommentBlock(string content)
|
||||
{
|
||||
return new HtmlCommentBlock(new SyntaxTreeNode[] {
|
||||
_factory.Markup("<!--").Accepts(AcceptedCharactersInternal.None),
|
||||
_factory.Markup(content).Accepts(AcceptedCharactersInternal.WhiteSpace),
|
||||
_factory.Markup("-->").Accepts(AcceptedCharactersInternal.None) });
|
||||
return HtmlCommentBlock(_factory, f => new SyntaxTreeNode[] { f.Markup(content).Accepts(AcceptedCharactersInternal.WhiteSpace) });
|
||||
}
|
||||
|
||||
public HtmlCommentBlock HtmlCommentBlock(params SyntaxTreeNode[] syntaxTreeNodes)
|
||||
public static HtmlCommentBlock HtmlCommentBlock(SpanFactory factory, Func<SpanFactory, IEnumerable<SyntaxTreeNode>> nodesBuilder = null)
|
||||
{
|
||||
var nodes = new List<SyntaxTreeNode>();
|
||||
nodes.Add(_factory.Markup("<!--").Accepts(AcceptedCharactersInternal.None));
|
||||
if (syntaxTreeNodes != null)
|
||||
nodes.Add(factory.Markup("<!--").Accepts(AcceptedCharactersInternal.None));
|
||||
if (nodesBuilder != null)
|
||||
{
|
||||
nodes.AddRange(syntaxTreeNodes);
|
||||
nodes.AddRange(nodesBuilder(factory));
|
||||
}
|
||||
nodes.Add(_factory.Markup("-->").Accepts(AcceptedCharactersInternal.None));
|
||||
nodes.Add(factory.Markup("-->").Accepts(AcceptedCharactersInternal.None));
|
||||
|
||||
return new HtmlCommentBlock(nodes.ToArray());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue