Exemplo n.º 1
0
 /**
  * Call nextEvaluation() the expected number of times, and check that it returns true (or throws
  * an exception).
  */
 @Action
 public void nextEval() {
   assert data_ != null;
   debug("nextEval trying nextEval() " + data_.successes + " times.");
   if (data_.successes > 1) {
     // just check that true is returned the expected number of times.
     for (int i = data_.successes; i > 0; i--) Assert.assertTrue(pred_.nextEvaluation());
   } else if (data_.successes == 1) {
     Assert.assertTrue("nextEvaluation should be true", pred_.nextEvaluation());
     // check that the correct results were returned.
     Envir newenv = pred_.getEnvir();
     debug("nextEval returns newenv=" + newenv);
     for (int i = 0; i < names_.length; i++) {
       Assert.assertTrue(names_[i] + " undefined.", newenv.isDefined(names_[i]));
       Assert.assertEquals(
           names_[i] + " has incorrect value.", data_.args[i], newenv.lookup(names_[i]));
     }
   } else if (data_.successes == Eval.UNDEF) {
     try {
       pred_.nextEvaluation();
       Assert.fail("Should have thrown UndefException: " + pred_);
     } catch (UndefException ex) {
       // Good!
     }
   }
   // else data_.successes == 0, so we do nothing.
   data_ = null;
   state_ = State.Finished;
 }