diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs index afc2afa90a..18c32b67c3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/CSharpExplicitExpressionTest.cs @@ -8,68 +8,39 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { public class CSharpExplicitExpressionTest : CsHtmlCodeParserTestBase { + public CSharpExplicitExpressionTest() + { + UseBaselineTests = true; + } + [Fact] public void ParseBlockShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty() { - ParseBlockTest("@()", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp().AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@()"); } [Fact] public void ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression() { - ParseBlockTest("@(", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.EmptyCSharp().AsExpression() - ), - RazorDiagnosticFactory.CreateParsing_ExpectedEndOfBlockBeforeEOF( - new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 1), - Resources.BlockName_ExplicitExpression, - ")", - "(")); + ParseBlockTest("@("); } [Fact] public void ParseBlockShouldAcceptEscapedQuoteInNonVerbatimStrings() { - ParseBlockTest("@(\"\\\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\\\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(\"\\\"\")"); } [Fact] public void ParseBlockShouldAcceptEscapedQuoteInVerbatimStrings() { - ParseBlockTest("@(@\"\"\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("@\"\"\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(@\"\"\"\")"); } [Fact] public void ParseBlockShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings() { - ParseBlockTest("@(@\"\"\"\"\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("@\"\"\"\"\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(@\"\"\"\"\"\")"); } [Fact] @@ -79,61 +50,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy + @"Foo" + Environment.NewLine + @"Bar" + Environment.NewLine + @"Baz" + Environment.NewLine - + @""")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code($"@\"{Environment.NewLine}Foo{Environment.NewLine}Bar{Environment.NewLine}Baz{Environment.NewLine}\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + + @""")"); } [Fact] public void ParseBlockShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings() { - ParseBlockTest("@(\"\\\"hello, world\\\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\\\"hello, world\\\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(\"\\\"hello, world\\\"\")"); } [Fact] public void ParseBlockShouldAcceptMultipleEscapedQuotesInVerbatimStrings() { - ParseBlockTest("@(@\"\"\"hello, world\"\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("@\"\"\"hello, world\"\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(@\"\"\"hello, world\"\"\")"); } [Fact] public void ParseBlockShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings() { - ParseBlockTest("@(\"\\\"\\\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("\"\\\"\\\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(\"\\\"\\\"\")"); } [Fact] public void ParseBlockShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings() { - ParseBlockTest("@(@\"\"\"\"\"\")", - new ExpressionBlock( - Factory.CodeTransition(), - Factory.MetaCode("(").Accepts(AcceptedCharactersInternal.None), - Factory.Code("@\"\"\"\"\"\"").AsExpression(), - Factory.MetaCode(")").Accepts(AcceptedCharactersInternal.None) - )); + ParseBlockTest("@(@\"\"\"\"\"\")"); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.syntaxtree.txt new file mode 100644 index 0000000000..26d9034003 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptConsecutiveEscapedQuotesInNonVerbatimStrings.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 9 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - ["\"\""] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.StringLiteral;["\"\""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (8:0,8) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.syntaxtree.txt new file mode 100644 index 0000000000..48f34c6ffb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptConsecutiveEscapedQuotesInVerbatimStrings.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [@""""""] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.StringLiteral;[@""""""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (9:0,9) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptEscapedQuoteInNonVerbatimStrings.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptEscapedQuoteInNonVerbatimStrings.syntaxtree.txt new file mode 100644 index 0000000000..dbdf46f11a --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptEscapedQuoteInNonVerbatimStrings.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 7 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - ["\""] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.StringLiteral;["\""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (6:0,6) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptEscapedQuoteInVerbatimStrings.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptEscapedQuoteInVerbatimStrings.syntaxtree.txt new file mode 100644 index 0000000000..baa41dc569 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptEscapedQuoteInVerbatimStrings.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 8 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [@""""] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.StringLiteral;[@""""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (7:0,7) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultiLineVerbatimStrings.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultiLineVerbatimStrings.syntaxtree.txt new file mode 100644 index 0000000000..6047dfb72a --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultiLineVerbatimStrings.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 23 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [@"LFFooLFBarLFBazLF"] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.StringLiteral;[@"LFFooLFBarLFBazLF"]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (22:4,1) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.syntaxtree.txt new file mode 100644 index 0000000000..6bbfd0acad --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleEscapedQuotesInNonVerbatimStrings.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 21 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - ["\"hello, world\""] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.StringLiteral;["\"hello, world\""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (20:0,20) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleEscapedQuotesInVerbatimStrings.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleEscapedQuotesInVerbatimStrings.syntaxtree.txt new file mode 100644 index 0000000000..4e54ffe339 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleEscapedQuotesInVerbatimStrings.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 22 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [@"""hello, world"""] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.StringLiteral;[@"""hello, world"""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (21:0,21) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.syntaxtree.txt new file mode 100644 index 0000000000..48f34c6ffb --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldAcceptMultipleRepeatedEscapedQuoteInVerbatimStrings.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 10 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [@""""""] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.StringLiteral;[@""""""]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (9:0,9) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression.diagnostics.txt new file mode 100644 index 0000000000..0b063402e6 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression.diagnostics.txt @@ -0,0 +1 @@ +(1,2): Error RZ1006: The explicit expression block is missing a closing ")" character. Make sure you have a matching ")" character for all the "(" characters within this block, and that none of the ")" characters are being interpreted as markup. diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression.syntaxtree.txt new file mode 100644 index 0000000000..c3029b551a --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfEOFOccursAfterStartOfExplicitExpression.syntaxtree.txt @@ -0,0 +1,7 @@ +Expression block - Gen - 2 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.Unknown;[]; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.syntaxtree.txt new file mode 100644 index 0000000000..7a2a258620 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/CSharpExplicitExpressionTest/ParseBlockShouldOutputZeroLengthCodeSpanIfExplicitExpressionIsEmpty.syntaxtree.txt @@ -0,0 +1,9 @@ +Expression block - Gen - 3 - (0:0,0) + Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (0:0,0) - Symbols:1 + CSharpSymbolType.Transition;[@]; + MetaCode span - Gen - [(] - SpanEditHandler;Accepts:None - (1:0,1) - Symbols:1 + CSharpSymbolType.LeftParenthesis;[(]; + Code span - Gen - [] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:1 + CSharpSymbolType.Unknown;[]; + MetaCode span - Gen - [)] - SpanEditHandler;Accepts:None - (2:0,2) - Symbols:1 + CSharpSymbolType.RightParenthesis;[)];