public static boolean removeUnusedVariables(TestCase t){
  List<Integer> to_delete=new ArrayList<Integer>();
  boolean has_deleted=false;
  int num=0;
  for (  Statement s : t) {
    VariableReference var=s.getReturnValue();
    if (!t.hasReferences(var)) {
      to_delete.add(num);
      has_deleted=true;
    }
    num++;
  }
  Collections.sort(to_delete,Collections.reverseOrder());
  for (  Integer position : to_delete) {
    t.remove(position);
  }
  return has_deleted;
}

public static boolean removeUnusedVariables ( TestCase t ) { List < Integer > to_delete = new ArrayList < Integer > ( ) ; boolean has_deleted = false ; int num = 0 ; for ( Statement s : t ) { VariableReference var = s . getReturnValue ( ) ; if ( ! t . hasReferences ( var ) ) { to_delete . add ( num ) ; has_deleted = true ; } num ++ ; } Collections . sort ( to_delete , Collections . reverseOrder ( ) ) ; for ( Integer position : to_delete ) { t . remove ( position ) ; } return has_deleted ; }
remove all unreferenced variables
