Merge branch 'release/2.2'
This commit is contained in:
commit
7bdad8fdd3
|
|
@ -9,20 +9,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class CSharpBlockTest : CsHtmlCodeParserTestBase
|
public class CSharpBlockTest : CsHtmlCodeParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_NestedCodeBlockWithCSharpAt()
|
public void NestedCodeBlockWithCSharpAt()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ if (true) { var val = @x; if (val != 3) { } } }");
|
ParseBlockTest("{ if (true) { var val = @x; if (val != 3) { } } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_NestedCodeBlockWithMarkupSetsDotAsMarkup()
|
public void NestedCodeBlockWithMarkupSetsDotAsMarkup()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if (true) { @if(false) { <div>@something.</div> } }");
|
ParseBlockTest("if (true) { @if(false) { <div>@something.</div> } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideSingleLineComments()
|
public void BalancingBracketsIgnoresStringLiteralCharactersAndBrackets()
|
||||||
{
|
{
|
||||||
|
// BalancingBracketsIgnoresStringLiteralCharactersAndBracketsInsideSingleLineComments
|
||||||
SingleSpanBlockTest(@"if(foo) {
|
SingleSpanBlockTest(@"if(foo) {
|
||||||
// bar } "" baz '
|
// bar } "" baz '
|
||||||
zoop();
|
zoop();
|
||||||
|
|
@ -46,102 +47,107 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForKeyword()
|
public void SkipsExprThenBalancesBracesIfFirstIdentifierIsForKeyword()
|
||||||
{
|
{
|
||||||
|
// ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForKeyword
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
"for(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForeachKeyword()
|
public void SkipsExprThenBalancesBracesIfFirstIdentifierIsForeachKeyword()
|
||||||
{
|
{
|
||||||
|
// ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsForeachKeyword
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
"foreach(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsWhileKeyword()
|
public void SkipsExprThenBalancesBracesIfFirstIdentifierIsWhileKeyword()
|
||||||
{
|
{
|
||||||
|
// ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsWhileKeyword
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
"while(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsUsingKeywordFollowedByParen()
|
public void SkipsExprThenBalancesIfFirstIdentifierIsUsingFollowedByParen()
|
||||||
{
|
{
|
||||||
|
// ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsUsingKeywordFollowedByParen
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
"using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsUsingsNestedWithinOtherBlocks()
|
public void SupportsUsingsNestedWithinOtherBlocks()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }");
|
"if(foo) { using(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches()
|
public void SkipsExprThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches()
|
||||||
{
|
{
|
||||||
|
// ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsIfKeywordWithNoElseBranches
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
"if(int i = 0; i < 10; new Foo { Bar = \"baz\" }) { Debug.WriteLine(@\"foo } bar\"); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsEmptyBlockStatement()
|
public void AllowsEmptyBlockStatement()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("if(false) { }");
|
SingleSpanBlockTest("if(false) { }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesParenBalancingAtEOF()
|
public void TerminatesParenBalancingAtEOF()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("Html.En(code()");
|
ImplicitExpressionTest("Html.En(code()");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsBlockCommentBetweenIfAndElseClause()
|
public void SupportsBlockCommentBetweenIfAndElseClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }");
|
"if(foo) { bar(); } /* Foo */ /* Bar */ else { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsRazorCommentBetweenIfAndElseClause()
|
public void SupportsRazorCommentBetweenIfAndElseClause()
|
||||||
{
|
{
|
||||||
RunRazorCommentBetweenClausesTest(
|
RunRazorCommentBetweenClausesTest(
|
||||||
"if(foo) { bar(); } ", " else { baz(); }");
|
"if(foo) { bar(); } ", " else { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsBlockCommentBetweenElseIfAndElseClause()
|
public void SupportsBlockCommentBetweenElseIfAndElseClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }");
|
"if(foo) { bar(); } else if(bar) { baz(); } /* Foo */ /* Bar */ else { biz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsRazorCommentBetweenElseIfAndElseClause()
|
public void SupportsRazorCommentBetweenElseIfAndElseClause()
|
||||||
{
|
{
|
||||||
RunRazorCommentBetweenClausesTest(
|
RunRazorCommentBetweenClausesTest(
|
||||||
"if(foo) { bar(); } else if(bar) { baz(); } ", " else { baz(); }");
|
"if(foo) { bar(); } else if(bar) { baz(); } ", " else { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsBlockCommentBetweenIfAndElseIfClause()
|
public void SupportsBlockCommentBetweenIfAndElseIfClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }");
|
"if(foo) { bar(); } /* Foo */ /* Bar */ else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsRazorCommentBetweenIfAndElseIfClause()
|
public void SupportsRazorCommentBetweenIfAndElseIfClause()
|
||||||
{
|
{
|
||||||
RunRazorCommentBetweenClausesTest("if(foo) { bar(); } ", " else if(bar) { baz(); }");
|
RunRazorCommentBetweenClausesTest("if(foo) { bar(); } ", " else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsLineCommentBetweenIfAndElseClause()
|
public void SupportsLineCommentBetweenIfAndElseClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(@"if(foo) { bar(); }
|
SingleSpanBlockTest(@"if(foo) { bar(); }
|
||||||
// Foo
|
// Foo
|
||||||
|
|
@ -150,7 +156,7 @@ else { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsLineCommentBetweenElseIfAndElseClause()
|
public void SupportsLineCommentBetweenElseIfAndElseClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(@"if(foo) { bar(); } else if(bar) { baz(); }
|
SingleSpanBlockTest(@"if(foo) { bar(); } else if(bar) { baz(); }
|
||||||
// Foo
|
// Foo
|
||||||
|
|
@ -159,7 +165,7 @@ else { biz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsLineCommentBetweenIfAndElseIfClause()
|
public void SupportsLineCommentBetweenIfAndElseIfClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(@"if(foo) { bar(); }
|
SingleSpanBlockTest(@"if(foo) { bar(); }
|
||||||
// Foo
|
// Foo
|
||||||
|
|
@ -168,7 +174,7 @@ else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesElseIfBranchesOfIfStatement()
|
public void ParsesElseIfBranchesOfIfStatement()
|
||||||
{
|
{
|
||||||
const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
||||||
Debug.WriteLine(@""foo } bar"");
|
Debug.WriteLine(@""foo } bar"");
|
||||||
|
|
@ -182,7 +188,7 @@ else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesMultipleElseIfBranchesOfIfStatement()
|
public void ParsesMultipleElseIfBranchesOfIfStatement()
|
||||||
{
|
{
|
||||||
const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
||||||
Debug.WriteLine(@""foo } bar"");
|
Debug.WriteLine(@""foo } bar"");
|
||||||
|
|
@ -195,7 +201,7 @@ else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch()
|
public void ParsesMultipleElseIfBranchesOfIfStatementFollowedByOneElseBranch()
|
||||||
{
|
{
|
||||||
const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
||||||
Debug.WriteLine(@""foo } bar"");
|
Debug.WriteLine(@""foo } bar"");
|
||||||
|
|
@ -210,7 +216,7 @@ else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockStopsParsingCodeAfterElseBranch()
|
public void StopsParsingCodeAfterElseBranch()
|
||||||
{
|
{
|
||||||
const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
const string ifStatement = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
||||||
Debug.WriteLine(@""foo } bar"");
|
Debug.WriteLine(@""foo } bar"");
|
||||||
|
|
@ -225,7 +231,7 @@ else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockStopsParsingIfIfStatementNotFollowedByElse()
|
public void StopsParsingIfIfStatementNotFollowedByElse()
|
||||||
{
|
{
|
||||||
const string document = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
const string document = @"if(int i = 0; i < 10; new Foo { Bar = ""baz"" }) {
|
||||||
Debug.WriteLine(@""foo } bar"");
|
Debug.WriteLine(@""foo } bar"");
|
||||||
|
|
@ -235,7 +241,7 @@ else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAcceptsElseIfWithNoCondition()
|
public void AcceptsElseIfWithNoCondition()
|
||||||
{
|
{
|
||||||
// We don't want to be a full C# parser - If the else if is missing it's condition, the C# compiler
|
// We don't want to be a full C# parser - If the else if is missing it's condition, the C# compiler
|
||||||
// can handle that, we have all the info we need to keep parsing
|
// can handle that, we have all the info we need to keep parsing
|
||||||
|
|
@ -249,46 +255,46 @@ else if(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyParsesDoWhileBlock()
|
public void CorrectlyParsesDoWhileBlock()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"do { var foo = bar; } while(foo != bar);");
|
"do { var foo = bar; } while(foo != bar);");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyParsesDoWhileBlockMissingSemicolon()
|
public void CorrectlyParsesDoWhileBlockMissingSemicolon()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("do { var foo = bar; } while(foo != bar)");
|
SingleSpanBlockTest("do { var foo = bar; } while(foo != bar)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileCondition()
|
public void CorrectlyParsesDoWhileBlockMissingWhileCondition()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("do { var foo = bar; } while");
|
SingleSpanBlockTest("do { var foo = bar; } while");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon()
|
public void CorrectlyParsesDoWhileBlockMissingWhileConditionWithSemicolon()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"do { var foo = bar; } while;");
|
"do { var foo = bar; } while;");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyParsesDoWhileBlockMissingWhileClauseEntirely()
|
public void CorrectlyParsesDoWhileBlockMissingWhileClauseEntirely()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("do { var foo = bar; } narf;");
|
SingleSpanBlockTest("do { var foo = bar; } narf;");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsBlockCommentBetweenDoAndWhileClause()
|
public void SupportsBlockCommentBetweenDoAndWhileClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"do { var foo = bar; } /* Foo */ /* Bar */ while(true);");
|
"do { var foo = bar; } /* Foo */ /* Bar */ while(true);");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsLineCommentBetweenDoAndWhileClause()
|
public void SupportsLineCommentBetweenDoAndWhileClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(@"do { var foo = bar; }
|
SingleSpanBlockTest(@"do { var foo = bar; }
|
||||||
// Foo
|
// Foo
|
||||||
|
|
@ -297,21 +303,22 @@ while(true);");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsRazorCommentBetweenDoAndWhileClause()
|
public void SupportsRazorCommentBetweenDoAndWhileClause()
|
||||||
{
|
{
|
||||||
RunRazorCommentBetweenClausesTest(
|
RunRazorCommentBetweenClausesTest(
|
||||||
"do { var foo = bar; } ", " while(true);");
|
"do { var foo = bar; } ", " while(true);");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyParsesMarkupInDoWhileBlock()
|
public void CorrectlyParsesMarkupInDoWhileBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@do { var foo = bar; <p>Foo</p> foo++; } while (foo<bar>);");
|
ParseBlockTest("@do { var foo = bar; <p>Foo</p> foo++; } while (foo<bar>);");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsSwitchKeyword()
|
public void SkipsExprThenBalancesBracesIfFirstIdentifierIsSwitchKeyword()
|
||||||
{
|
{
|
||||||
|
// ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsSwitchKeyword
|
||||||
SingleSpanBlockTest(@"switch(foo) {
|
SingleSpanBlockTest(@"switch(foo) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
@ -327,119 +334,120 @@ while(true);");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsLockKeyword()
|
public void ThenBalancesBracesIfFirstIdentifierIsLockKeyword()
|
||||||
{
|
{
|
||||||
|
// ParseBlockSkipsParenthesisedExpressionAndThenBalancesBracesIfFirstIdentifierIsLockKeyword
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"lock(foo) { Debug.WriteLine(@\"foo } bar\"); }");
|
"lock(foo) { Debug.WriteLine(@\"foo } bar\"); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHasErrorsIfNamespaceImportMissingSemicolon()
|
public void HasErrorsIfNamespaceImportMissingSemicolon()
|
||||||
{
|
{
|
||||||
ParseBlockTest(
|
ParseBlockTest(
|
||||||
"using Foo.Bar.Baz");
|
"using Foo.Bar.Baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHasErrorsIfNamespaceAliasMissingSemicolon()
|
public void HasErrorsIfNamespaceAliasMissingSemicolon()
|
||||||
{
|
{
|
||||||
ParseBlockTest(
|
ParseBlockTest(
|
||||||
"using Foo.Bar.Baz = FooBarBaz");
|
"using Foo.Bar.Baz = FooBarBaz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat()
|
public void ParsesNamespaceImportWithSemicolonForUsingKeywordIfIsInValidFormat()
|
||||||
{
|
{
|
||||||
ParseBlockTest(
|
ParseBlockTest(
|
||||||
"using Foo.Bar.Baz;");
|
"using Foo.Bar.Baz;");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockDoesntCaptureWhitespaceAfterUsing()
|
public void DoesntCaptureWhitespaceAfterUsing()
|
||||||
{
|
{
|
||||||
ParseBlockTest("using Foo ");
|
ParseBlockTest("using Foo ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCapturesNewlineAfterUsing()
|
public void CapturesNewlineAfterUsing()
|
||||||
{
|
{
|
||||||
ParseBlockTest($"using Foo{Environment.NewLine}");
|
ParseBlockTest($"using Foo{Environment.NewLine}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat()
|
public void ParsesNamespaceAliasWithSemicolonForUsingKeywordIfIsInValidFormat()
|
||||||
{
|
{
|
||||||
ParseBlockTest(
|
ParseBlockTest(
|
||||||
"using FooBarBaz = FooBarBaz;");
|
"using FooBarBaz = FooBarBaz;");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock()
|
public void TerminatesUsingKeywordAtEOFAndOutputsFileCodeBlock()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("using ");
|
SingleSpanBlockTest("using ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesSingleLineCommentAtEndOfFile()
|
public void TerminatesSingleLineCommentAtEndOfFile()
|
||||||
{
|
{
|
||||||
const string document = "foreach(var f in Foo) { // foo bar baz";
|
const string document = "foreach(var f in Foo) { // foo bar baz";
|
||||||
SingleSpanBlockTest(document);
|
SingleSpanBlockTest(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesBlockCommentAtEndOfFile()
|
public void TerminatesBlockCommentAtEndOfFile()
|
||||||
{
|
{
|
||||||
const string document = "foreach(var f in Foo) { /* foo bar baz";
|
const string document = "foreach(var f in Foo) { /* foo bar baz";
|
||||||
SingleSpanBlockTest(document);
|
SingleSpanBlockTest(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesSingleSlashAtEndOfFile()
|
public void TerminatesSingleSlashAtEndOfFile()
|
||||||
{
|
{
|
||||||
const string document = "foreach(var f in Foo) { / foo bar baz";
|
const string document = "foreach(var f in Foo) { / foo bar baz";
|
||||||
SingleSpanBlockTest(document);
|
SingleSpanBlockTest(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsBlockCommentBetweenTryAndFinallyClause()
|
public void SupportsBlockCommentBetweenTryAndFinallyClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ finally { baz(); }");
|
SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ finally { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsRazorCommentBetweenTryAndFinallyClause()
|
public void SupportsRazorCommentBetweenTryAndFinallyClause()
|
||||||
{
|
{
|
||||||
RunRazorCommentBetweenClausesTest("try { bar(); } ", " finally { biz(); }");
|
RunRazorCommentBetweenClausesTest("try { bar(); } ", " finally { biz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsBlockCommentBetweenCatchAndFinallyClause()
|
public void SupportsBlockCommentBetweenCatchAndFinallyClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }");
|
"try { bar(); } catch(bar) { baz(); } /* Foo */ /* Bar */ finally { biz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsRazorCommentBetweenCatchAndFinallyClause()
|
public void SupportsRazorCommentBetweenCatchAndFinallyClause()
|
||||||
{
|
{
|
||||||
RunRazorCommentBetweenClausesTest(
|
RunRazorCommentBetweenClausesTest(
|
||||||
"try { bar(); } catch(bar) { baz(); } ", " finally { biz(); }");
|
"try { bar(); } catch(bar) { baz(); } ", " finally { biz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsBlockCommentBetweenTryAndCatchClause()
|
public void SupportsBlockCommentBetweenTryAndCatchClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }");
|
SingleSpanBlockTest("try { bar(); } /* Foo */ /* Bar */ catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsRazorCommentBetweenTryAndCatchClause()
|
public void SupportsRazorCommentBetweenTryAndCatchClause()
|
||||||
{
|
{
|
||||||
RunRazorCommentBetweenClausesTest("try { bar(); }", " catch(bar) { baz(); }");
|
RunRazorCommentBetweenClausesTest("try { bar(); }", " catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsLineCommentBetweenTryAndFinallyClause()
|
public void SupportsLineCommentBetweenTryAndFinallyClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(@"try { bar(); }
|
SingleSpanBlockTest(@"try { bar(); }
|
||||||
// Foo
|
// Foo
|
||||||
|
|
@ -448,7 +456,7 @@ finally { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsLineCommentBetweenCatchAndFinallyClause()
|
public void SupportsLineCommentBetweenCatchAndFinallyClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(@"try { bar(); } catch(bar) { baz(); }
|
SingleSpanBlockTest(@"try { bar(); } catch(bar) { baz(); }
|
||||||
// Foo
|
// Foo
|
||||||
|
|
@ -457,7 +465,7 @@ finally { biz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsLineCommentBetweenTryAndCatchClause()
|
public void SupportsLineCommentBetweenTryAndCatchClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(@"try { bar(); }
|
SingleSpanBlockTest(@"try { bar(); }
|
||||||
// Foo
|
// Foo
|
||||||
|
|
@ -466,13 +474,13 @@ catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsTryStatementWithNoAdditionalClauses()
|
public void SupportsTryStatementWithNoAdditionalClauses()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("try { var foo = new { } }");
|
SingleSpanBlockTest("try { var foo = new { } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsMarkupWithinTryClause()
|
public void SupportsMarkupWithinTryClause()
|
||||||
{
|
{
|
||||||
RunSimpleWrappedMarkupTest(
|
RunSimpleWrappedMarkupTest(
|
||||||
prefix: "try {",
|
prefix: "try {",
|
||||||
|
|
@ -481,13 +489,13 @@ catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsTryStatementWithOneCatchClause()
|
public void SupportsTryStatementWithOneCatchClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }");
|
SingleSpanBlockTest("try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsMarkupWithinCatchClause()
|
public void SupportsMarkupWithinCatchClause()
|
||||||
{
|
{
|
||||||
RunSimpleWrappedMarkupTest(
|
RunSimpleWrappedMarkupTest(
|
||||||
prefix: "try { var foo = new { } } catch(Foo Bar Baz) {",
|
prefix: "try { var foo = new { } } catch(Foo Bar Baz) {",
|
||||||
|
|
@ -496,7 +504,7 @@ catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsTryStatementWithMultipleCatchClause()
|
public void SupportsTryStatementWithMultipleCatchClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest(
|
SingleSpanBlockTest(
|
||||||
"try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " +
|
"try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " +
|
||||||
|
|
@ -504,13 +512,13 @@ catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsExceptionLessCatchClauses()
|
public void SupportsExceptionLessCatchClauses()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("try { var foo = new { } } catch { var foo = new { } }");
|
SingleSpanBlockTest("try { var foo = new { } } catch { var foo = new { } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsMarkupWithinAdditionalCatchClauses()
|
public void SupportsMarkupWithinAdditionalCatchClauses()
|
||||||
{
|
{
|
||||||
RunSimpleWrappedMarkupTest(
|
RunSimpleWrappedMarkupTest(
|
||||||
prefix: "try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " +
|
prefix: "try { var foo = new { } } catch(Foo Bar Baz) { var foo = new { } } catch(Foo Bar Baz) " +
|
||||||
|
|
@ -520,13 +528,13 @@ catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsTryStatementWithFinallyClause()
|
public void SupportsTryStatementWithFinallyClause()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("try { var foo = new { } } finally { var foo = new { } }");
|
SingleSpanBlockTest("try { var foo = new { } } finally { var foo = new { } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsMarkupWithinFinallyClause()
|
public void SupportsMarkupWithinFinallyClause()
|
||||||
{
|
{
|
||||||
RunSimpleWrappedMarkupTest(
|
RunSimpleWrappedMarkupTest(
|
||||||
prefix: "try { var foo = new { } } finally {",
|
prefix: "try { var foo = new { } } finally {",
|
||||||
|
|
@ -535,57 +543,58 @@ catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockStopsParsingCatchClausesAfterFinallyBlock()
|
public void StopsParsingCatchClausesAfterFinallyBlock()
|
||||||
{
|
{
|
||||||
var content = "try { var foo = new { } } finally { var foo = new { } }";
|
var content = "try { var foo = new { } } finally { var foo = new { } }";
|
||||||
SingleSpanBlockTest(content + " catch(Foo Bar Baz) { }");
|
SingleSpanBlockTest(content + " catch(Foo Bar Baz) { }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockDoesNotAllowMultipleFinallyBlocks()
|
public void DoesNotAllowMultipleFinallyBlocks()
|
||||||
{
|
{
|
||||||
var content = "try { var foo = new { } } finally { var foo = new { } }";
|
var content = "try { var foo = new { } } finally { var foo = new { } }";
|
||||||
SingleSpanBlockTest(content + " finally { }");
|
SingleSpanBlockTest(content + " finally { }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode()
|
public void AcceptsTrailingDotIntoImplicitExpressionWhenEmbeddedInCode()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest(@"if(foo) { @foo. }");
|
ParseBlockTest(@"if(foo) { @foo. }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesExpressionOnSwitchCharacterFollowedByOpenParen()
|
public void ParsesExpressionOnSwitchCharacterFollowedByOpenParen()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest(@"if(foo) { @(foo + bar) }");
|
ParseBlockTest(@"if(foo) { @(foo + bar) }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesExpressionOnSwitchCharacterFollowedByIdentifierStart()
|
public void ParsesExpressionOnSwitchCharacterFollowedByIdentifierStart()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest(@"if(foo) { @foo[4].bar() }");
|
ParseBlockTest(@"if(foo) { @foo[4].bar() }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart()
|
public void TreatsDoubleAtSignAsEscapeSequenceIfAtStatementStart()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest(@"if(foo) { @@class.Foo() }");
|
ParseBlockTest(@"if(foo) { @@class.Foo() }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTreatsAtSignsAfterFirstPairAsPartOfCSharpStatement()
|
public void TreatsAtSignsAfterFirstPairAsPartOfCSharpStatement()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest(@"if(foo) { @@@@class.Foo() }");
|
ParseBlockTest(@"if(foo) { @@@@class.Foo() }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockDoesNotParseMarkupStatementOrExpressionOnSwitchCharacterNotFollowedByOpenAngleOrColon()
|
public void DoesNotParseOnSwitchCharacterNotFollowedByOpenAngleOrColon()
|
||||||
{
|
{
|
||||||
|
// ParseBlockDoesNotParseMarkupStatementOrExpressionOnSwitchCharacterNotFollowedByOpenAngleOrColon
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest("if(foo) { @\"Foo\".ToString(); }");
|
ParseBlockTest("if(foo) { @\"Foo\".ToString(); }");
|
||||||
}
|
}
|
||||||
|
|
@ -607,62 +616,62 @@ catch(bar) { baz(); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransitionInAttributeValue_DoesNotThrow()
|
public void WithDoubleTransitionInAttributeValue_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='@@' />}";
|
var input = "{<span foo='@@' />}";
|
||||||
ParseBlockTest(input);
|
ParseBlockTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow()
|
public void WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='abc@@' />}";
|
var input = "{<span foo='abc@@' />}";
|
||||||
ParseBlockTest(input);
|
ParseBlockTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow()
|
public void WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='@@def' />}";
|
var input = "{<span foo='@@def' />}";
|
||||||
ParseBlockTest(input);
|
ParseBlockTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransitionBetweenAttributeValue_DoesNotThrow()
|
public void WithDoubleTransitionBetweenAttributeValue_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='abc @@ def' />}";
|
var input = "{<span foo='abc @@ def' />}";
|
||||||
ParseBlockTest(input);
|
ParseBlockTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransitionWithExpressionBlock_DoesNotThrow()
|
public void WithDoubleTransitionWithExpressionBlock_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='@@@(2+3)' bar='@(2+3)@@@DateTime.Now' baz='@DateTime.Now@@' bat='@DateTime.Now @@' zoo='@@@DateTime.Now' />}";
|
var input = "{<span foo='@@@(2+3)' bar='@(2+3)@@@DateTime.Now' baz='@DateTime.Now@@' bat='@DateTime.Now @@' zoo='@@@DateTime.Now' />}";
|
||||||
ParseBlockTest(input);
|
ParseBlockTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransitionInEmail_DoesNotThrow()
|
public void WithDoubleTransitionInEmail_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='abc@def.com abc@@def.com @@' />}";
|
var input = "{<span foo='abc@def.com abc@@def.com @@' />}";
|
||||||
ParseBlockTest(input);
|
ParseBlockTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransitionInRegex_DoesNotThrow()
|
public void WithDoubleTransitionInRegex_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = @"{<span foo=""/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@@[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i"" />}";
|
var input = @"{<span foo=""/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@@[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i"" />}";
|
||||||
ParseBlockTest(input);
|
ParseBlockTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransition_EndOfFile_Throws()
|
public void WithDoubleTransition_EndOfFile_Throws()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{<span foo='@@");
|
ParseBlockTest("{<span foo='@@");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithUnexpectedTransitionsInAttributeValue_Throws()
|
public void WithUnexpectedTransitionsInAttributeValue_Throws()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{<span foo='@ @' />}");
|
ParseBlockTest("{<span foo='@ @' />}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,79 +10,83 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class CSharpErrorTest : CsHtmlCodeParserTestBase
|
public class CSharpErrorTest : CsHtmlCodeParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesQuotesAfterTransition()
|
public void HandlesQuotesAfterTransition()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@\"");
|
ParseBlockTest("@\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockWithHelperDirectiveProducesError()
|
public void WithHelperDirectiveProducesError()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@helper fooHelper { }");
|
ParseBlockTest("@helper fooHelper { }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockWithNestedCodeBlockProducesError()
|
public void WithNestedCodeBlockProducesError()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@if { @{} }");
|
ParseBlockTest("@if { @{} }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode()
|
public void CapturesWhitespaceToEOLInInvalidUsingStmtAndTreatsAsFileCode()
|
||||||
{
|
{
|
||||||
|
// ParseBlockCapturesWhitespaceToEndOfLineInInvalidUsingStatementAndTreatsAsFileCode
|
||||||
ParseBlockTest("using " + Environment.NewLine
|
ParseBlockTest("using " + Environment.NewLine
|
||||||
+ Environment.NewLine);
|
+ Environment.NewLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace()
|
public void MethodOutputsOpenCurlyAsCodeSpanIfEofFoundAfterOpenCurlyBrace()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{");
|
ParseBlockTest("{");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty()
|
public void MethodOutputsZeroLengthCodeSpanIfStatementBlockEmpty()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{}");
|
ParseBlockTest("{}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodProducesErrorIfNewlineFollowsTransition()
|
public void MethodProducesErrorIfNewlineFollowsTransition()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@" + Environment.NewLine);
|
ParseBlockTest("@" + Environment.NewLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression()
|
public void MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr()
|
||||||
{
|
{
|
||||||
|
// ParseBlockMethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpression
|
||||||
ParseBlockTest("{" + Environment.NewLine
|
ParseBlockTest("{" + Environment.NewLine
|
||||||
+ " @ {}" + Environment.NewLine
|
+ " @ {}" + Environment.NewLine
|
||||||
+ "}");
|
+ "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression()
|
public void MethodProducesErrorIfEOFAfterTransitionInEmbeddedExpression()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{" + Environment.NewLine
|
ParseBlockTest("{" + Environment.NewLine
|
||||||
+ " @");
|
+ " @");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace()
|
public void MethodParsesNothingIfFirstCharacterIsNotIdentifierStartOrParenOrBrace()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@!!!");
|
ParseBlockTest("@!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed()
|
public void ShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExprUnclosed()
|
||||||
{
|
{
|
||||||
|
// ParseBlockShouldReportErrorAndTerminateAtEOFIfIfParenInExplicitExpressionUnclosed
|
||||||
ParseBlockTest("(foo bar" + Environment.NewLine
|
ParseBlockTest("(foo bar" + Environment.NewLine
|
||||||
+ "baz");
|
+ "baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed()
|
public void ShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExprUnclosed()
|
||||||
{
|
{
|
||||||
|
// ParseBlockShouldReportErrorAndTerminateAtMarkupIfIfParenInExplicitExpressionUnclosed
|
||||||
ParseBlockTest("(foo bar" + Environment.NewLine
|
ParseBlockTest("(foo bar" + Environment.NewLine
|
||||||
+ "<html>" + Environment.NewLine
|
+ "<html>" + Environment.NewLine
|
||||||
+ "baz" + Environment.NewLine
|
+ "baz" + Environment.NewLine
|
||||||
|
|
@ -90,7 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed()
|
public void CorrectlyHandlesInCorrectTransitionsIfImplicitExpressionParensUnclosed()
|
||||||
{
|
{
|
||||||
ParseBlockTest("Href(" + Environment.NewLine
|
ParseBlockTest("Href(" + Environment.NewLine
|
||||||
+ "<h1>@Html.Foo(Bar);</h1>" + Environment.NewLine);
|
+ "<h1>@Html.Foo(Bar);</h1>" + Environment.NewLine);
|
||||||
|
|
@ -98,8 +102,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
// Test for fix to Dev10 884975 - Incorrect Error Messaging
|
// Test for fix to Dev10 884975 - Incorrect Error Messaging
|
||||||
public void ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed()
|
public void ShouldReportErrorAndTerminateAtEOFIfParenInImplicitExprUnclosed()
|
||||||
{
|
{
|
||||||
|
// ParseBlockShouldReportErrorAndTerminateAtEOFIfParenInImplicitExpressionUnclosed
|
||||||
ParseBlockTest("Foo(Bar(Baz)" + Environment.NewLine
|
ParseBlockTest("Foo(Bar(Baz)" + Environment.NewLine
|
||||||
+ "Biz" + Environment.NewLine
|
+ "Biz" + Environment.NewLine
|
||||||
+ "Boz");
|
+ "Boz");
|
||||||
|
|
@ -107,8 +112,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
// Test for fix to Dev10 884975 - Incorrect Error Messaging
|
// Test for fix to Dev10 884975 - Incorrect Error Messaging
|
||||||
public void ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed()
|
public void ShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed()
|
||||||
{
|
{
|
||||||
|
// ParseBlockShouldReportErrorAndTerminateAtMarkupIfParenInImplicitExpressionUnclosed
|
||||||
ParseBlockTest("Foo(Bar(Baz)" + Environment.NewLine
|
ParseBlockTest("Foo(Bar(Baz)" + Environment.NewLine
|
||||||
+ "Biz" + Environment.NewLine
|
+ "Biz" + Environment.NewLine
|
||||||
+ "<html>" + Environment.NewLine
|
+ "<html>" + Environment.NewLine
|
||||||
|
|
@ -118,8 +124,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
// Test for fix to Dev10 884975 - Incorrect Error Messaging
|
// Test for fix to Dev10 884975 - Incorrect Error Messaging
|
||||||
public void ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed()
|
public void ShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed()
|
||||||
{
|
{
|
||||||
|
// ParseBlockShouldReportErrorAndTerminateAtEOFIfBracketInImplicitExpressionUnclosed
|
||||||
ParseBlockTest("Foo[Bar[Baz]" + Environment.NewLine
|
ParseBlockTest("Foo[Bar[Baz]" + Environment.NewLine
|
||||||
+ "Biz" + Environment.NewLine
|
+ "Biz" + Environment.NewLine
|
||||||
+ "Boz");
|
+ "Boz");
|
||||||
|
|
@ -127,8 +134,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
// Test for fix to Dev10 884975 - Incorrect Error Messaging
|
// Test for fix to Dev10 884975 - Incorrect Error Messaging
|
||||||
public void ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed()
|
public void ShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExprUnclosed()
|
||||||
{
|
{
|
||||||
|
// ParseBlockShouldReportErrorAndTerminateAtMarkupIfBracketInImplicitExpressionUnclosed
|
||||||
ParseBlockTest("Foo[Bar[Baz]" + Environment.NewLine
|
ParseBlockTest("Foo[Bar[Baz]" + Environment.NewLine
|
||||||
+ "Biz" + Environment.NewLine
|
+ "Biz" + Environment.NewLine
|
||||||
+ "<b>" + Environment.NewLine
|
+ "<b>" + Environment.NewLine
|
||||||
|
|
@ -138,13 +146,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
// Simple EOF handling errors:
|
// Simple EOF handling errors:
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfExplicitCodeBlockUnterminatedAtEOF()
|
public void ReportsErrorIfExplicitCodeBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ var foo = bar; if(foo != null) { bar(); } ");
|
ParseBlockTest("{ var foo = bar; if(foo != null) { bar(); } ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfClassBlockUnterminatedAtEOF()
|
public void ReportsErrorIfClassBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest(
|
ParseBlockTest(
|
||||||
"functions { var foo = bar; if(foo != null) { bar(); } ",
|
"functions { var foo = bar; if(foo != null) { bar(); } ",
|
||||||
|
|
@ -152,138 +160,138 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfIfBlockUnterminatedAtEOF()
|
public void ReportsErrorIfIfBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
RunUnterminatedSimpleKeywordBlock("if");
|
RunUnterminatedSimpleKeywordBlock("if");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfElseBlockUnterminatedAtEOF()
|
public void ReportsErrorIfElseBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ");
|
ParseBlockTest("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfElseIfBlockUnterminatedAtEOF()
|
public void ReportsErrorIfElseIfBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ");
|
ParseBlockTest("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfDoBlockUnterminatedAtEOF()
|
public void ReportsErrorIfDoBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest("do { var foo = bar; if(foo != null) { bar(); } ");
|
ParseBlockTest("do { var foo = bar; if(foo != null) { bar(); } ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfTryBlockUnterminatedAtEOF()
|
public void ReportsErrorIfTryBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest("try { var foo = bar; if(foo != null) { bar(); } ");
|
ParseBlockTest("try { var foo = bar; if(foo != null) { bar(); } ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfCatchBlockUnterminatedAtEOF()
|
public void ReportsErrorIfCatchBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ");
|
ParseBlockTest("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfFinallyBlockUnterminatedAtEOF()
|
public void ReportsErrorIfFinallyBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ");
|
ParseBlockTest("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfForBlockUnterminatedAtEOF()
|
public void ReportsErrorIfForBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
RunUnterminatedSimpleKeywordBlock("for");
|
RunUnterminatedSimpleKeywordBlock("for");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfForeachBlockUnterminatedAtEOF()
|
public void ReportsErrorIfForeachBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
RunUnterminatedSimpleKeywordBlock("foreach");
|
RunUnterminatedSimpleKeywordBlock("foreach");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfWhileBlockUnterminatedAtEOF()
|
public void ReportsErrorIfWhileBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
RunUnterminatedSimpleKeywordBlock("while");
|
RunUnterminatedSimpleKeywordBlock("while");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfSwitchBlockUnterminatedAtEOF()
|
public void ReportsErrorIfSwitchBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
RunUnterminatedSimpleKeywordBlock("switch");
|
RunUnterminatedSimpleKeywordBlock("switch");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfLockBlockUnterminatedAtEOF()
|
public void ReportsErrorIfLockBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
RunUnterminatedSimpleKeywordBlock("lock");
|
RunUnterminatedSimpleKeywordBlock("lock");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReportsErrorIfUsingBlockUnterminatedAtEOF()
|
public void ReportsErrorIfUsingBlockUnterminatedAtEOF()
|
||||||
{
|
{
|
||||||
RunUnterminatedSimpleKeywordBlock("using");
|
RunUnterminatedSimpleKeywordBlock("using");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockRequiresControlFlowStatementsToHaveBraces()
|
public void RequiresControlFlowStatementsToHaveBraces()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(foo) <p>Bar</p> else if(bar) <p>Baz</p> else <p>Boz</p>");
|
ParseBlockTest("if(foo) <p>Bar</p> else if(bar) <p>Baz</p> else <p>Boz</p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockIncludesUnexpectedCharacterInSingleStatementControlFlowStatementError()
|
public void IncludesUnexpectedCharacterInSingleStatementControlFlowStatementError()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(foo)) { var bar = foo; }");
|
ParseBlockTest("if(foo)) { var bar = foo; }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockOutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart()
|
public void OutputsErrorIfAtSignFollowedByLessThanSignAtStatementStart()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(foo) { @<p>Bar</p> }");
|
ParseBlockTest("if(foo) { @<p>Bar</p> }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen()
|
public void TerminatesIfBlockAtEOLWhenRecoveringFromMissingCloseParen()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(foo bar" + Environment.NewLine
|
ParseBlockTest("if(foo bar" + Environment.NewLine
|
||||||
+ "baz");
|
+ "baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen()
|
public void TerminatesForeachBlockAtEOLWhenRecoveringFromMissingCloseParen()
|
||||||
{
|
{
|
||||||
ParseBlockTest("foreach(foo bar" + Environment.NewLine
|
ParseBlockTest("foreach(foo bar" + Environment.NewLine
|
||||||
+ "baz");
|
+ "baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesWhileClauseInDoStatementAtEOLWhenRecoveringFromMissingCloseParen()
|
public void TerminatesWhileClauseInDoStmtAtEOLWhenRecoveringFromMissingCloseParen()
|
||||||
{
|
{
|
||||||
ParseBlockTest("do { } while(foo bar" + Environment.NewLine
|
ParseBlockTest("do { } while(foo bar" + Environment.NewLine
|
||||||
+ "baz");
|
+ "baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen()
|
public void TerminatesUsingBlockAtEOLWhenRecoveringFromMissingCloseParen()
|
||||||
{
|
{
|
||||||
ParseBlockTest("using(foo bar" + Environment.NewLine
|
ParseBlockTest("using(foo bar" + Environment.NewLine
|
||||||
+ "baz");
|
+ "baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockResumesIfStatementAfterOpenParen()
|
public void ResumesIfStatementAfterOpenParen()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(" + Environment.NewLine
|
ParseBlockTest("if(" + Environment.NewLine
|
||||||
+ "else { <p>Foo</p> }");
|
+ "else { <p>Foo</p> }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing()
|
public void TerminatesNormalCSharpStringsAtEOLIfEndQuoteMissing()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("if(foo) {" + Environment.NewLine
|
SingleSpanBlockTest("if(foo) {" + Environment.NewLine
|
||||||
+ " var p = \"foo bar baz" + Environment.NewLine
|
+ " var p = \"foo bar baz" + Environment.NewLine
|
||||||
|
|
@ -292,13 +300,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesNormalStringAtEndOfFile()
|
public void TerminatesNormalStringAtEndOfFile()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah");
|
SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesVerbatimStringAtEndOfFile()
|
public void TerminatesVerbatimStringAtEndOfFile()
|
||||||
{
|
{
|
||||||
SingleSpanBlockTest("if(foo) { var foo = @\"blah " + Environment.NewLine
|
SingleSpanBlockTest("if(foo) { var foo = @\"blah " + Environment.NewLine
|
||||||
+ "blah; " + Environment.NewLine
|
+ "blah; " + Environment.NewLine
|
||||||
|
|
@ -308,7 +316,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement()
|
public void CorrectlyParsesMarkupIncorrectyAssumedToBeWithinAStatement()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(foo) {" + Environment.NewLine
|
ParseBlockTest("if(foo) {" + Environment.NewLine
|
||||||
+ " var foo = \"foo bar baz" + Environment.NewLine
|
+ " var foo = \"foo bar baz" + Environment.NewLine
|
||||||
|
|
@ -317,13 +325,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyParsesAtSignInDelimitedBlock()
|
public void CorrectlyParsesAtSignInDelimitedBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("(Request[\"description\"] ?? @photo.Description)");
|
ParseBlockTest("(Request[\"description\"] ?? @photo.Description)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyRecoversFromMissingCloseParenInExpressionWithinCode()
|
public void CorrectlyRecoversFromMissingCloseParenInExpressionWithinCode()
|
||||||
{
|
{
|
||||||
ParseBlockTest(@"{string.Format(<html></html>}");
|
ParseBlockTest(@"{string.Format(<html></html>}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,37 +9,38 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class CSharpExplicitExpressionTest : CsHtmlCodeParserTestBase
|
public class CSharpExplicitExpressionTest : CsHtmlCodeParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty()
|
public void ShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@()");
|
ParseBlockTest("@()");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression()
|
public void ShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpr()
|
||||||
{
|
{
|
||||||
|
// ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression
|
||||||
ParseBlockTest("@(");
|
ParseBlockTest("@(");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldAcceptEscapedQuoteInNonVerbatimStrings()
|
public void ShouldAcceptEscapedQuoteInNonVerbatimStrings()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@(\"\\\"\")");
|
ParseBlockTest("@(\"\\\"\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldAcceptEscapedQuoteInVerbatimStrings()
|
public void ShouldAcceptEscapedQuoteInVerbatimStrings()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@(@\"\"\"\")");
|
ParseBlockTest("@(@\"\"\"\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings()
|
public void ShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@(@\"\"\"\"\"\")");
|
ParseBlockTest("@(@\"\"\"\"\"\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldAcceptMultiLineVerbatimStrings()
|
public void ShouldAcceptMultiLineVerbatimStrings()
|
||||||
{
|
{
|
||||||
ParseBlockTest(@"@(@""" + Environment.NewLine
|
ParseBlockTest(@"@(@""" + Environment.NewLine
|
||||||
+ @"Foo" + Environment.NewLine
|
+ @"Foo" + Environment.NewLine
|
||||||
|
|
@ -49,25 +50,25 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings()
|
public void ShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@(\"\\\"hello, world\\\"\")");
|
ParseBlockTest("@(\"\\\"hello, world\\\"\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldAcceptMultipleEscapedQuotesInVerbatimStrings()
|
public void ShouldAcceptMultipleEscapedQuotesInVerbatimStrings()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@(@\"\"\"hello, world\"\"\")");
|
ParseBlockTest("@(@\"\"\"hello, world\"\"\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings()
|
public void ShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@(\"\\\"\\\"\")");
|
ParseBlockTest("@(\"\\\"\\\"\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings()
|
public void ShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@(@\"\"\"\"\"\")");
|
ParseBlockTest("@(@\"\"\"\"\"\")");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,210 +8,210 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class CSharpImplicitExpressionTest : CsHtmlCodeParserTestBase
|
public class CSharpImplicitExpressionTest : CsHtmlCodeParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket1()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket1()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val??[");
|
ImplicitExpressionTest("val??[");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket2()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket2()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val??[0");
|
ImplicitExpressionTest("val??[0");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket3()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket3()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[");
|
ImplicitExpressionTest("val?[");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket4()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket4()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?(");
|
ImplicitExpressionTest("val?(");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket5()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket5()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[more");
|
ImplicitExpressionTest("val?[more");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket6()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket6()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[0]");
|
ImplicitExpressionTest("val?[0]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket7()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket7()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[<p>");
|
ImplicitExpressionTest("val?[<p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket8()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket8()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[more.<p>");
|
ImplicitExpressionTest("val?[more.<p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket9()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket9()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val??[more<p>");
|
ImplicitExpressionTest("val??[more<p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket10()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket10()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[-1]?");
|
ImplicitExpressionTest("val?[-1]?");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket11()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket11()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[abc]?[def");
|
ImplicitExpressionTest("val?[abc]?[def");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket12()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket12()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[abc]?[2]");
|
ImplicitExpressionTest("val?[abc]?[2]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket13()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket13()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[abc]?.more?[def]");
|
ImplicitExpressionTest("val?[abc]?.more?[def]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket14()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket14()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[abc]?.more?.abc");
|
ImplicitExpressionTest("val?[abc]?.more?.abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket15()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket15()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[null ?? true]");
|
ImplicitExpressionTest("val?[null ?? true]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket16()
|
public void ParsesNullConditionalOperatorImplicitExpression_Bracket16()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?[abc?.gef?[-1]]");
|
ImplicitExpressionTest("val?[abc?.gef?[-1]]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot1()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot1()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?");
|
ImplicitExpressionTest("val?");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot2()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot2()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val??");
|
ImplicitExpressionTest("val??");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot3()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot3()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val??more");
|
ImplicitExpressionTest("val??more");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot4()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot4()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?!");
|
ImplicitExpressionTest("val?!");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot5()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot5()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?.");
|
ImplicitExpressionTest("val?.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot6()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot6()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val??.");
|
ImplicitExpressionTest("val??.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot7()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot7()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?.(abc)");
|
ImplicitExpressionTest("val?.(abc)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot8()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot8()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?.<p>");
|
ImplicitExpressionTest("val?.<p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot9()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot9()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?.more");
|
ImplicitExpressionTest("val?.more");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot10()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot10()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?.more<p>");
|
ImplicitExpressionTest("val?.more<p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot11()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot11()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val??.more<p>");
|
ImplicitExpressionTest("val??.more<p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot12()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot12()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?.more(false)?.<p>");
|
ImplicitExpressionTest("val?.more(false)?.<p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot13()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot13()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?.more(false)?.abc");
|
ImplicitExpressionTest("val?.more(false)?.abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Dot14()
|
public void ParsesNullConditionalOperatorImplicitExpression_Dot14()
|
||||||
{
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
ImplicitExpressionTest("val?.more(null ?? true)?.abc");
|
ImplicitExpressionTest("val?.more(null ?? true)?.abc");
|
||||||
|
|
@ -224,145 +224,149 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAcceptsNonEnglishCharactersThatAreValidIdentifiers()
|
public void AcceptsNonEnglishCharactersThatAreValidIdentifiers()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("हळूँजद॔.");
|
ImplicitExpressionTest("हळूँजद॔.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockOutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition()
|
public void OutputsZeroLengthCodeSpanIfInvalidCharacterFollowsTransition()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@/");
|
ParseBlockTest("@/");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockOutputsZeroLengthCodeSpanIfEOFOccursAfterTransition()
|
public void OutputsZeroLengthCodeSpanIfEOFOccursAfterTransition()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@");
|
ParseBlockTest("@");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsSlashesWithinComplexImplicitExpressions()
|
public void SupportsSlashesWithinComplexImplicitExpressions()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("DataGridColumn.Template(\"Years of Service\", e => (int)Math.Round((DateTime.Now - dt).TotalDays / 365))");
|
ImplicitExpressionTest("DataGridColumn.Template(\"Years of Service\", e => (int)Math.Round((DateTime.Now - dt).TotalDays / 365))");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesSingleIdentifierAsImplicitExpression()
|
public void ParsesSingleIdentifierAsImplicitExpression()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo");
|
ImplicitExpressionTest("foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodDoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace()
|
public void DoesNotAcceptSemicolonIfExpressionTerminatedByWhitespace()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo ;");
|
ImplicitExpressionTest("foo ;");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodIgnoresSemicolonAtEndOfSimpleImplicitExpression()
|
public void IgnoresSemicolonAtEndOfSimpleImplicitExpression()
|
||||||
{
|
{
|
||||||
RunTrailingSemicolonTest("foo");
|
RunTrailingSemicolonTest("foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodParsesDottedIdentifiersAsImplicitExpression()
|
public void ParsesDottedIdentifiersAsImplicitExpression()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo.bar.baz");
|
ImplicitExpressionTest("foo.bar.baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodIgnoresSemicolonAtEndOfDottedIdentifiers()
|
public void IgnoresSemicolonAtEndOfDottedIdentifiers()
|
||||||
{
|
{
|
||||||
RunTrailingSemicolonTest("foo.bar.baz");
|
RunTrailingSemicolonTest("foo.bar.baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodDoesNotIncludeDotAtEOFInImplicitExpression()
|
public void DoesNotIncludeDotAtEOFInImplicitExpression()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo.bar.");
|
ImplicitExpressionTest("foo.bar.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression1()
|
public void DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr1()
|
||||||
{
|
{
|
||||||
|
// ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression1
|
||||||
ImplicitExpressionTest("foo.bar.0");
|
ImplicitExpressionTest("foo.bar.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression2()
|
public void DoesNotIncludeDotFollowedByInvalidIdentifierCharInImplicitExpr2()
|
||||||
{
|
{
|
||||||
|
// ParseBlockMethodDoesNotIncludeDotFollowedByInvalidIdentifierCharacterInImplicitExpression2
|
||||||
ImplicitExpressionTest("foo.bar.</p>");
|
ImplicitExpressionTest("foo.bar.</p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodDoesNotIncludeSemicolonAfterDot()
|
public void DoesNotIncludeSemicolonAfterDot()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo.bar.;");
|
ImplicitExpressionTest("foo.bar.;");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockMethodTerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpression()
|
public void TerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpr()
|
||||||
{
|
{
|
||||||
|
// ParseBlockMethodTerminatesAfterIdentifierUnlessFollowedByDotOrParenInImplicitExpression
|
||||||
ImplicitExpressionTest("foo.bar</p>");
|
ImplicitExpressionTest("foo.bar</p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockProperlyParsesParenthesesAndBalancesThemInImplicitExpression()
|
public void ProperlyParsesParenthesesAndBalancesThemInImplicitExpression()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest(@"foo().bar(""bi\""z"", 4)(""chained method; call"").baz(@""bo""""z"", '\'', () => { return 4; }, (4+5+new { foo = bar[4] }))");
|
ImplicitExpressionTest(@"foo().bar(""bi\""z"", 4)(""chained method; call"").baz(@""bo""""z"", '\'', () => { return 4; }, (4+5+new { foo = bar[4] }))");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockProperlyParsesBracketsAndBalancesThemInImplicitExpression()
|
public void ProperlyParsesBracketsAndBalancesThemInImplicitExpression()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest(@"foo.bar[4 * (8 + 7)][""fo\""o""].baz");
|
ImplicitExpressionTest(@"foo.bar[4 * (8 + 7)][""fo\""o""].baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesImplicitExpressionAtHtmlEndTag()
|
public void TerminatesImplicitExpressionAtHtmlEndTag()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo().bar.baz</p>zoop");
|
ImplicitExpressionTest("foo().bar.baz</p>zoop");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesImplicitExpressionAtHtmlStartTag()
|
public void TerminatesImplicitExpressionAtHtmlStartTag()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo().bar.baz<p>zoop");
|
ImplicitExpressionTest("foo().bar.baz<p>zoop");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesImplicitExpressionBeforeDotIfDotNotFollowedByIdentifierStartCharacter()
|
public void TerminatesImplicitExprBeforeDotIfDotNotFollowedByIdentifierStartChar()
|
||||||
{
|
{
|
||||||
|
// ParseBlockTerminatesImplicitExpressionBeforeDotIfDotNotFollowedByIdentifierStartCharacter
|
||||||
ImplicitExpressionTest("foo().bar.baz.42");
|
ImplicitExpressionTest("foo().bar.baz.42");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockStopsBalancingParenthesesAtEOF()
|
public void StopsBalancingParenthesesAtEOF()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo(()");
|
ImplicitExpressionTest("foo(()");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace()
|
public void TerminatesImplicitExpressionIfCloseParenFollowedByAnyWhiteSpace()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo.bar() (baz)");
|
ImplicitExpressionTest("foo.bar() (baz)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace()
|
public void TerminatesImplicitExpressionIfIdentifierFollowedByAnyWhiteSpace()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo .bar() (baz)");
|
ImplicitExpressionTest("foo .bar() (baz)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace()
|
public void TerminatesImplicitExpressionAtLastValidPointIfDotFollowedByWhitespace()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("foo. bar() (baz)");
|
ImplicitExpressionTest("foo. bar() (baz)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockOutputExpressionIfModuleTokenNotFollowedByBrace()
|
public void OutputExpressionIfModuleTokenNotFollowedByBrace()
|
||||||
{
|
{
|
||||||
ImplicitExpressionTest("module.foo()");
|
ImplicitExpressionTest("module.foo()");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class CSharpSectionTest : CsHtmlMarkupParserTestBase
|
public class CSharpSectionTest : CsHtmlMarkupParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockCapturesNewlineImmediatelyFollowing()
|
public void CapturesNewlineImmediatelyFollowing()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section" + Environment.NewLine,
|
"@section" + Environment.NewLine,
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockCapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace()
|
public void CapturesWhitespaceToEndOfLineInSectionStatementMissingOpenBrace()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section Foo " + Environment.NewLine + " ",
|
"@section Foo " + Environment.NewLine + " ",
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockCapturesWhitespaceToEndOfLineInSectionStatementMissingName()
|
public void CapturesWhitespaceToEndOfLineInSectionStatementMissingName()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section " + Environment.NewLine + " ",
|
"@section " + Environment.NewLine + " ",
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockIgnoresSectionUnlessAllLowerCase()
|
public void IgnoresSectionUnlessAllLowerCase()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@Section foo",
|
"@Section foo",
|
||||||
|
|
@ -42,16 +42,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartCharacter()
|
public void ReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartChar()
|
||||||
{
|
{
|
||||||
|
// ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfKeywordNotFollowedByIdentifierStartCharacter
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section 9 { <p>Foo</p> }",
|
"@section 9 { <p>Foo</p> }",
|
||||||
new[] { SectionDirective.Directive });
|
new[] { SectionDirective.Directive });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace()
|
public void ReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace()
|
||||||
{
|
{
|
||||||
|
// ParseSectionBlockReportsErrorAndTerminatesSectionBlockIfNameNotFollowedByOpenBrace
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo-bar { <p>Foo</p> }",
|
"@section foo-bar { <p>Foo</p> }",
|
||||||
new[] { SectionDirective.Directive });
|
new[] { SectionDirective.Directive });
|
||||||
|
|
@ -66,7 +68,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockHandlesEOFAfterOpenBrace()
|
public void HandlesEOFAfterOpenBrace()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo {",
|
"@section foo {",
|
||||||
|
|
@ -74,7 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockHandlesEOFAfterOpenContent1()
|
public void HandlesEOFAfterOpenContent1()
|
||||||
{
|
{
|
||||||
|
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
|
|
@ -83,7 +85,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockHandlesEOFAfterOpenContent2()
|
public void HandlesEOFAfterOpenContent2()
|
||||||
{
|
{
|
||||||
|
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
|
|
@ -92,7 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockHandlesEOFAfterOpenContent3()
|
public void HandlesEOFAfterOpenContent3()
|
||||||
{
|
{
|
||||||
|
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
|
|
@ -101,7 +103,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockHandlesEOFAfterOpenContent4()
|
public void HandlesEOFAfterOpenContent4()
|
||||||
{
|
{
|
||||||
|
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
|
|
@ -110,7 +112,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockHandlesUnterminatedSection()
|
public void HandlesUnterminatedSection()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo { <p>Foo{}</p>",
|
"@section foo { <p>Foo{}</p>",
|
||||||
|
|
@ -118,7 +120,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockHandlesUnterminatedSectionWithNestedIf()
|
public void HandlesUnterminatedSectionWithNestedIf()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var newLine = Environment.NewLine;
|
var newLine = Environment.NewLine;
|
||||||
|
|
@ -134,8 +136,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockReportsErrorAndAcceptsWhitespaceToEndOfLineIfSectionNotFollowedByOpenBrace()
|
public void ReportsErrorAndAcceptsWhitespaceToEOLIfSectionNotFollowedByOpenBrace()
|
||||||
{
|
{
|
||||||
|
// ParseSectionBlockReportsErrorAndAcceptsWhitespaceToEndOfLineIfSectionNotFollowedByOpenBrace
|
||||||
// Arrange
|
// Arrange
|
||||||
var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive);
|
var chunkGenerator = new DirectiveChunkGenerator(SectionDirective.Directive);
|
||||||
chunkGenerator.Diagnostics.Add(
|
chunkGenerator.Diagnostics.Add(
|
||||||
|
|
@ -151,7 +154,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockAcceptsOpenBraceMultipleLinesBelowSectionName()
|
public void AcceptsOpenBraceMultipleLinesBelowSectionName()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo "
|
"@section foo "
|
||||||
|
|
@ -168,7 +171,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockParsesNamedSectionCorrectly()
|
public void ParsesNamedSectionCorrectly()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo { <p>Foo</p> }",
|
"@section foo { <p>Foo</p> }",
|
||||||
|
|
@ -176,7 +179,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockDoesNotRequireSpaceBetweenSectionNameAndOpenBrace()
|
public void DoesNotRequireSpaceBetweenSectionNameAndOpenBrace()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo{ <p>Foo</p> }",
|
"@section foo{ <p>Foo</p> }",
|
||||||
|
|
@ -184,7 +187,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockBalancesBraces()
|
public void BalancesBraces()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo { <script>(function foo() { return 1; })();</script> }",
|
"@section foo { <script>(function foo() { return 1; })();</script> }",
|
||||||
|
|
@ -192,7 +195,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockAllowsBracesInCSharpExpression()
|
public void AllowsBracesInCSharpExpression()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo { I really want to render a close brace, so here I go: @(\"}\") }",
|
"@section foo { I really want to render a close brace, so here I go: @(\"}\") }",
|
||||||
|
|
@ -211,8 +214,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlockNoWhitespace()
|
public void SectionCorrectlyTerminatedWhenCloseBraceFollowsCodeBlockNoWhitespace()
|
||||||
{
|
{
|
||||||
|
// SectionIsCorrectlyTerminatedWhenCloseBraceImmediatelyFollowsCodeBlockNoWhitespace
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section Foo {" + Environment.NewLine
|
"@section Foo {" + Environment.NewLine
|
||||||
+ "@if(true) {" + Environment.NewLine
|
+ "@if(true) {" + Environment.NewLine
|
||||||
|
|
@ -221,7 +225,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockCorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup()
|
public void CorrectlyTerminatesWhenCloseBraceImmediatelyFollowsMarkup()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section foo {something}",
|
"@section foo {something}",
|
||||||
|
|
@ -229,7 +233,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockParsesComment()
|
public void ParsesComment()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section s {<!-- -->}",
|
"@section s {<!-- -->}",
|
||||||
|
|
@ -239,7 +243,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
// This was a user reported bug (codeplex #710), the section parser wasn't handling
|
// This was a user reported bug (codeplex #710), the section parser wasn't handling
|
||||||
// comments.
|
// comments.
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockParsesCommentWithDelimiters()
|
public void ParsesCommentWithDelimiters()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section s {<!-- > \" '-->}",
|
"@section s {<!-- > \" '-->}",
|
||||||
|
|
@ -247,7 +251,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockCommentRecoversFromUnclosedTag()
|
public void CommentRecoversFromUnclosedTag()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section s {" + Environment.NewLine + "<a" + Environment.NewLine + "<!-- > \" '-->}",
|
"@section s {" + Environment.NewLine + "<a" + Environment.NewLine + "<!-- > \" '-->}",
|
||||||
|
|
@ -255,7 +259,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlockParsesXmlProcessingInstruction()
|
public void ParsesXmlProcessingInstruction()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
"@section s { <? xml bleh ?>}",
|
"@section s { <? xml bleh ?>}",
|
||||||
|
|
@ -263,13 +267,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlock_WithDoubleTransition1()
|
public void _WithDoubleTransition1()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@section s {<span foo='@@' />}", new[] { SectionDirective.Directive });
|
ParseDocumentTest("@section s {<span foo='@@' />}", new[] { SectionDirective.Directive });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseSectionBlock_WithDoubleTransition2()
|
public void _WithDoubleTransition2()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@section s {<span foo='@DateTime.Now @@' />}", new[] { SectionDirective.Directive });
|
ParseDocumentTest("@section s {<span foo='@DateTime.Now @@' />}", new[] { SectionDirective.Directive });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockBalancesBracesOutsideStringsIfFirstCharacterIsBraceAndReturnsSpanOfTypeCode()
|
public void BalancesBracesOutsideStringsIfFirstCharIsBraceAndReturnsSpanOfTypeCode()
|
||||||
{
|
{
|
||||||
|
// ParseBlockBalancesBracesOutsideStringsIfFirstCharacterIsBraceAndReturnsSpanOfTypeCode
|
||||||
ParseBlockTest("{foo\"b}ar\" if(condition) { string.Format(\"{0}\"); } }");
|
ParseBlockTest("{foo\"b}ar\" if(condition) { string.Format(\"{0}\"); } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockBalancesParensOutsideStringsIfFirstCharacterIsParenAndReturnsSpanOfTypeExpression()
|
public void BalancesParensOutsideStringsIfFirstCharIsParenAndReturnsSpanOfTypeExpr()
|
||||||
{
|
{
|
||||||
|
// ParseBlockBalancesParensOutsideStringsIfFirstCharacterIsParenAndReturnsSpanOfTypeExpression
|
||||||
ParseBlockTest("(foo\"b)ar\" if(condition) { string.Format(\"{0}\"); } )");
|
ParseBlockTest("(foo\"b)ar\" if(condition) { string.Format(\"{0}\"); } )");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,79 +9,82 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class CSharpTemplateTest : CsHtmlCodeParserTestBase
|
public class CSharpTemplateTest : CsHtmlCodeParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesSingleLineTemplate()
|
public void HandlesSingleLineTemplate()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ var foo = @: bar" + Environment.NewLine + "; }");
|
ParseBlockTest("{ var foo = @: bar" + Environment.NewLine + "; }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesSingleLineImmediatelyFollowingStatementChar()
|
public void HandlesSingleLineImmediatelyFollowingStatementChar()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{i@: bar" + Environment.NewLine + "}");
|
ParseBlockTest("{i@: bar" + Environment.NewLine + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesSimpleTemplateInExplicitExpressionParens()
|
public void HandlesSimpleTemplateInExplicitExpressionParens()
|
||||||
{
|
{
|
||||||
ParseBlockTest("(Html.Repeat(10, @<p>Foo #@item</p>))");
|
ParseBlockTest("(Html.Repeat(10, @<p>Foo #@item</p>))");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesSimpleTemplateInImplicitExpressionParens()
|
public void HandlesSimpleTemplateInImplicitExpressionParens()
|
||||||
{
|
{
|
||||||
ParseBlockTest("Html.Repeat(10, @<p>Foo #@item</p>)");
|
ParseBlockTest("Html.Repeat(10, @<p>Foo #@item</p>)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesTwoTemplatesInImplicitExpressionParens()
|
public void HandlesTwoTemplatesInImplicitExpressionParens()
|
||||||
{
|
{
|
||||||
ParseBlockTest("Html.Repeat(10, @<p>Foo #@item</p>, @<p>Foo #@item</p>)");
|
ParseBlockTest("Html.Repeat(10, @<p>Foo #@item</p>, @<p>Foo #@item</p>)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInImplicitExpressionParens()
|
public void ProducesErrorButCorrectlyParsesNestedTemplateInImplicitExprParens()
|
||||||
{
|
{
|
||||||
|
// ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInImplicitExpressionParens
|
||||||
ParseBlockTest("Html.Repeat(10, @<p>Foo #@Html.Repeat(10, @<p>@item</p>)</p>)");
|
ParseBlockTest("Html.Repeat(10, @<p>Foo #@Html.Repeat(10, @<p>@item</p>)</p>)");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesSimpleTemplateInStatementWithinCodeBlock()
|
public void HandlesSimpleTemplateInStatementWithinCodeBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @<p>Foo #@item</p>); }");
|
ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @<p>Foo #@item</p>); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesTwoTemplatesInStatementWithinCodeBlock()
|
public void HandlesTwoTemplatesInStatementWithinCodeBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @<p>Foo #@item</p>, @<p>Foo #@item</p>); }");
|
ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @<p>Foo #@item</p>, @<p>Foo #@item</p>); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinCodeBlock()
|
public void ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinCodeBlock()
|
||||||
{
|
{
|
||||||
|
// ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinCodeBlock
|
||||||
ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @<p>Foo #@Html.Repeat(10, @<p>@item</p>)</p>); }");
|
ParseBlockTest("foreach(foo in Bar) { Html.ExecuteTemplate(foo, @<p>Foo #@Html.Repeat(10, @<p>@item</p>)</p>); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesSimpleTemplateInStatementWithinStatementBlock()
|
public void HandlesSimpleTemplateInStatementWithinStatementBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @<p>Foo #@item</p>); }");
|
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @<p>Foo #@item</p>); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlessTwoTemplatesInStatementWithinStatementBlock()
|
public void HandlessTwoTemplatesInStatementWithinStatementBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @<p>Foo #@item</p>, @<p>Foo #@item</p>); }");
|
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @<p>Foo #@item</p>, @<p>Foo #@item</p>); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinStatementBlock()
|
public void ProducesErrorButCorrectlyParsesNestedTemplateInStmtWithinStmtBlock()
|
||||||
{
|
{
|
||||||
|
// ParseBlockProducesErrorButCorrectlyParsesNestedTemplateInStatementWithinStatementBlock
|
||||||
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @<p>Foo #@Html.Repeat(10, @<p>@item</p>)</p>); }");
|
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @<p>Foo #@Html.Repeat(10, @<p>@item</p>)</p>); }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlock_WithDoubleTransition_DoesNotThrow()
|
public void _WithDoubleTransition_DoesNotThrow()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @<p foo='@@'>Foo #@item</p>); }");
|
ParseBlockTest("{ var foo = bar; Html.ExecuteTemplate(foo, @<p foo='@@'>Foo #@item</p>); }");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockGivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode()
|
public void GivesSpacesToCodeOnAtTagTemplateTransitionInDesignTimeMode()
|
||||||
{
|
{
|
||||||
ParseBlockTest("Foo( @<p>Foo</p> )", designTime: true);
|
ParseBlockTest("Foo( @<p>Foo</p> )", designTime: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockGivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode()
|
public void GivesSpacesToCodeOnAtColonTemplateTransitionInDesignTimeMode()
|
||||||
{
|
{
|
||||||
ParseBlockTest("Foo( " + Environment.NewLine
|
ParseBlockTest("Foo( " + Environment.NewLine
|
||||||
+ "@:<p>Foo</p> " + Environment.NewLine
|
+ "@:<p>Foo</p> " + Environment.NewLine
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockGivesSpacesToCodeOnTagTransitionInDesignTimeMode()
|
public void GivesSpacesToCodeOnTagTransitionInDesignTimeMode()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{" + Environment.NewLine
|
ParseBlockTest("{" + Environment.NewLine
|
||||||
+ " <p>Foo</p> " + Environment.NewLine
|
+ " <p>Foo</p> " + Environment.NewLine
|
||||||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockGivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode()
|
public void GivesSpacesToCodeOnInvalidAtTagTransitionInDesignTimeMode()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{" + Environment.NewLine
|
ParseBlockTest("{" + Environment.NewLine
|
||||||
+ " @<p>Foo</p> " + Environment.NewLine
|
+ " @<p>Foo</p> " + Environment.NewLine
|
||||||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockGivesSpacesToCodeOnAtColonTransitionInDesignTimeMode()
|
public void GivesSpacesToCodeOnAtColonTransitionInDesignTimeMode()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{" + Environment.NewLine
|
ParseBlockTest("{" + Environment.NewLine
|
||||||
+ " @:<p>Foo</p> " + Environment.NewLine
|
+ " @:<p>Foo</p> " + Environment.NewLine
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldSupportSingleLineMarkupContainingStatementBlock()
|
public void ShouldSupportSingleLineMarkupContainingStatementBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("Repeat(10," + Environment.NewLine
|
ParseBlockTest("Repeat(10," + Environment.NewLine
|
||||||
+ " @: @{}" + Environment.NewLine
|
+ " @: @{}" + Environment.NewLine
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockShouldSupportMarkupWithoutPreceedingWhitespace()
|
public void ShouldSupportMarkupWithoutPreceedingWhitespace()
|
||||||
{
|
{
|
||||||
ParseBlockTest("foreach(var file in files){" + Environment.NewLine
|
ParseBlockTest("foreach(var file in files){" + Environment.NewLine
|
||||||
+ Environment.NewLine
|
+ Environment.NewLine
|
||||||
|
|
@ -74,8 +74,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockGivesAllWhitespaceOnSameLineExcludingPreceedingNewlineButIncludingTrailingNewLineToMarkup()
|
public void GivesAllWhitespaceOnSameLineWithTrailingNewLineToMarkupExclPreceedingNewline()
|
||||||
{
|
{
|
||||||
|
// ParseBlockGivesAllWhitespaceOnSameLineExcludingPreceedingNewlineButIncludingTrailingNewLineToMarkup
|
||||||
ParseBlockTest("if(foo) {" + Environment.NewLine
|
ParseBlockTest("if(foo) {" + Environment.NewLine
|
||||||
+ " var foo = \"After this statement there are 10 spaces\"; " + Environment.NewLine
|
+ " var foo = \"After this statement there are 10 spaces\"; " + Environment.NewLine
|
||||||
+ " <p>" + Environment.NewLine
|
+ " <p>" + Environment.NewLine
|
||||||
|
|
@ -88,19 +89,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsMarkupInIfBodyWithBraces()
|
public void AllowsMarkupInIfBodyWithBraces()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if(foo) { <p>Bar</p> } else if(bar) { <p>Baz</p> } else { <p>Boz</p> }");
|
ParseBlockTest("if(foo) { <p>Bar</p> } else if(bar) { <p>Baz</p> } else { <p>Boz</p> }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsMarkupInIfBodyWithBracesWithinCodeBlock()
|
public void AllowsMarkupInIfBodyWithBracesWithinCodeBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ if(foo) { <p>Bar</p> } else if(bar) { <p>Baz</p> } else { <p>Boz</p> } }");
|
ParseBlockTest("{ if(foo) { <p>Bar</p> } else if(bar) { <p>Baz</p> } else { <p>Boz</p> } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsMarkupInCaseAndDefaultBranchesOfSwitch()
|
public void SupportsMarkupInCaseAndDefaultBranchesOfSwitch()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest("switch(foo) {" + Environment.NewLine
|
ParseBlockTest("switch(foo) {" + Environment.NewLine
|
||||||
|
|
@ -121,7 +122,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock()
|
public void SupportsMarkupInCaseAndDefaultBranchesOfSwitchInCodeBlock()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest("{ switch(foo) {" + Environment.NewLine
|
ParseBlockTest("{ switch(foo) {" + Environment.NewLine
|
||||||
|
|
@ -142,19 +143,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesMarkupStatementOnOpenAngleBracket()
|
public void ParsesMarkupStatementOnOpenAngleBracket()
|
||||||
{
|
{
|
||||||
ParseBlockTest("for(int i = 0; i < 10; i++) { <p>Foo</p> }");
|
ParseBlockTest("for(int i = 0; i < 10; i++) { <p>Foo</p> }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesMarkupStatementOnOpenAngleBracketInCodeBlock()
|
public void ParsesMarkupStatementOnOpenAngleBracketInCodeBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ for(int i = 0; i < 10; i++) { <p>Foo</p> } }");
|
ParseBlockTest("{ for(int i = 0; i < 10; i++) { <p>Foo</p> } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesMarkupStatementOnSwitchCharacterFollowedByColon()
|
public void ParsesMarkupStatementOnSwitchCharacterFollowedByColon()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest("if(foo) { @:Bar" + Environment.NewLine
|
ParseBlockTest("if(foo) { @:Bar" + Environment.NewLine
|
||||||
|
|
@ -162,7 +163,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon()
|
public void ParsesMarkupStatementOnSwitchCharacterFollowedByDoubleColon()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest("if(foo) { @::Sometext" + Environment.NewLine
|
ParseBlockTest("if(foo) { @::Sometext" + Environment.NewLine
|
||||||
|
|
@ -171,7 +172,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon()
|
public void ParsesMarkupStatementOnSwitchCharacterFollowedByTripleColon()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest("if(foo) { @:::Sometext" + Environment.NewLine
|
ParseBlockTest("if(foo) { @:::Sometext" + Environment.NewLine
|
||||||
|
|
@ -179,7 +180,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock()
|
public void ParsesMarkupStatementOnSwitchCharacterFollowedByColonInCodeBlock()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ParseBlockTest("{ if(foo) { @:Bar" + Environment.NewLine
|
ParseBlockTest("{ if(foo) { @:Bar" + Environment.NewLine
|
||||||
|
|
@ -187,19 +188,19 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyReturnsFromMarkupBlockWithPseudoTag()
|
public void CorrectlyReturnsFromMarkupBlockWithPseudoTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("if (i > 0) { <text>;</text> }");
|
ParseBlockTest("if (i > 0) { <text>;</text> }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock()
|
public void CorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{ if (i > 0) { <text>;</text> } }");
|
ParseBlockTest("{ if (i > 0) { <text>;</text> } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsAllKindsOfImplicitMarkupInCodeBlock()
|
public void SupportsAllKindsOfImplicitMarkupInCodeBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{" + Environment.NewLine
|
ParseBlockTest("{" + Environment.NewLine
|
||||||
+ " if(true) {" + Environment.NewLine
|
+ " if(true) {" + Environment.NewLine
|
||||||
|
|
|
||||||
|
|
@ -17,31 +17,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void InnerImplicitExpressionWithOnlySingleAtOutputsZeroLengthCodeSpan()
|
public void InnerImplicitExprWithOnlySingleAtOutputsZeroLengthCodeSpan()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{@}");
|
ParseBlockTest("{@}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void InnerImplicitExpressionDoesNotAcceptDotAfterAt()
|
public void InnerImplicitExprDoesNotAcceptDotAfterAt()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{@.}");
|
ParseBlockTest("{@.}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void InnerImplicitExpressionWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime()
|
public void InnerImplicitExprWithOnlySingleAtAcceptsSingleSpaceOrNewlineAtDesignTime()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{" + Environment.NewLine + " @" + Environment.NewLine + "}", designTime: true);
|
ParseBlockTest("{" + Environment.NewLine + " @" + Environment.NewLine + "}", designTime: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void InnerImplicitExpressionDoesNotAcceptTrailingNewlineInRunTimeMode()
|
public void InnerImplicitExprDoesNotAcceptTrailingNewlineInRunTimeMode()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{@foo." + Environment.NewLine + "}");
|
ParseBlockTest("{@foo." + Environment.NewLine + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void InnerImplicitExpressionAcceptsTrailingNewlineInDesignTimeMode()
|
public void InnerImplicitExprAcceptsTrailingNewlineInDesignTimeMode()
|
||||||
{
|
{
|
||||||
ParseBlockTest("{@foo." + Environment.NewLine + "}", designTime: true);
|
ParseBlockTest("{@foo." + Environment.NewLine + "}", designTime: true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class CSharpWhitespaceHandlingTest : CsHtmlMarkupParserTestBase
|
public class CSharpWhitespaceHandlingTest : CsHtmlMarkupParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void StatementBlockDoesNotAcceptTrailingNewlineIfNewlinesAreSignificantToAncestor()
|
public void StmtBlockDoesNotAcceptTrailingNewlineIfTheyAreSignificantToAncestor()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@: @if (true) { }" + Environment.NewLine + "}");
|
ParseBlockTest("@: @if (true) { }" + Environment.NewLine + "}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class HtmlBlockTest : CsHtmlMarkupParserTestBase
|
public class HtmlBlockTest : CsHtmlMarkupParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesUnbalancedTripleDashHTMLComments()
|
public void HandlesUnbalancedTripleDashHTMLComments()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(
|
ParseDocumentTest(
|
||||||
@"@{
|
@"@{
|
||||||
|
|
@ -18,14 +18,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesOpenAngleAtEof()
|
public void HandlesOpenAngleAtEof()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{" + Environment.NewLine
|
ParseDocumentTest("@{" + Environment.NewLine
|
||||||
+ "<");
|
+ "<");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockHandlesOpenAngleWithProperTagFollowingIt()
|
public void HandlesOpenAngleWithProperTagFollowingIt()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{" + Environment.NewLine
|
ParseDocumentTest("@{" + Environment.NewLine
|
||||||
+ "<" + Environment.NewLine
|
+ "<" + Environment.NewLine
|
||||||
|
|
@ -41,104 +41,104 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsStartAndEndTagsToDifferInCase()
|
public void AllowsStartAndEndTagsToDifferInCase()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<li><p>Foo</P></lI>");
|
ParseBlockTest("<li><p>Foo</P></lI>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon()
|
public void ReadsToEndOfLineIfFirstCharacterAfterTransitionIsColon()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@:<li>Foo Bar Baz" + Environment.NewLine
|
ParseBlockTest("@:<li>Foo Bar Baz" + Environment.NewLine
|
||||||
+ "bork");
|
+ "bork");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockStopsParsingSingleLineBlockAtEOFIfNoEOLReached()
|
public void StopsParsingSingleLineBlockAtEOFIfNoEOLReached()
|
||||||
{
|
{
|
||||||
ParseBlockTest("@:foo bar");
|
ParseBlockTest("@:foo bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockStopsAtMatchingCloseTagToStartTag()
|
public void StopsAtMatchingCloseTagToStartTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<a><b></b></a><c></c>");
|
ParseBlockTest("<a><b></b></a><c></c>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag()
|
public void ParsesUntilMatchingEndTagIfFirstNonWhitespaceCharacterIsStartTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<baz><boz><biz></biz></boz></baz>");
|
ParseBlockTest("<baz><boz><biz></biz></boz></baz>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag()
|
public void AllowsUnclosedTagsAsLongAsItCanRecoverToAnExpectedEndTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><bar><baz></foo>");
|
ParseBlockTest("<foo><bar><baz></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockWithSelfClosingTagJustEmitsTag()
|
public void WithSelfClosingTagJustEmitsTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo />");
|
ParseBlockTest("<foo />");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCanHandleSelfClosingTagsWithinBlock()
|
public void CanHandleSelfClosingTagsWithinBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><bar /></foo>");
|
ParseBlockTest("<foo><bar /></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsTagsWithAttributes()
|
public void SupportsTagsWithAttributes()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo bar=\"baz\"><biz><boz zoop=zork/></biz></foo>");
|
ParseBlockTest("<foo bar=\"baz\"><biz><boz zoop=zork/></biz></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsCloseAngleBracketInAttributeValueIfDoubleQuoted()
|
public void AllowsCloseAngleBracketInAttributeValueIfDoubleQuoted()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><bar baz=\">\" /></foo>");
|
ParseBlockTest("<foo><bar baz=\">\" /></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsCloseAngleBracketInAttributeValueIfSingleQuoted()
|
public void AllowsCloseAngleBracketInAttributeValueIfSingleQuoted()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><bar baz=\'>\' /></foo>");
|
ParseBlockTest("<foo><bar baz=\'>\' /></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsSlashInAttributeValueIfDoubleQuoted()
|
public void AllowsSlashInAttributeValueIfDoubleQuoted()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><bar baz=\"/\"></bar></foo>");
|
ParseBlockTest("<foo><bar baz=\"/\"></bar></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsSlashInAttributeValueIfSingleQuoted()
|
public void AllowsSlashInAttributeValueIfSingleQuoted()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><bar baz=\'/\'></bar></foo>");
|
ParseBlockTest("<foo><bar baz=\'/\'></bar></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesAtEOF()
|
public void TerminatesAtEOF()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo>");
|
ParseBlockTest("<foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsCommentAsBlock()
|
public void SupportsCommentAsBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<!-- foo -->");
|
ParseBlockTest("<!-- foo -->");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsCommentWithExtraDashAsBlock()
|
public void SupportsCommentWithExtraDashAsBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<!-- foo --->");
|
ParseBlockTest("<!-- foo --->");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsCommentWithinBlock()
|
public void SupportsCommentWithinBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo>bar<!-- zoop -->baz</foo>");
|
ParseBlockTest("<foo>bar<!-- zoop -->baz</foo>");
|
||||||
}
|
}
|
||||||
|
|
@ -155,116 +155,117 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockProperlyBalancesCommentStartAndEndTags()
|
public void ProperlyBalancesCommentStartAndEndTags()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<!--<foo></bar>-->");
|
ParseBlockTest("<!--<foo></bar>-->");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesAtEOFWhenParsingComment()
|
public void TerminatesAtEOFWhenParsingComment()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<!--<foo>");
|
ParseBlockTest("<!--<foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockOnlyTerminatesCommentOnFullEndSequence()
|
public void OnlyTerminatesCommentOnFullEndSequence()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<!--<foo>--</bar>-->");
|
ParseBlockTest("<!--<foo>--</bar>-->");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesCommentAtFirstOccurrenceOfEndSequence()
|
public void TerminatesCommentAtFirstOccurrenceOfEndSequence()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><!--<foo></bar-->--></foo>");
|
ParseBlockTest("<foo><!--<foo></bar-->--></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTreatsMalformedTagsAsContent()
|
public void TreatsMalformedTagsAsContent()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo></!-- bar --></foo>");
|
ParseBlockTest("<foo></!-- bar --></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesSGMLDeclarationAsEmptyTag()
|
public void ParsesSGMLDeclarationAsEmptyTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><!DOCTYPE foo bar baz></foo>");
|
ParseBlockTest("<foo><!DOCTYPE foo bar baz></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesSGMLDeclarationAtFirstCloseAngle()
|
public void TerminatesSGMLDeclarationAtFirstCloseAngle()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><!DOCTYPE foo bar> baz></foo>");
|
ParseBlockTest("<foo><!DOCTYPE foo bar> baz></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesXMLProcessingInstructionAsEmptyTag()
|
public void ParsesXMLProcessingInstructionAsEmptyTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><?xml foo bar baz?></foo>");
|
ParseBlockTest("<foo><?xml foo bar baz?></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair()
|
public void TerminatesXMLProcessingInstructionAtQuestionMarkCloseAnglePair()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><?xml foo bar baz?> baz</foo>");
|
ParseBlockTest("<foo><?xml foo bar baz?> baz</foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockDoesNotTerminateXMLProcessingInstructionAtCloseAngleUnlessPreceededByQuestionMark()
|
public void DoesNotTerminateXMLProcInstrAtCloseAngleUnlessPreceededByQuestionMark()
|
||||||
{
|
{
|
||||||
|
// ParseBlockDoesNotTerminateXMLProcessingInstructionAtCloseAngleUnlessPreceededByQuestionMark
|
||||||
ParseBlockTest("<foo><?xml foo bar> baz?></foo>");
|
ParseBlockTest("<foo><?xml foo bar> baz?></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsScriptTagsWithLessThanSignsInThem()
|
public void SupportsScriptTagsWithLessThanSignsInThem()
|
||||||
{
|
{
|
||||||
ParseBlockTest(@"<script>if(foo<bar) { alert(""baz"");)</script>");
|
ParseBlockTest(@"<script>if(foo<bar) { alert(""baz"");)</script>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsScriptTagsWithSpacedLessThanSignsInThem()
|
public void SupportsScriptTagsWithSpacedLessThanSignsInThem()
|
||||||
{
|
{
|
||||||
ParseBlockTest(@"<script>if(foo < bar) { alert(""baz"");)</script>");
|
ParseBlockTest(@"<script>if(foo < bar) { alert(""baz"");)</script>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAcceptsEmptyTextTag()
|
public void AcceptsEmptyTextTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<text/>");
|
ParseBlockTest("<text/>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAcceptsTextTagAsOuterTagButDoesNotRender()
|
public void AcceptsTextTagAsOuterTagButDoesNotRender()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<text>Foo Bar <foo> Baz</text> zoop");
|
ParseBlockTest("<text>Foo Bar <foo> Baz</text> zoop");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockRendersLiteralTextTagIfDoubled()
|
public void RendersLiteralTextTagIfDoubled()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<text><text>Foo Bar <foo> Baz</text></text> zoop");
|
ParseBlockTest("<text><text>Foo Bar <foo> Baz</text></text> zoop");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockDoesNotConsiderPsuedoTagWithinMarkupBlock()
|
public void DoesNotConsiderPsuedoTagWithinMarkupBlock()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><text><bar></bar></foo>");
|
ParseBlockTest("<foo><text><bar></bar></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockStopsParsingMidEmptyTagIfEOFReached()
|
public void StopsParsingMidEmptyTagIfEOFReached()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<br/");
|
ParseBlockTest("<br/");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockCorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement()
|
public void CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<div>Foo @if(true) {} Bar</div>");
|
ParseBlockTest("<div>Foo @if(true) {} Bar</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockIgnoresTagsInContentsOfScriptTag()
|
public void IgnoresTagsInContentsOfScriptTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest(@"<script>foo<bar baz='@boz'></script>");
|
ParseBlockTest(@"<script>foo<bar baz='@boz'></script>");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,43 +13,43 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
private static readonly TestFile Nested1000 = TestFile.Create("TestFiles/nested-1000.html", typeof(HtmlDocumentTest));
|
private static readonly TestFile Nested1000 = TestFile.Create("TestFiles/nested-1000.html", typeof(HtmlDocumentTest));
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_NestedCodeBlockWithMarkupSetsDotAsMarkup()
|
public void NestedCodeBlockWithMarkupSetsDotAsMarkup()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@if (true) { @if(false) { <div>@something.</div> } }");
|
ParseDocumentTest("@if (true) { @if(false) { <div>@something.</div> } }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentOutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString()
|
public void OutputsEmptyBlockWithEmptyMarkupSpanIfContentIsEmptyString()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(string.Empty);
|
ParseDocumentTest(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentOutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan()
|
public void OutputsWhitespaceOnlyContentAsSingleWhitespaceMarkupSpan()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(" ");
|
ParseDocumentTest(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentAcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan()
|
public void AcceptsSwapTokenAtEndOfFileAndOutputsZeroLengthCodeSpan()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@");
|
ParseDocumentTest("@");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentCorrectlyHandlesOddlySpacedHTMLElements()
|
public void CorrectlyHandlesOddlySpacedHTMLElements()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("<div ><p class = 'bar'> Foo </p></div >");
|
ParseDocumentTest("<div ><p class = 'bar'> Foo </p></div >");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentCorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement()
|
public void CorrectlyHandlesSingleLineOfMarkupWithEmbeddedStatement()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("<div>Foo @if(true) {} Bar</div>");
|
ParseDocumentTest("<div>Foo @if(true) {} Bar</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentWithinSectionDoesNotCreateDocumentLevelSpan()
|
public void WithinSectionDoesNotCreateDocumentLevelSpan()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@section Foo {" + Environment.NewLine
|
ParseDocumentTest("@section Foo {" + Environment.NewLine
|
||||||
+ " <html></html>" + Environment.NewLine
|
+ " <html></html>" + Environment.NewLine
|
||||||
|
|
@ -58,25 +58,25 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered()
|
public void ParsesWholeContentAsOneSpanIfNoSwapCharacterEncountered()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("foo baz");
|
ParseDocumentTest("foo baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentHandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput()
|
public void HandsParsingOverToCodeParserWhenAtSignEncounteredAndEmitsOutput()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("foo @bar baz");
|
ParseDocumentTest("foo @bar baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentEmitsAtSignAsMarkupIfAtEndOfFile()
|
public void EmitsAtSignAsMarkupIfAtEndOfFile()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("foo @");
|
ParseDocumentTest("foo @");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentEmitsCodeBlockIfFirstCharacterIsSwapCharacter()
|
public void EmitsCodeBlockIfFirstCharacterIsSwapCharacter()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@bar");
|
ParseDocumentTest("@bar");
|
||||||
}
|
}
|
||||||
|
|
@ -84,107 +84,109 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText()
|
public void ParseDocumentDoesNotSwitchToCodeOnEmailAddressInText()
|
||||||
{
|
{
|
||||||
ParseDocument("example@microsoft.com");
|
ParseDocumentTest("example@microsoft.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentDoesNotSwitchToCodeOnEmailAddressInAttribute()
|
public void DoesNotSwitchToCodeOnEmailAddressInAttribute()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("<a href=\"mailto:example@microsoft.com\">Email me</a>");
|
ParseDocumentTest("<a href=\"mailto:example@microsoft.com\">Email me</a>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentDoesNotReturnErrorOnMismatchedTags()
|
public void DoesNotReturnErrorOnMismatchedTags()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("Foo <div><p></p></p> Baz");
|
ParseDocumentTest("Foo <div><p></p></p> Baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentReturnsOneMarkupSegmentIfNoCodeBlocksEncountered()
|
public void ReturnsOneMarkupSegmentIfNoCodeBlocksEncountered()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("Foo Baz<!--Foo-->Bar<!--F> Qux");
|
ParseDocumentTest("Foo Baz<!--Foo-->Bar<!--F> Qux");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentRendersTextPseudoTagAsMarkup()
|
public void RendersTextPseudoTagAsMarkup()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("Foo <text>Foo</text>");
|
ParseDocumentTest("Foo <text>Foo</text>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentAcceptsEndTagWithNoMatchingStartTag()
|
public void AcceptsEndTagWithNoMatchingStartTag()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("Foo </div> Bar");
|
ParseDocumentTest("Foo </div> Bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentNoLongerSupportsDollarOpenBraceCombination()
|
public void NoLongerSupportsDollarOpenBraceCombination()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("<foo>${bar}</foo>");
|
ParseDocumentTest("<foo>${bar}</foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentIgnoresTagsInContentsOfScriptTag()
|
public void IgnoresTagsInContentsOfScriptTag()
|
||||||
{
|
{
|
||||||
ParseDocumentTest(@"<script>foo<bar baz='@boz'></script>");
|
ParseDocumentTest(@"<script>foo<bar baz='@boz'></script>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentDoesNotRenderExtraNewLineAtTheEndOfVerbatimBlock()
|
public void DoesNotRenderExtraNewLineAtTheEndOfVerbatimBlock()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{\r\n}\r\n<html>");
|
ParseDocumentTest("@{\r\n}\r\n<html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentDoesNotRenderExtraWhitespaceAndNewLineAtTheEndOfVerbatimBlock()
|
public void DoesNotRenderExtraWhitespaceAndNewLineAtTheEndOfVerbatimBlock()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{\r\n} \t\r\n<html>");
|
ParseDocumentTest("@{\r\n} \t\r\n<html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentDoesNotRenderExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByCSharp()
|
public void DoesNotRenderNewlineAfterTextTagInVerbatimBlockIfFollowedByCSharp()
|
||||||
{
|
{
|
||||||
|
// ParseDocumentDoesNotRenderExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByCSharp
|
||||||
ParseDocumentTest("@{<text>Blah</text>\r\n\r\n}<html>");
|
ParseDocumentTest("@{<text>Blah</text>\r\n\r\n}<html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentRendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByHtml()
|
public void RendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByHtml()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{<text>Blah</text>\r\n<input/>\r\n}<html>");
|
ParseDocumentTest("@{<text>Blah</text>\r\n<input/>\r\n}<html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentRendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByMarkupTransition()
|
public void RendersNewlineAfterTextTagInVerbatimBlockIfFollowedByMarkupTransition()
|
||||||
{
|
{
|
||||||
|
// ParseDocumentRendersExtraNewlineAtTheEndTextTagInVerbatimBlockIfFollowedByMarkupTransition
|
||||||
ParseDocumentTest("@{<text>Blah</text>\r\n@: Bleh\r\n}<html>");
|
ParseDocumentTest("@{<text>Blah</text>\r\n@: Bleh\r\n}<html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentDoesNotIgnoreNewLineAtTheEndOfMarkupBlock()
|
public void DoesNotIgnoreNewLineAtTheEndOfMarkupBlock()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{\r\n}\r\n<html>\r\n");
|
ParseDocumentTest("@{\r\n}\r\n<html>\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentDoesNotIgnoreWhitespaceAtTheEndOfVerbatimBlockIfNoNewlinePresent()
|
public void DoesNotIgnoreWhitespaceAtTheEndOfVerbatimBlockIfNoNewlinePresent()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{\r\n} \t<html>\r\n");
|
ParseDocumentTest("@{\r\n} \t<html>\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentHandlesNewLineInNestedBlock()
|
public void HandlesNewLineInNestedBlock()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{\r\n@if(true){\r\n} \r\n}\r\n<html>");
|
ParseDocumentTest("@{\r\n@if(true){\r\n} \r\n}\r\n<html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentHandlesNewLineAndMarkupInNestedBlock()
|
public void HandlesNewLineAndMarkupInNestedBlock()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{\r\n@if(true){\r\n} <input> }");
|
ParseDocumentTest("@{\r\n@if(true){\r\n} <input> }");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocumentHandlesExtraNewLineBeforeMarkupInNestedBlock()
|
public void HandlesExtraNewLineBeforeMarkupInNestedBlock()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("@{\r\n@if(true){\r\n} \r\n<input> \r\n}<html>");
|
ParseDocumentTest("@{\r\n@if(true){\r\n} \r\n<input> \r\n}<html>");
|
||||||
}
|
}
|
||||||
|
|
@ -207,56 +209,56 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_WithDoubleTransitionInAttributeValue_DoesNotThrow()
|
public void WithDoubleTransitionInAttributeValue_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='@@' />}";
|
var input = "{<span foo='@@' />}";
|
||||||
ParseDocumentTest(input);
|
ParseDocumentTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow()
|
public void WithDoubleTransitionAtEndOfAttributeValue_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='abc@@' />}";
|
var input = "{<span foo='abc@@' />}";
|
||||||
ParseDocumentTest(input);
|
ParseDocumentTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow()
|
public void WithDoubleTransitionAtBeginningOfAttributeValue_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='@@def' />}";
|
var input = "{<span foo='@@def' />}";
|
||||||
ParseDocumentTest(input);
|
ParseDocumentTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_WithDoubleTransitionBetweenAttributeValue_DoesNotThrow()
|
public void WithDoubleTransitionBetweenAttributeValue_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='abc @@ def' />}";
|
var input = "{<span foo='abc @@ def' />}";
|
||||||
ParseDocumentTest(input);
|
ParseDocumentTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_WithDoubleTransitionWithExpressionBlock_DoesNotThrow()
|
public void WithDoubleTransitionWithExpressionBlock_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='@@@(2+3)' bar='@(2+3)@@@DateTime.Now' baz='@DateTime.Now@@' bat='@DateTime.Now @@' zoo='@@@DateTime.Now' />}";
|
var input = "{<span foo='@@@(2+3)' bar='@(2+3)@@@DateTime.Now' baz='@DateTime.Now@@' bat='@DateTime.Now @@' zoo='@@@DateTime.Now' />}";
|
||||||
ParseDocumentTest(input);
|
ParseDocumentTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_WithDoubleTransitionInEmail_DoesNotThrow()
|
public void WithDoubleTransitionInEmail_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = "{<span foo='abc@def.com abc@@def.com @@' />}";
|
var input = "{<span foo='abc@def.com abc@@def.com @@' />}";
|
||||||
ParseDocumentTest(input);
|
ParseDocumentTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_WithDoubleTransitionInRegex_DoesNotThrow()
|
public void WithDoubleTransitionInRegex_DoesNotThrow()
|
||||||
{
|
{
|
||||||
var input = @"{<span foo=""/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@@[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i"" />}";
|
var input = @"{<span foo=""/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@@[a-z0-9]([a-z0-9-]*[a-z0-9])?\.([a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i"" />}";
|
||||||
ParseDocumentTest(input);
|
ParseDocumentTest(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseDocument_WithUnexpectedTransitionsInAttributeValue_Throws()
|
public void WithUnexpectedTransitionsInAttributeValue_Throws()
|
||||||
{
|
{
|
||||||
ParseDocumentTest("<span foo='@ @' />");
|
ParseDocumentTest("<span foo='@ @' />");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,49 +8,51 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class HtmlErrorTest : CsHtmlMarkupParserTestBase
|
public class HtmlErrorTest : CsHtmlMarkupParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockAllowsInvalidTagNamesAsLongAsParserCanIdentifyEndTag()
|
public void AllowsInvalidTagNamesAsLongAsParserCanIdentifyEndTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<1-foo+bar>foo</1-foo+bar>");
|
ParseBlockTest("<1-foo+bar>foo</1-foo+bar>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockThrowsErrorIfStartTextTagContainsTextAfterName()
|
public void ThrowsErrorIfStartTextTagContainsTextAfterName()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<text foo bar></text>");
|
ParseBlockTest("<text foo bar></text>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockThrowsErrorIfEndTextTagContainsTextAfterName()
|
public void ThrowsErrorIfEndTextTagContainsTextAfterName()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<text></text foo bar>");
|
ParseBlockTest("<text></text foo bar>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockThrowsExceptionIfBlockDoesNotStartWithTag()
|
public void ThrowsExceptionIfBlockDoesNotStartWithTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("foo bar <baz>");
|
ParseBlockTest("foo bar <baz>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock()
|
public void StartingWithEndTagErrorsThenOutputsMarkupSegmentAndEndsBlock()
|
||||||
{
|
{
|
||||||
|
// ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock
|
||||||
ParseBlockTest("</foo> bar baz");
|
ParseBlockTest("</foo> bar baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag()
|
public void WithUnclosedTopLevelTagThrowsOnOutermostUnclosedTag()
|
||||||
{
|
{
|
||||||
|
// ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag
|
||||||
ParseBlockTest("<p><foo></bar>");
|
ParseBlockTest("<p><foo></bar>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException()
|
public void WithUnclosedTagAtEOFThrowsMissingEndTagException()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo>blah blah blah blah blah");
|
ParseBlockTest("<foo>blah blah blah blah blah");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException()
|
public void WithUnfinishedTagAtEOFThrowsIncompleteTagException()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo bar=baz");
|
ParseBlockTest("<foo bar=baz");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.AspNetCore.Razor.Language.Extensions;
|
using Microsoft.AspNetCore.Razor.Language.Extensions;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -11,31 +10,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class HtmlToCodeSwitchTest : CsHtmlMarkupParserTestBase
|
public class HtmlToCodeSwitchTest : CsHtmlMarkupParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSwitchesWhenCharacterBeforeSwapIsNonAlphanumeric()
|
public void SwitchesWhenCharacterBeforeSwapIsNonAlphanumeric()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<p>foo#@i</p>");
|
ParseBlockTest("<p>foo#@i</p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSwitchesToCodeWhenSwapCharacterEncounteredMidTag()
|
public void SwitchesToCodeWhenSwapCharacterEncounteredMidTag()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo @bar />");
|
ParseBlockTest("<foo @bar />");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue()
|
public void SwitchesToCodeWhenSwapCharacterEncounteredInAttributeValue()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo bar=\"@baz\" />");
|
ParseBlockTest("<foo bar=\"@baz\" />");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSwitchesToCodeWhenSwapCharacterEncounteredInTagContent()
|
public void SwitchesToCodeWhenSwapCharacterEncounteredInTagContent()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo>@bar<baz>@boz</baz></foo>");
|
ParseBlockTest("<foo>@bar<baz>@boz</baz></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockParsesCodeWithinSingleLineMarkup()
|
public void ParsesCodeWithinSingleLineMarkup()
|
||||||
{
|
{
|
||||||
// TODO: Fix at a later date, HTML should be a tag block: https://github.com/aspnet/Razor/issues/101
|
// TODO: Fix at a later date, HTML should be a tag block: https://github.com/aspnet/Razor/issues/101
|
||||||
ParseBlockTest("@:<li>Foo @Bar Baz" + Environment.NewLine
|
ParseBlockTest("@:<li>Foo @Bar Baz" + Environment.NewLine
|
||||||
|
|
@ -43,25 +42,25 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsCodeWithinComment()
|
public void SupportsCodeWithinComment()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><!-- @foo --></foo>");
|
ParseBlockTest("<foo><!-- @foo --></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsCodeWithinSGMLDeclaration()
|
public void SupportsCodeWithinSGMLDeclaration()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><!DOCTYPE foo @bar baz></foo>");
|
ParseBlockTest("<foo><!DOCTYPE foo @bar baz></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsCodeWithinCDataDeclaration()
|
public void SupportsCodeWithinCDataDeclaration()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><![CDATA[ foo @bar baz]]></foo>");
|
ParseBlockTest("<foo><![CDATA[ foo @bar baz]]></foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockSupportsCodeWithinXMLProcessingInstruction()
|
public void SupportsCodeWithinXMLProcessingInstruction()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo><?xml foo @bar baz?></foo>");
|
ParseBlockTest("<foo><?xml foo @bar baz?></foo>");
|
||||||
}
|
}
|
||||||
|
|
@ -73,13 +72,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockDoesNotSwitchToCodeOnEmailAddressInAttribute()
|
public void DoesNotSwitchToCodeOnEmailAddressInAttribute()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<a href=\"mailto:anurse@microsoft.com\">Email me</a>");
|
ParseBlockTest("<a href=\"mailto:anurse@microsoft.com\">Email me</a>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockGivesWhitespacePreceedingAtToCodeIfThereIsNoMarkupOnThatLine()
|
public void GivesWhitespacePreceedingAtToCodeIfThereIsNoMarkupOnThatLine()
|
||||||
{
|
{
|
||||||
ParseBlockTest(" <ul>" + Environment.NewLine
|
ParseBlockTest(" <ul>" + Environment.NewLine
|
||||||
+ " @foreach(var p in Products) {" + Environment.NewLine
|
+ " @foreach(var p in Products) {" + Environment.NewLine
|
||||||
|
|
@ -125,13 +124,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
|
|
||||||
// Tests for "@@" escape sequence:
|
// Tests for "@@" escape sequence:
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTreatsTwoAtSignsAsEscapeSequence()
|
public void TreatsTwoAtSignsAsEscapeSequence()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo>@@bar</foo>");
|
ParseBlockTest("<foo>@@bar</foo>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ParseBlockTreatsPairsOfAtSignsAsEscapeSequence()
|
public void TreatsPairsOfAtSignsAsEscapeSequence()
|
||||||
{
|
{
|
||||||
ParseBlockTest("<foo>@@@@@bar</foo>");
|
ParseBlockTest("<foo>@@@@@bar</foo>");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
||||||
public class WhiteSpaceRewriterTest : CsHtmlMarkupParserTestBase
|
public class WhiteSpaceRewriterTest : CsHtmlMarkupParserTestBase
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Rewrite_Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block()
|
public void Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var parsed = ParseDocument(
|
var parsed = ParseDocument(
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue