mirror of
https://github.com/github/semantic.git
synced 2024-12-26 00:12:29 +03:00
Generate arbitrary keyed terms.
This commit is contained in:
parent
cc1f0a07a3
commit
4a24c3f872
@ -19,9 +19,17 @@ extension UnannotatedTerm: Arbitrary {
|
||||
}
|
||||
}
|
||||
}
|
||||
let keyed: Gen<Term> = Gen.sized { n in
|
||||
Gen<Int>.choose((0, n)).bind { n in
|
||||
sequence((0..<n).map { _ in String.arbitrary.bind { key in UnannotatedTerm.arbitrary.fmap { (key, $0.term) } } }).fmap {
|
||||
Term((), .Keyed(Dictionary(elements: $0)))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Gen.oneOf([
|
||||
leaf,
|
||||
indexed,
|
||||
keyed,
|
||||
]).fmap {
|
||||
UnannotatedTerm(term: $0)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user