|
|
|
@ -5,7 +5,7 @@ module Minitest::Thesis
|
|
|
|
|
class Possibility
|
|
|
|
|
attr_reader :produce, :name
|
|
|
|
|
|
|
|
|
|
def initialize(name = "TODO", &produce)
|
|
|
|
|
def initialize(name, &produce)
|
|
|
|
|
@name = name
|
|
|
|
|
@produce = produce
|
|
|
|
|
end
|
|
|
|
@ -15,20 +15,20 @@ module Minitest::Thesis
|
|
|
|
|
|
|
|
|
|
# "Returns a `Possibility` where values come from applying `f` to some possible value for `self`."
|
|
|
|
|
def map(&f)
|
|
|
|
|
self.class.new("#{name}.map(TODO)") {|tc| f.call(tc.any(self)) }
|
|
|
|
|
self.class.new("#{name}.map(#{f.class})") {|tc| f.call(tc.any(self)) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Returns a `Possibility` where values come from applying `f` (which
|
|
|
|
|
# should return a new `Possibility` to some possible value for `self`
|
|
|
|
|
# then returning a possible value from that.
|
|
|
|
|
def bind(&f)
|
|
|
|
|
self.class.new("#{name}.bind(TODO)") {|tc| tc.any(f.(tc.any(self))) }
|
|
|
|
|
self.class.new("#{name}.bind(#{f.class})") {|tc| tc.any(f.(tc.any(self))) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Returns a `Possibility` whose values are any possible value of `self`
|
|
|
|
|
# for which `f` returns True.
|
|
|
|
|
def satisfying(&f)
|
|
|
|
|
self.class.new("#{name}.select(TODO)") {|test_case|
|
|
|
|
|
self.class.new("#{name}.select(#{f.class})") {|test_case|
|
|
|
|
|
3.times.first {
|
|
|
|
|
candidate = test_case.any(self)
|
|
|
|
|
candidate if f.(candidate)
|
|
|
|
|