Skip to content

Commit

Permalink
Add additional location tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Oct 6, 2016
1 parent 2512c96 commit 8b369b4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
24 changes: 24 additions & 0 deletions src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4830,6 +4830,8 @@ public void CreateTupleTypeSymbol_WithValueTuple()
Assert.True(tupleWithoutNames.TupleElementNames.IsDefault);
Assert.Equal(new[] { "System.Int32", "System.String" }, tupleWithoutNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));
Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind);
Assert.All(tupleWithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand Down Expand Up @@ -4873,6 +4875,8 @@ public void CreateTupleTypeSymbol_NoNames()
Assert.True(tupleWithoutNames.TupleElementNames.IsDefault);
Assert.Equal(new[] { "System.Int32", "System.String" }, tupleWithoutNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));
Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind);
Assert.All(tupleWithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -4890,6 +4894,8 @@ public void CreateTupleTypeSymbol_WithNames()
Assert.Equal(new[] { "Alice", "Bob" }, tupleWithNames.TupleElementNames);
Assert.Equal(new[] { "System.Int32", "System.String" }, tupleWithNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));
Assert.Equal(SymbolKind.NamedType, tupleWithNames.Kind);
Assert.All(tupleWithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -4907,6 +4913,8 @@ public void CreateTupleTypeSymbol_WithSomeNames()
Assert.Equal(new[] { null, "Item2", "Charlie" }, tupleWithSomeNames.TupleElementNames);
Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32" }, tupleWithSomeNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));
Assert.Equal(SymbolKind.NamedType, tupleWithSomeNames.Kind);
Assert.All(tupleWithSomeNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -4923,6 +4931,8 @@ public void CreateTupleTypeSymbol_WithBadNames()
Assert.Equal(new[] { "Item2", "Item1" }, tupleWithNames.TupleElementNames);
Assert.Equal(new[] { "System.Int32", "System.Int32" }, tupleWithNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));
Assert.Equal(SymbolKind.NamedType, tupleWithNames.Kind);
Assert.All(tupleWithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -4945,6 +4955,8 @@ public void CreateTupleTypeSymbol_Tuple8NoNames()

Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String" },
tuple8WithoutNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));
Assert.All(tuple8WithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -4968,6 +4980,8 @@ public void CreateTupleTypeSymbol_Tuple8WithNames()

Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String" },
tuple8WithNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));
Assert.All(tuple8WithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -4991,6 +5005,8 @@ public void CreateTupleTypeSymbol_Tuple9NoNames()

Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32" },
tuple9WithoutNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));
Assert.All(tuple9WithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -5014,6 +5030,9 @@ public void CreateTupleTypeSymbol_Tuple9WithNames()

Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32" },
tuple9WithNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));

Assert.All(tuple9WithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -5040,6 +5059,9 @@ public void CreateTupleTypeSymbol_Tuple9WithDefaultNames()

Assert.Equal(new[] { "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.Int32", "System.Int32" },
tuple9WithNames.TupleElementTypes.Select(t => t.ToTestDisplayString()));

Assert.All(tuple9WithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact]
Expand All @@ -5060,6 +5082,8 @@ public void CreateTupleTypeSymbol_ElementTypeIsError()
Assert.Equal(2, types.Length);
Assert.Equal(SymbolKind.NamedType, types[0].Kind);
Assert.Equal(SymbolKind.ErrorType, types[1].Kind);
Assert.All(tupleWithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()),
loc => Assert.Equal(loc, null));
}

[Fact, WorkItem(13277, "https://github.com/dotnet/roslyn/issues/13277")]
Expand Down
3 changes: 2 additions & 1 deletion src/Compilers/Core/Portable/Compilation/Compilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ protected static ImmutableArray<string> CheckTupleElementNames(int cardinality,
return elementNames;
}

protected static void CheckTupleElementLocations(int cardinality,
protected static void CheckTupleElementLocations(
int cardinality,
ImmutableArray<Location> elementLocations)
{
if (!elementLocations.IsDefault)
Expand Down
33 changes: 22 additions & 11 deletions src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5059,7 +5059,8 @@ End Class
Assert.True(tupleWithoutNames.TupleElementNames.IsDefault)
Assert.Equal(New String() {"System.Int32", "System.String"}, tupleWithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))
Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind)

Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand Down Expand Up @@ -5107,7 +5108,8 @@ End Class
Assert.True(tupleWithoutNames.TupleElementNames.IsDefault)
Assert.Equal(New String() {"System.Int32", "System.String"}, tupleWithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))
Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind)

Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5126,7 +5128,8 @@ End Class
Assert.Equal(New String() {"Alice", "Bob"}, tupleWithoutNames.TupleElementNames)
Assert.Equal(New String() {"System.Int32", "System.String"}, tupleWithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))
Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind)

Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5148,7 +5151,8 @@ End Class
tupleWithSomeNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))

Assert.Equal(SymbolKind.NamedType, tupleWithSomeNames.Kind)

Assert.All(tupleWithSomeNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5165,7 +5169,8 @@ End Class
Assert.Equal(New String() {"Item2", "Item1"}, tupleWithoutNames.TupleElementNames)
Assert.Equal(New String() {"System.Int32", "System.Int32"}, tupleWithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))
Assert.Equal(SymbolKind.NamedType, tupleWithoutNames.Kind)

Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5189,7 +5194,8 @@ End Class

Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String"},
tuple8WithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))

Assert.All(tuple8WithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5213,7 +5219,8 @@ End Class

Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String"},
tuple8WithNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))

Assert.All(tuple8WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5237,7 +5244,8 @@ End Class

Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32"},
tuple9WithoutNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))

Assert.All(tuple9WithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5261,7 +5269,8 @@ End Class

Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32"},
tuple9WithNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))

Assert.All(tuple9WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5285,7 +5294,8 @@ End Class

Assert.Equal(New String() {"System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32", "System.String", "System.Int32"},
tuple9WithNames.TupleElementTypes.Select(Function(t) t.ToTestDisplayString()))

Assert.All(tuple9WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand All @@ -5308,7 +5318,8 @@ End Class
Assert.Equal(2, types.Length)
Assert.Equal(SymbolKind.NamedType, types(0).Kind)
Assert.Equal(SymbolKind.ErrorType, types(1).Kind)

Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()),
Sub(Loc) Assert.Equal(Loc, Nothing))
End Sub

<Fact>
Expand Down

0 comments on commit 8b369b4

Please sign in to comment.