Skip to content

Optimize list shrinking for "any list over count" situation #318

Description

@nth-commit

A reasonably common counterexample might due to a list of over n count, or a string over n length.

However, the smallest example that satisfies this predicate is actually quite hard to get to, as we focus on bisecting the list whilst shrinking the elements first.

Consider the property:

public void StringProp(string s)
{
    Xunit.Assert.True(s.Length < 2);
}

Takes approximately 20 shrinks to find the smallest countexample ("aa"). It also does not scale linearly:

Length ~Number of shrinks
2 20
4 60
8 180
16 500
32 1500

We should prioritize finding the smallest example that satisfies that constraint. That is, the first shrink of a list should be shrinking all the elements to their smallest form.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions