Sha256: b24f7ff4eec32e02d199664cdfbfbedb8274f2839638911647371e89052b2347

Contents?: true

Size: 409 Bytes

Versions: 6

Compression:

Stored size: 409 Bytes

Contents

# frozen_string_literal: true

module Pbt
  module Arbitrary
    # Generates a constant value.
    class ConstantArbitrary < Arbitrary
      # @param val [Object]
      def initialize(val)
        @val = val
      end

      # @see Arbitrary#generate
      def generate(rng)
        @val
      end

      # @see Arbitrary#shrink
      def shrink(current)
        Enumerator.new {}
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pbt-0.5.0 lib/pbt/arbitrary/constant_arbitrary.rb
pbt-0.4.0 lib/pbt/arbitrary/constant_arbitrary.rb
pbt-0.3.0 lib/pbt/arbitrary/constant_arbitrary.rb
pbt-0.2.0 lib/pbt/arbitrary/constant_arbitrary.rb
pbt-0.1.1 lib/pbt/arbitrary/constant_arbitrary.rb
pbt-0.1.0 lib/pbt/arbitrary/constant_arbitrary.rb