Ejemplo n.º 1
0
 @Test
 public void createAny() throws Exception {
   Expression<Unit> unit = f.createAny(null);
   Statement stmt = f.createPrint(unit, null);
   runStatementFor(u, stmt, 0.1, 0.01);
   System.out.println("The above test should print null");
   Unit any = new Unit(w);
   Expression<Unit> unit2 = f.createAny(null);
   Statement stmt2 = f.createPrint(unit2, null);
   runStatementFor(u, stmt2, 0.1);
   System.out.println("The above test should print" + any);
 }
Ejemplo n.º 2
0
  @Test
  public void createWhile() throws Exception {
    // new While(new HerePosition(),new Print(new True()));// Dit lukt niet
    new While(new False(), new Print(new False()));

    Expression<Boolean> condition = f.createIsAlive(f.createAny(null), null);
    Statement body = f.createPrint(new LiteralPosition(0, 0, 0), null);
    Statement whileStmt = f.createWhile(condition, body, null);

    Unit test = w.spawnUnit(false);

    runStatementFor(u, whileStmt, 0.1, 0.01); // No exceptions

    // Task is still running:
    assertTrue(u.getTask() != null);
    assertEquals(1, u.getFaction().getScheduler().getNbTasks());

    test.terminate();

    advanceTimeFor(w, 0.1, 0.01);

    // Check whether task successfully finished
    assertEquals(null, u.getTask());
    assertEquals(0, u.getFaction().getScheduler().getNbTasks());
  }