1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 21:31:48 +03:00
semantic/prototype/DoubtTests/RangedDiff.swift
2015-10-16 17:21:45 -04:00

26 lines
550 B
Swift

struct RangedDiff {
typealias Term = RangedTerm.Term
typealias Diff = Free<String, Patch<Term>>
let a: Term
let b: Term
let diff: Diff
}
extension RangedDiff: Arbitrary {
static let interpreter = Interpreter<Term>(equal: ==, comparable: const(true), cost: Diff.sum(Patch.difference))
static var arbitrary: Gen<RangedDiff> {
return RangedTerm.arbitrary.bind { a in
RangedTerm.arbitrary.fmap { b in
RangedDiff(a: a.term, b: b.term, diff: interpreter.run(a.term, b.term))
}
}
}
}
import Doubt
import Prelude
import SwiftCheck