Skip to content

Commit

Permalink
Enable nullable context in "Flatten" tests
Browse files Browse the repository at this point in the history
Adds to #803.
  • Loading branch information
atifaziz authored Nov 9, 2022
1 parent fc3ee2f commit a39672c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions MoreLinq.Test/FlattenTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// limitations under the License.
#endregion

#nullable enable

namespace MoreLinq.Test
{
using System.Collections.Generic;
Expand Down Expand Up @@ -395,7 +397,7 @@ public void FlattenSelectorWithTree()
var result = new[] { source }.Flatten(obj => obj switch
{
int => null,
Tree<int> tree => new object[] { tree.Left, tree.Value, tree.Right },
Tree<int> tree => new object?[] { tree.Left, tree.Value, tree.Right },
IEnumerable inner => inner,
_ => Enumerable.Empty<object>()
});
Expand All @@ -407,23 +409,23 @@ public void FlattenSelectorWithTree()

class Series
{
public string Name;
public Attribute[] Attributes;
public required string Name;
public required Attribute[] Attributes;
}

class Attribute
{
public int[] Values;
public required int[] Values;
}

class Tree<T>
{
public readonly T Value;
public readonly Tree<T> Left;
public readonly Tree<T> Right;
public readonly Tree<T>? Left;
public readonly Tree<T>? Right;

public Tree(T value) : this(null, value, null) {}
public Tree(Tree<T> left, T value, Tree<T> right)
public Tree(Tree<T>? left, T value, Tree<T>? right)
{
Left = left;
Value = value;
Expand Down
1 change: 1 addition & 0 deletions MoreLinq.Test/MoreLinq.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
</PackageReference>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnitLite" Version="3.13.3" />
<PackageReference Include="PolySharp" Version="1.7.1" />
<PackageReference Include="System.Reactive" Version="3.1.1" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
Expand Down

0 comments on commit a39672c

Please sign in to comment.