Skip to content

Backsert tests don't cover enumerator disposal #651

@atifaziz

Description

@atifaziz

If the using is removed from the following line in Backsert:

using var e = first.CountDown(index, ValueTuple.Create).GetEnumerator();

then its tests, like the following that uses TestingSequence:

public IEnumerable<int> Backsert(int[] seq1, int index, int[] seq2)
{
using (var test1 = seq1.AsTestingSequence())
using (var test2 = seq2.AsTestingSequence())
{
return test1.Backsert(test2, index).ToArray();
}
}

don't break!

This is because Backsert internally uses other operators like Concat and CountDown and so provide a false positive because while Backsert is modified to not dispose anymore, Concat and CountDown do! This highlights a flaw that relying on TestingSequence is weak and won't cover what it's designed to test if an implementation is refactored internally to rely on other operations. TestingSequence is only as good as the implementation fully stand on its own.

This came up while reviewing issue #649. Thanks @Orace!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions