Пример #1
0
        public void Parser_Error_SkipsBadTokens()
        {
            const string text = @"
                'First' + !'Last'
            ";

            using (var enumerator = AssertingEnumerator.ForExpression(text))
            {
                enumerator.AssertNode(SyntaxKind.AddExpression);
                enumerator.AssertNode(SyntaxKind.LiteralExpression);
                enumerator.AssertToken(SyntaxKind.StringLiteralToken, @"'First'");
                enumerator.AssertToken(SyntaxKind.PlusToken, @"+");
                enumerator.AssertNode(SyntaxKind.LiteralExpression);
                enumerator.AssertNode(SyntaxKind.SkippedTokensTrivia);
                enumerator.AssertToken(SyntaxKind.BadToken, @"!");
                enumerator.AssertDiagnostic(DiagnosticId.IllegalInputCharacter, @"Invalid character in input '!'.");
                enumerator.AssertToken(SyntaxKind.StringLiteralToken, @"'Last'");
            }
        }