Class TupleSequence


  • public final class TupleSequence
    extends Object
    A Sequence that produces a tuple or collection of values, all of the same type.

    To make a new sequence requires choosing an operation, choosing a value (really, a previously-created sequence and one of its outputs) for each of the operation's inputs, and then concatenating all the input sequences along with the new operation. Most operations take a well-defined number and type of inputs. This helper class supports calling operations that take a variable number of inputs -- namely, array and list creation.

    Ordinarily:

    • Each Sequence consists of a single operation (the final statement) and its inputs. Those inputs are individually chosen and may be of different types, because the operation takes multiple types of arguments.
    • Each Sequence creates multiple values: the value produced by its last statement, and the values that might be side-effected by its last statement.
    • Each valid Sequence is output as a regression test. All of its values are in the pool, and when Randoop needs a value, it might choose any of them. Only one of its outputs is used when it is used as a component in a larger sequence.
    This sequence is different.
    • It is created as the concatenation of valid sequences, without an operation at the end.
    • Its outputs are one value from each of the sequences that created it.
    • It is not output as a regression test, but is used as one of the inputs to an array- or list-producing operation that will be output. All of its outputs are used.
    • Field Detail

      • sequence

        public Sequence sequence
        The underlying sequence.
      • outputIndices

        private List<Integer> outputIndices
        The list of statement indices that define outputs of this sequence.
    • Constructor Detail

      • TupleSequence

        public TupleSequence​(List<Sequence> sequences,
                             List<Integer> variables)
        Create a TupleSequence that concatenates the given sequences, choosing the given variable from each.
        Parameters:
        sequences - that will be concatenated to make the new TupleSequence
        variables - one index per sequence in sequences, defining the outputs of the TupleSequence
    • Method Detail

      • getOutputIndices

        public List<Integer> getOutputIndices()
        Returns the list of output indices.
        Returns:
        the list of output indices for this sequence
      • createElementsSequence

        public static TupleSequence createElementsSequence​(SimpleList<Sequence> candidates,
                                                           int length,
                                                           Type elementType)
        Selects sequences as element values for creating a collection.
        Parameters:
        candidates - the sequences from which to select
        length - the number of values to select
        elementType - the type of elements
        Returns:
        a sequence with subsequences that create element values for a collection