protected void assignArray(TestCase test,VariableReference array,int arrayIndex,int position,List<VariableReference> objects) throws ConstructionFailedException {
  assert (array instanceof ArrayReference);
  ArrayReference arrRef=(ArrayReference)array;
  if (!objects.isEmpty() && Randomness.nextDouble() <= Properties.OBJECT_REUSE_PROBABILITY) {
    VariableReference choice=Randomness.choice(objects);
    logger.debug("Reusing value: " + choice);
    ArrayIndex index=new ArrayIndex(test,arrRef,arrayIndex);
    Statement st=new AssignmentStatement(test,index,choice);
    test.addStatement(st,position);
  }
 else {
    int oldLength=test.size();
    logger.debug("Attempting generation of object of type " + array.getComponentType());
    VariableReference var=attemptGeneration(test,array.getComponentType(),position);
    if (!var.isAssignableTo(arrRef.getComponentType())) {
      throw new ConstructionFailedException("Error");
    }
    position+=test.size() - oldLength;
    ArrayIndex index=new ArrayIndex(test,arrRef,arrayIndex);
    Statement st=new AssignmentStatement(test,index,var);
    test.addStatement(st,position);
  }
}

protected void assignArray ( TestCase test , VariableReference array , int arrayIndex , int position , List < VariableReference > objects ) throws ConstructionFailedException { assert ( array instanceof ArrayReference ) ; ArrayReference arrRef = ( ArrayReference ) array ; if ( ! objects . isEmpty ( ) && Randomness . nextDouble ( ) <= Properties . OBJECT_REUSE_PROBABILITY ) { VariableReference choice = Randomness . choice ( objects ) ; logger . debug ( "Reusing value: " + choice ) ; ArrayIndex index = new ArrayIndex ( test , arrRef , arrayIndex ) ; Statement st = new AssignmentStatement ( test , index , choice ) ; test . addStatement ( st , position ) ; } else { int oldLength = test . size ( ) ; logger . debug ( "Attempting generation of object of type " + array . getComponentType ( ) ) ; VariableReference var = attemptGeneration ( test , array . getComponentType ( ) , position ) ; if ( ! var . isAssignableTo ( arrRef . getComponentType ( ) ) ) { throw new ConstructionFailedException ( "Error" ) ; } position += test . size ( ) - oldLength ; ArrayIndex index = new ArrayIndex ( test , arrRef , arrayIndex ) ; Statement st = new AssignmentStatement ( test , index , var ) ; test . addStatement ( st , position ) ; } }
assign a value to an array index for a given set of objects
