1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Web.Razor.Parser.SyntaxTree;
using System.Web.Razor.Test.Framework;
using System.Web.Razor.Tokenizer.Symbols;
using Xunit;
namespace System.Web.Razor.Test.Parser.VB
{
public class VBNestedStatementsTest : VBHtmlCodeParserTestBase
{
[Fact]
public void VB_Nested_If_Statement()
{
ParseBlockTest(@"@If True Then
If False Then
End If
End If",
new StatementBlock(
Factory.CodeTransition(),
Factory.Code("If True Then\r\n If False Then\r\n End If\r\nEnd If")
.AsStatement()
.Accepts(AcceptedCharacters.None)));
}
[Fact]
public void VB_Nested_Do_Statement()
{
ParseBlockTest(@"@Do While True
Do
Loop Until False
Loop",
new StatementBlock(
Factory.CodeTransition(),
Factory.Code("Do While True\r\n Do\r\n Loop Until False\r\nLoop")
.AsStatement()
.Accepts(AcceptedCharacters.AnyExceptNewline)));
}
[Fact]
public void VB_Nested_Markup_Statement_In_If()
{
ParseBlockTest(@"@If True Then
@<p>Tag</p>
End If",
new StatementBlock(
Factory.CodeTransition(),
Factory.Code("If True Then\r\n")
.AsStatement(),
new MarkupBlock(
Factory.Markup(" "),
Factory.MarkupTransition(),
Factory.Markup("<p>Tag</p>\r\n")
.Accepts(AcceptedCharacters.None)),
Factory.Code("End If")
.AsStatement()
.Accepts(AcceptedCharacters.None)));
}
[Fact]
public void VB_Nested_Markup_Statement_In_Code()
{
ParseBlockTest(@"@Code
Foo()
@<p>Tag</p>
Bar()
End Code",
new StatementBlock(
Factory.CodeTransition(),
Factory.MetaCode("Code")
.Accepts(AcceptedCharacters.None),
Factory.Code("\r\n Foo()\r\n")
.AsStatement(),
new MarkupBlock(
Factory.Markup(" "),
Factory.MarkupTransition(),
Factory.Markup("<p>Tag</p>\r\n")
.Accepts(AcceptedCharacters.None)),
Factory.Code(" Bar()\r\n")
.AsStatement(),
Factory.MetaCode("End Code")
.Accepts(AcceptedCharacters.None)));
}
[Fact]
public void VB_Nested_Markup_Statement_In_Do()
{
ParseBlockTest(@"@Do
@<p>Tag</p>
Loop While True",
new StatementBlock(
Factory.CodeTransition(),
Factory.Code("Do\r\n")
.AsStatement(),
new MarkupBlock(
Factory.Markup(" "),
Factory.MarkupTransition(),
Factory.Markup("<p>Tag</p>\r\n")
.Accepts(AcceptedCharacters.None)),
Factory.Code("Loop While True")
.AsStatement()
.Accepts(AcceptedCharacters.AnyExceptNewline)));
}
[Fact]
public void VB_Nested_Single_Line_Markup_Statement_In_Do()
{
ParseBlockTest(@"@Do
@:<p>Tag
Loop While True",
new StatementBlock(
Factory.CodeTransition(),
Factory.Code("Do\r\n")
.AsStatement(),
new MarkupBlock(
Factory.Markup(" "),
Factory.MarkupTransition(),
Factory.MetaMarkup(":", HtmlSymbolType.Colon),
Factory.Markup("<p>Tag\r\n")
.Accepts(AcceptedCharacters.None)),
Factory.Code("Loop While True")
.AsStatement()
.Accepts(AcceptedCharacters.AnyExceptNewline)));
}
[Fact]
public void VB_Nested_Implicit_Expression_In_If()
{
ParseBlockTest(@"@If True Then
@Foo.Bar
End If",
new StatementBlock(
Factory.CodeTransition(),
Factory.Code("If True Then\r\n ")
.AsStatement(),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("Foo.Bar")
.AsExpression()
.Accepts(AcceptedCharacters.NonWhiteSpace)),
Factory.Code("\r\nEnd If")
.AsStatement()
.Accepts(AcceptedCharacters.None)));
}
[Fact]
public void VB_Nested_Explicit_Expression_In_If()
{
ParseBlockTest(@"@If True Then
@(Foo.Bar + 42)
End If",
new StatementBlock(
Factory.CodeTransition(),
Factory.Code("If True Then\r\n ")
.AsStatement(),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.MetaCode("(")
.Accepts(AcceptedCharacters.None),
Factory.Code("Foo.Bar + 42")
.AsExpression(),
Factory.MetaCode(")")
.Accepts(AcceptedCharacters.None)),
Factory.Code("\r\nEnd If")
.AsStatement()
.Accepts(AcceptedCharacters.None)));
}
}
}
|