Skip to content

Commit

Permalink
Small typo fix, add a couple of more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Nov 9, 2017
1 parent 4c5b6cb commit 13a6f43
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ void M1()

[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void IVariableDeclaration_InvalidIgnoredArguments_VerifyChildren()
public void IVariableDeclaration_InvalidIgnoredArgumentsWithInitializer_VerifyChildren()
{
string source = @"
class C
Expand All @@ -610,6 +610,67 @@ void M1()
Assert.Equal(OperationKind.VariableInitializer, declarator.Children.ElementAt(1).Kind);
}

[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void IVariableDeclaration_InvalidIgnoredArguments_VerifyChildren()
{
string source = @"
class C
{
void M1()
{
int /*<bind>*/x[10]/*</bind>*/;
}
}
";

var compilation = CreateCompilation(source);
(var operation, _) = GetOperationAndSyntaxForTest<VariableDeclaratorSyntax>(compilation);
var declarator = (IVariableDeclaratorOperation)operation;
Assert.Equal(1, declarator.Children.Count());
Assert.Equal(OperationKind.Literal, declarator.Children.First().Kind);
}

[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void IVariableDeclaration_WithInitializer_VerifyChildren()
{
string source = @"
class C
{
void M1()
{
int /*<bind>*/x = 1/*</bind>*/;
}
}
";

var compilation = CreateCompilation(source);
(var operation, _) = GetOperationAndSyntaxForTest<VariableDeclaratorSyntax>(compilation);
var declarator = (IVariableDeclaratorOperation)operation;
Assert.Equal(1, declarator.Children.Count());
Assert.Equal(OperationKind.VariableInitializer, declarator.Children.ElementAt(0).Kind);
}

[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void IVariableDeclaration_NoChildren()
{
string source = @"
class C
{
void M1()
{
int /*<bind>*/x/*</bind>*/;
}
}
";

var compilation = CreateCompilation(source);
(var operation, _) = GetOperationAndSyntaxForTest<VariableDeclaratorSyntax>(compilation);
Assert.Empty(operation.Children);
}

#endregion

#region Fixed Statements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5436,12 +5436,9 @@ public override IEnumerable<IOperation> Children
{
get
{
if (!IgnoredArguments.IsEmpty)
foreach (var arg in IgnoredArguments)
{
foreach (var arg in IgnoredArguments)
{
yield return arg;
}
yield return arg;
}
if (Initializer != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface IVariableDeclaratorOperation : IOperation
IVariableInitializerOperation Initializer { get; }

/// <summary>
/// Additional arguments supplied to the declarator in error cases, ignored by the compiler. This only used for C# cases, of
/// Additional arguments supplied to the declarator in error cases, ignored by the compiler. This only used for the C# case of
/// DeclaredArgumentSyntax nodes on a VariableDeclaratorSyntax.
/// </summary>
ImmutableArray<IOperation> IgnoredArguments { get; }
Expand Down

0 comments on commit 13a6f43

Please sign in to comment.