shrink method

  1. @override
Iterable<Shrinkable<List<T>>> shrink()
override

Generates an Iterable of Shrinkables that fulfill the following criteria:

  • They are similar to this: They only differ in little ways.
  • They are simpler than this: The transitive hull is finite acyclic. If you would call shrink on all returned values and on the values returned by them etc., this process should terminate sometime.

Implementation

@core.override
core.Iterable<Shrinkable<core.List<T>>> shrink() sync* {
  if (items.length > minLength) {
    for (var i = 0; i < items.length; i++) {
      yield ShrinkableList(core.List.of(items)..removeAt(i), minLength);
    }
  }
  for (var i = 0; i < items.length; i++) {
    for (final shrunk in items[i].shrink()) {
      yield ShrinkableList(core.List.of(items)..[i] = shrunk, minLength);
    }
  }
}