|
1 | 1 | // Copyright (c) .NET Foundation. All rights reserved. |
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
3 | 3 |
|
| 4 | +using System; |
4 | 5 | using System.Linq; |
5 | 6 | using Microsoft.AspNet.Razor.Chunks.Generators; |
6 | | -using Microsoft.AspNet.Razor.Editor; |
7 | 7 | using Microsoft.AspNet.Razor.Parser; |
8 | 8 | using Microsoft.AspNet.Razor.Parser.SyntaxTree; |
9 | 9 | using Microsoft.AspNet.Razor.Test.Framework; |
@@ -60,6 +60,52 @@ public void DoubleQuotedLiteralAttribute() |
60 | 60 | Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); |
61 | 61 | } |
62 | 62 |
|
| 63 | + [Fact] |
| 64 | + public void NewLinePrecedingAttribute() |
| 65 | + { |
| 66 | + ParseBlockTest($"<a{Environment.NewLine}href='Foo' />", |
| 67 | + new MarkupBlock( |
| 68 | + new MarkupTagBlock( |
| 69 | + Factory.Markup("<a"), |
| 70 | + new MarkupBlock(new AttributeBlockChunkGenerator(name: "href", prefix: new LocationTagged<string>(Environment.NewLine + "href='", 2, 0, 2), suffix: new LocationTagged<string>("'", 13, 1, 9)), |
| 71 | + Factory.Markup(Environment.NewLine + "href='").With(SpanChunkGenerator.Null), |
| 72 | + Factory.Markup("Foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged<string>(string.Empty, 10, 1, 6), value: new LocationTagged<string>("Foo", 10, 1, 6))), |
| 73 | + Factory.Markup("'").With(SpanChunkGenerator.Null)), |
| 74 | + Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); |
| 75 | + } |
| 76 | + |
| 77 | + [Fact] |
| 78 | + public void NewLineBetweenAttributes() |
| 79 | + { |
| 80 | + ParseBlockTest($"<a{Environment.NewLine}href='Foo'{Environment.NewLine}abcd='Bar' />", |
| 81 | + new MarkupBlock( |
| 82 | + new MarkupTagBlock( |
| 83 | + Factory.Markup("<a"), |
| 84 | + new MarkupBlock(new AttributeBlockChunkGenerator(name: "href", prefix: new LocationTagged<string>(Environment.NewLine + "href='", 2, 0, 2), suffix: new LocationTagged<string>("'", 13, 1, 9)), |
| 85 | + Factory.Markup(Environment.NewLine + "href='").With(SpanChunkGenerator.Null), |
| 86 | + Factory.Markup("Foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged<string>(string.Empty, 10, 1, 6), value: new LocationTagged<string>("Foo", 10, 1, 6))), |
| 87 | + Factory.Markup("'").With(SpanChunkGenerator.Null)), |
| 88 | + new MarkupBlock(new AttributeBlockChunkGenerator(name: "abcd", prefix: new LocationTagged<string>(Environment.NewLine + "abcd='", 14, 1, 0), suffix: new LocationTagged<string>("'", 25, 2, 9)), |
| 89 | + Factory.Markup(Environment.NewLine + "abcd='").With(SpanChunkGenerator.Null), |
| 90 | + Factory.Markup("Bar").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged<string>(string.Empty, 22, 2, 6), value: new LocationTagged<string>("Bar", 22, 2, 6))), |
| 91 | + Factory.Markup("'").With(SpanChunkGenerator.Null)), |
| 92 | + Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); |
| 93 | + } |
| 94 | + |
| 95 | + [Fact] |
| 96 | + public void WhitespaceAndNewLinePrecedingAttribute() |
| 97 | + { |
| 98 | + ParseBlockTest($"<a {Environment.NewLine}href='Foo' />", |
| 99 | + new MarkupBlock( |
| 100 | + new MarkupTagBlock( |
| 101 | + Factory.Markup("<a"), |
| 102 | + new MarkupBlock(new AttributeBlockChunkGenerator(name: "href", prefix: new LocationTagged<string>(" " + Environment.NewLine + "href='", 2, 0, 2), suffix: new LocationTagged<string>("'", 14, 1, 9)), |
| 103 | + Factory.Markup(" " + Environment.NewLine + "href='").With(SpanChunkGenerator.Null), |
| 104 | + Factory.Markup("Foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged<string>(string.Empty, 11, 1, 6), value: new LocationTagged<string>("Foo", 11, 1, 6))), |
| 105 | + Factory.Markup("'").With(SpanChunkGenerator.Null)), |
| 106 | + Factory.Markup(" />").Accepts(AcceptedCharacters.None)))); |
| 107 | + } |
| 108 | + |
63 | 109 | [Fact] |
64 | 110 | public void UnquotedLiteralAttribute() |
65 | 111 | { |
|
0 commit comments