2015-10-16 19:28:16 +03:00
|
|
|
struct RangedTerm {
|
2015-10-16 20:23:38 +03:00
|
|
|
typealias Term = Cofree<String, (String, Range<Int>)>
|
|
|
|
let term: Term
|
2015-10-16 19:28:16 +03:00
|
|
|
}
|
|
|
|
|
2015-10-16 21:24:17 +03:00
|
|
|
struct UnannotatedTerm {
|
|
|
|
typealias Term = Cofree<String, ()>
|
|
|
|
let term: Term
|
|
|
|
}
|
2015-10-16 19:28:16 +03:00
|
|
|
|
2015-10-16 19:28:49 +03:00
|
|
|
extension RangedTerm: Arbitrary {
|
|
|
|
static var arbitrary: Gen<RangedTerm> {
|
2015-10-16 20:23:38 +03:00
|
|
|
func arbitrary(from: Int) -> Gen<Term> {
|
|
|
|
let leaf: Gen<Term> = String.arbitrary.fmap {
|
|
|
|
Cofree(($0, from..<Int($0.characters.count)), .Leaf($0))
|
|
|
|
}
|
|
|
|
return Gen.oneOf([
|
|
|
|
leaf,
|
|
|
|
])
|
|
|
|
}
|
|
|
|
return arbitrary(0).fmap {
|
|
|
|
RangedTerm(term: $0)
|
|
|
|
}
|
2015-10-16 19:28:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-16 19:28:16 +03:00
|
|
|
@testable import Doubt
|
2015-10-16 19:28:49 +03:00
|
|
|
import SwiftCheck
|