Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Span<T>.Fill implementation for Array.Fill #52590

Merged
merged 16 commits into from
Jun 30, 2021
Prev Previous commit
Next Next commit
remove try/catch
  • Loading branch information
xtqqczze committed Jun 18, 2021
commit 5168dabf9c7b467dfc3c173f8ac2f78b9c28a713
24 changes: 3 additions & 21 deletions src/libraries/System.Runtime/tests/System/ArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4298,29 +4298,11 @@ public static void Fill_Casting_Invalid()
{
Bar[] barArray1 = CreateBarArray();
Assert.Throws<ArrayTypeMismatchException>(() => Array.Fill<object>(barArray1, new Foo()));
Assert.Equal(CreateBarArray(), barArray1);

Bar[] barArray2 = CreateBarArray();
try
{
Array.Fill<object>(barArray2, new Foo());
}
catch (ArrayTypeMismatchException)
{
Assert.Equal(CreateBarArray(), barArray2);
}

Bar[] barArray3 = CreateBarArray();
Assert.Throws<ArrayTypeMismatchException>(() => Array.Fill<object>(barArray3, new Foo(), 1, 2));

Bar[] barArray4 = CreateBarArray();
try
{
Array.Fill<object>(barArray4, new Foo(), 1, 2);
}
catch (ArrayTypeMismatchException)
{
Assert.Equal(CreateBarArray(), barArray4);
}
Assert.Throws<ArrayTypeMismatchException>(() => Array.Fill<object>(barArray2, new Foo(), 1, 2));
Assert.Equal(CreateBarArray(), barArray2);
}

public static IEnumerable<object[]> Reverse_Generic_Int_TestData()
Expand Down