1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 11:04:00 +03:00

Document the shrunk term.

This commit is contained in:
Rob Rix 2015-10-19 11:31:35 -04:00
parent 9e6aa171a7
commit 423d804254

View File

@ -104,12 +104,12 @@ extension UnannotatedTerm: Arbitrary {
static func shrink(term: UnannotatedTerm) -> [UnannotatedTerm] {
let equal = Term.equals(annotation: const(true), leaf: ==)
/// A smaller-than-or-equal-to permutation of `term`. Shrinking is performed outward-in by dropping elements from branches.
let shrunk: UnannotatedTerm.Term = term.term.para {
switch $0 {
case let .Leaf(a):
return Cofree((), .Leaf(a))
case let .Indexed(i):
/// if the child nodes are unchanged, shrink the array
return Cofree((), .Indexed(i.reduce(true) { $0 && equal($1) }
? i.dropLast().map { $1 }
: i.map { $1 }))