public static double testCaseBasedReasoner(Symbol className, Symbol slotName, int numTrain, int numTest) {
    className = ((Symbol)(className.permanentify()));
    slotName = ((Symbol)(slotName.permanentify()));
    { Surrogate renamed_Class = Logic.getDescription(className).surrogateValueInverse;
      List caseList = Logic.allClassInstances(renamed_Class).listify();
      int numCases = caseList.length();
      Surrogate slot = Logic.getDescription(slotName).surrogateValueInverse;
      OutputFileStream fptr = OutputFileStream.newOutputFileStream("cbr-test-output.txt");
      List trainingCases = List.newList();
      Vector caseVector = Vector.newVector(numCases);
      int numCorrect = 0;

      Logic.shuffleList(caseList);
      if ((numTrain + numTest) > numCases) {
        System.out.println("Error:  training and test instances out number total instances");
        return (0.0);
      }
      { int i = Stella.NULL_INTEGER;
        int iter000 = 0;
        int upperBound000 = numCases - 1;
        Stella_Object renamed_Case = null;
        Cons iter001 = caseList.theConsList;

        for (;(iter000 <= upperBound000) &&
                  (!(iter001 == Stella.NIL)); iter000 = iter000 + 1, iter001 = iter001.rest) {
          i = iter000;
          renamed_Case = iter001.value;
          (caseVector.theArray)[i] = (((LogicObject)(renamed_Case)));
        }
      }
      { int i = Stella.NULL_INTEGER;
        int iter002 = 1;
        int upperBound001 = numTrain;
        boolean unboundedP000 = upperBound001 == Stella.NULL_INTEGER;
        Stella_Object renamed_Case = null;
        Cons iter003 = caseList.theConsList;
        Cons collect000 = null;

        for (;(unboundedP000 ||
                  (iter002 <= upperBound001)) &&
                  (!(iter003 == Stella.NIL)); iter002 = iter002 + 1, iter003 = iter003.rest) {
          i = iter002;
          renamed_Case = iter003.value;
          if (collect000 == null) {
            {
              collect000 = Cons.cons(renamed_Case, Stella.NIL);
              if (trainingCases.theConsList == Stella.NIL) {
                trainingCases.theConsList = collect000;
              }
              else {
                Cons.addConsToEndOfConsList(trainingCases.theConsList, collect000);
              }
            }
          }
          else {
            {
              collect000.rest = Cons.cons(renamed_Case, Stella.NIL);
              collect000 = collect000.rest;
            }
          }
        }
      }
      { int i = Stella.NULL_INTEGER;
        int iter004 = numTrain;
        int upperBound002 = (numTrain + numTest) - 1;

        for (;iter004 <= upperBound002; iter004 = iter004 + 1) {
          i = iter004;
          { LogicObject probe = ((LogicObject)((caseVector.theArray)[i]));
            Symbol caseName = Logic.objectName(probe);
            Stella_Object correctAnswer = LogicObject.getSlotValue(probe, slot);
            Stella_Object answer = LogicObject.generateCaseBasedAnswer(probe, slot, trainingCases);

            if (Stella_Object.eqlP(answer, correctAnswer)) {
              numCorrect = numCorrect + 1;
            }
            fptr.nativeStream.print("Case " + caseName + " predicted: " + answer + " correct: " + correctAnswer);
            System.out.print("Case " + caseName + " predicted: " + answer + " correct: " + correctAnswer);
            fptr.nativeStream.println("  Summary: " + numCorrect + " out of " + numTest);
            System.out.println("  Summary: " + numCorrect + " out of " + numTest);
          }
        }
      }
      return (((double)(numCorrect)) / numTest);
    }
  }