lib/speculation/spec/merge_spec.rb in speculation-0.4.0 vs lib/speculation/spec/merge_spec.rb in speculation-0.4.2
- old
+ new
@@ -17,16 +17,20 @@
def conform(x)
ms = @preds.map { |pred| S.dt(pred, x) }
if ms.any?(&S.method(:invalid?))
- S::INVALID
+ :"Speculation/invalid"
else
ms.reduce(&:merge)
end
end
+ def unform(x)
+ @preds.reverse.map { |pred| S.unform(pred, x) }.reduce(&:merge)
+ end
+
def explain(path, via, inn, x)
@preds.
flat_map { |pred| S.explain1(pred, path, via, inn, x) }.
compact
end
@@ -34,10 +38,10 @@
def with_gen(gen)
self.class.new(@preds, gen)
end
def gen(overrides, path, rmap)
- return @gen if @gen
+ return @gen.call if @gen
gens = @preds.
map { |pred| S.gensub(pred, overrides, path, rmap) }
->(r) do