Sha256: 74d2155348490e9ab85a5af8d23b269232f71ee3836ca5baea65121fde6addb2
Contents?: true
Size: 977 Bytes
Versions: 1
Compression:
Stored size: 977 Bytes
Contents
# frozen_string_literal: true module Speculation # @private class NilableSpec < SpecImpl include NamespacedSymbols S = Speculation def initialize(pred) @pred = pred @delayed_spec = Concurrent::Delay.new { S.send(:specize, pred) } end def conform(value) value.nil? ? value : @delayed_spec.value!.conform(value) end def explain(path, via, inn, value) return if S.pvalid?(@delayed_spec.value!, value) || value.nil? Utils.conj( S.explain1(@pred, Utils.conj(path, ns(S, :pred)), via, inn, value), :path => Utils.conj(path, ns(S, :nil)), :pred => [NilClass, [value]], :val => value, :via => via, :in => inn ) end def gen(overrides, path, rmap) return @gen if @gen ->(rantly) do rantly.freq([1, Gen.delay { Utils.constantly(nil) }], [9, Gen.delay { S.gensub(@pred, overrides, Utils.conj(path, ns(S, :pred)), rmap) }]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
speculation-0.2.0 | lib/speculation/spec_impl/nilable_spec.rb |