Program: 170953
Project: 170953
Buggy source:
@Override public void calculate(CalculaterTask thread) throws CancelException {
  final TestSession ta=getFormulaList().getTaSession();
  if (disableCalculation()) {
    if (!leftTerm.isTerm() && ta != null) {
      ta.setResult(leftTerm.getText(),fillResultString());
    }
    return;
  }
  ArrayList<Equation> linkedIntervals=getAllIntervals();
  if (linkedIntervals.isEmpty()) {
    resultType=ResultType.CONSTANT;
    constantResult=new CalculatedValue();
    leftTerm.getValue(thread,constantResult);
  }
 else   if (linkedIntervals.size() == 1) {
    final CalculatedValue[] argValues=new CalculatedValue[1];
    argValues[0]=new CalculatedValue();
    final ArrayList<Double> xValues=linkedIntervals.get(0).getInterval(thread);
    if (xValues != null && xValues.size() > 0) {
      final int xLength=xValues.size();
      resultType=ResultType.ARRAY_1D;
      arrayArgument=new EquationArrayResult(xLength);
      arrayResult=new EquationArrayResult(xLength,1);
      for (int xIndex=0; xIndex < xLength; xIndex++) {
        final Double x=xValues.get(xIndex);
        argValues[0].setValue(x);
        arrayArgument.getValue1D(xIndex).setValue(x);
        linkedIntervals.get(0).setArgumentValues(argValues);
        leftTerm.getValue(thread,arrayResult.getValue2D(xIndex,0));
      }
    }
 else {
      resultType=ResultType.NAN;
    }
  }
 else   if (linkedIntervals.size() == 2) {
    final CalculatedValue[][] argValues=new CalculatedValue[2][1];
    argValues[0][0]=new CalculatedValue();
    final ArrayList<Double> xValues=linkedIntervals.get(0).getInterval(thread);
    argValues[1][0]=new CalculatedValue();
    final ArrayList<Double> yValues=linkedIntervals.get(1).getInterval(thread);
    if (xValues != null && xValues.size() > 0 && yValues != null && yValues.size() > 0) {
      final int xLength=xValues.size();
      final int yLength=yValues.size();
      resultType=ResultType.ARRAY_2D;
      arrayResult=new EquationArrayResult(xLength,yLength);
      for (int xIndex=0; xIndex < xLength; xIndex++) {
        argValues[0][0].setValue(xValues.get(xIndex));
        linkedIntervals.get(0).setArgumentValues(argValues[0]);
        for (int yIndex=0; yIndex < yLength; yIndex++) {
          argValues[1][0].setValue(yValues.get(yIndex));
          linkedIntervals.get(1).setArgumentValues(argValues[1]);
          leftTerm.getValue(thread,arrayResult.getValue2D(xIndex,yIndex));
        }
      }
    }
  }
  if (!leftTerm.isTerm() && ta != null) {
    ta.setResult(leftTerm.getText(),fillResultString());
  }
}

Fixed version (ground truth):
@Override public void calculate(CalculaterTask thread) throws CancelException {
  clearResult();
  final TestSession ta=getFormulaList().getTaSession();
  if (disableCalculation()) {
    if (!leftTerm.isTerm() && ta != null) {
      ta.setResult(leftTerm.getText(),fillResultString());
    }
    return;
  }
  ArrayList<Equation> linkedIntervals=getAllIntervals();
  if (linkedIntervals.isEmpty()) {
    resultType=ResultType.CONSTANT;
    constantResult=new CalculatedValue();
    leftTerm.getValue(thread,constantResult);
  }
 else   if (linkedIntervals.size() == 1) {
    final CalculatedValue[] argValues=new CalculatedValue[1];
    argValues[0]=new CalculatedValue();
    final ArrayList<Double> xValues=linkedIntervals.get(0).getInterval(thread);
    if (xValues != null && xValues.size() > 0) {
      final int xLength=xValues.size();
      resultType=ResultType.ARRAY_1D;
      arrayArgument=new EquationArrayResult(xLength);
      arrayResult=new EquationArrayResult(xLength,1);
      for (int xIndex=0; xIndex < xLength; xIndex++) {
        final Double x=xValues.get(xIndex);
        argValues[0].setValue(x);
        arrayArgument.getValue1D(xIndex).setValue(x);
        linkedIntervals.get(0).setArgumentValues(argValues);
        leftTerm.getValue(thread,arrayResult.getValue2D(xIndex,0));
      }
    }
 else {
      resultType=ResultType.NAN;
    }
  }
 else   if (linkedIntervals.size() == 2) {
    final CalculatedValue[][] argValues=new CalculatedValue[2][1];
    argValues[0][0]=new CalculatedValue();
    final ArrayList<Double> xValues=linkedIntervals.get(0).getInterval(thread);
    argValues[1][0]=new CalculatedValue();
    final ArrayList<Double> yValues=linkedIntervals.get(1).getInterval(thread);
    if (xValues != null && xValues.size() > 0 && yValues != null && yValues.size() > 0) {
      final int xLength=xValues.size();
      final int yLength=yValues.size();
      resultType=ResultType.ARRAY_2D;
      arrayResult=new EquationArrayResult(xLength,yLength);
      for (int xIndex=0; xIndex < xLength; xIndex++) {
        argValues[0][0].setValue(xValues.get(xIndex));
        linkedIntervals.get(0).setArgumentValues(argValues[0]);
        for (int yIndex=0; yIndex < yLength; yIndex++) {
          argValues[1][0].setValue(yValues.get(yIndex));
          linkedIntervals.get(1).setArgumentValues(argValues[1]);
          leftTerm.getValue(thread,arrayResult.getValue2D(xIndex,yIndex));
        }
      }
    }
 else {
      resultType=ResultType.NAN;
    }
  }
  if (!leftTerm.isTerm() && ta != null) {
    ta.setResult(leftTerm.getText(),fillResultString());
  }
}