-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/Compilers/CSharp/Test/Syntax/Parsing/Deconstruction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Linq; | ||
using Microsoft.CodeAnalysis.CSharp.Test.Utilities; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Parsing | ||
{ | ||
// (T id, ...) = is a deconstruction-declaration | ||
|
||
// (T, ...) id | ||
// and (T, ...) [] are types | ||
// (E, ...) = is a deconstruction-assignment | ||
// (E, ...) folowed by ., +, -, etc is an expression | ||
|
||
public class DeconstructionTests : ParsingTests | ||
{ | ||
protected override SyntaxTree ParseTree(string text, CSharpParseOptions options) | ||
{ | ||
return SyntaxFactory.ParseSyntaxTree(text, options: options); | ||
} | ||
|
||
[Fact] | ||
public void TupleType() | ||
{ | ||
// (T id, ...) id is a tuple type | ||
|
||
var tree = UsingTree(@" | ||
class C | ||
{ | ||
void Foo() | ||
{ | ||
(Int32 a, Int64 b) x; | ||
} | ||
}", options: TestOptions.Regular.WithTuplesFeature()); | ||
N(SyntaxKind.CompilationUnit); | ||
{ | ||
N(SyntaxKind.ClassDeclaration); | ||
{ | ||
N(SyntaxKind.ClassKeyword); | ||
N(SyntaxKind.IdentifierToken); | ||
N(SyntaxKind.OpenBraceToken); | ||
N(SyntaxKind.MethodDeclaration); | ||
{ | ||
N(SyntaxKind.TupleType); | ||
{ | ||
N(SyntaxKind.OpenParenToken); | ||
N(SyntaxKind.TupleElement); | ||
{ | ||
N(SyntaxKind.PredefinedType); | ||
{ | ||
N(SyntaxKind.IntKeyword); | ||
} | ||
} | ||
N(SyntaxKind.CommaToken); | ||
N(SyntaxKind.TupleElement); | ||
{ | ||
N(SyntaxKind.PredefinedType); | ||
{ | ||
N(SyntaxKind.StringKeyword); | ||
} | ||
} | ||
N(SyntaxKind.CloseParenToken); | ||
} | ||
N(SyntaxKind.IdentifierToken); | ||
N(SyntaxKind.ParameterList); | ||
{ | ||
N(SyntaxKind.OpenParenToken); | ||
N(SyntaxKind.CloseParenToken); | ||
} | ||
N(SyntaxKind.Block); | ||
{ | ||
N(SyntaxKind.OpenBraceToken); | ||
N(SyntaxKind.ReturnStatement); | ||
{ | ||
N(SyntaxKind.ReturnKeyword); | ||
N(SyntaxKind.TupleExpression); | ||
{ | ||
N(SyntaxKind.OpenParenToken); | ||
N(SyntaxKind.Argument); | ||
{ | ||
N(SyntaxKind.NumericLiteralExpression); | ||
{ | ||
N(SyntaxKind.NumericLiteralToken); | ||
} | ||
} | ||
N(SyntaxKind.CommaToken); | ||
N(SyntaxKind.Argument); | ||
{ | ||
N(SyntaxKind.StringLiteralExpression); | ||
{ | ||
N(SyntaxKind.StringLiteralToken); | ||
} | ||
} | ||
N(SyntaxKind.CloseParenToken); | ||
} | ||
N(SyntaxKind.SemicolonToken); | ||
} | ||
N(SyntaxKind.CloseBraceToken); | ||
} | ||
} | ||
N(SyntaxKind.CloseBraceToken); | ||
} | ||
N(SyntaxKind.EndOfFileToken); | ||
} | ||
EOF(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,6 @@ class C | |
EOF(); | ||
} | ||
|
||
|
||
[Fact] | ||
public void LongTuple() | ||
{ | ||
|