class RandomlyGenerated::Object

This is the base class for all classes used to generate random objects.

Attributes

rand[R]
seed[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/randomly_generated/object.rb, line 6
def initialize(options={})
  @seed = options.fetch(:seed) { Random.new_seed }
  @rand = Random.new(seed)
end

Public Instance Methods

call() click to toggle source

Returns the generated object.

# File lib/randomly_generated/object.rb, line 12
def call
  raise NotImplementedError
end
shrunken_subsets() click to toggle source

Returns an array of “shrunken” proper subsets of the object. These subsets are intended to find simpler cases that will reproduce a test failure. WARNING: This API will likely change. We plan to experiment with it heavily. One idea is to have it take a block instead, and pass the various subsets to the block.

# File lib/randomly_generated/object.rb, line 20
def shrunken_subsets
  # By default, assume that the object is atomic and cannot be simplified.
  []
end