Exemplo n.º 1
0
 @Test
 public void createThis() throws Exception {
   Expression<Unit> unit = f.createThis(null);
   Expression<Vector> pos = f.createPositionOf(unit, null);
   Statement stmt = f.createPrint(pos, null);
   runStatementFor(u, stmt, 0.1);
   System.out.println("The above test should print" + u.getPosition());
   stmt = f.createPrint(unit, null);
   runStatementFor(u, stmt, 0.1);
   System.out.println("The above test should print" + u);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 @Test
 public void createTrue() throws Exception {
   System.out.println(u.getTask());
   Statement stmt = f.createPrint(f.createTrue(null), null);
   runStatementFor(u, stmt, 0.1);
   System.out.println("The above test should print 'true'");
 }
Exemplo n.º 4
0
  @Test
  public void createTasks() throws Exception {
    List<int[]> selectedCubes = new ArrayList<>();
    Statement stmt = f.createPrint(new True(), null);
    List<Task> tasks = f.createTasks("blub", 10, stmt, selectedCubes);

    assertEquals(1, tasks.size());
    assertEquals("blub", tasks.get(0).getName());
    assertEquals(10, tasks.get(0).getPriority());
    assertEquals(stmt, tasks.get(0).getActivity());
    assertEquals(null, tasks.get(0).getSelectedCube());

    selectedCubes.addAll(Arrays.asList(new int[] {0, 0, 0}, new int[] {1, 1, 1}));
    tasks = f.createTasks("test", 25, stmt, selectedCubes);

    assertEquals(2, tasks.size());
    for (Task t : tasks) {
      assertEquals("test", t.getName());
      assertEquals(25, t.getPriority());
      assertEquals(stmt, t.getActivity());
      assertTrue(
          t.getSelectedCube().equals(new Vector(0, 0, 0))
              || t.getSelectedCube().equals(new Vector(1, 1, 1)));
    }
  }
Exemplo n.º 5
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());
  }
Exemplo n.º 6
0
 @Test
 public void createEnemy() throws Exception {
   Unit u2 = new Unit(w);
   Expression<Unit> unit = f.createEnemy(null);
   Statement stmt = f.createPrint(unit, null);
   runStatementFor(u, stmt, 0.1);
   System.out.println("The above test should print" + u2);
 }
Exemplo n.º 7
0
 @Test
 public void createLiteralPosition() throws Exception {
   Expression<Vector> pos = f.createLiteralPosition(5, 5, 5, null);
   Statement stmt = f.createPrint(pos, null);
   runStatementFor(u, stmt, 0.1);
   Vector vec = new Vector(5, 5, 5);
   System.out.println("The above test should print" + vec);
 }
Exemplo n.º 8
0
 @Test
 public void createFriend() throws Exception {
   Faction fact = u.getFaction();
   Unit u2 = new Unit(w);
   while (fact != u2.getFaction()) u2 = new Unit(w);
   Expression<Unit> unit = f.createFriend(null);
   Statement stmt = f.createPrint(unit, null);
   runStatementFor(u, stmt, 0.1);
   System.out.println("The above test should print" + u2);
 }
Exemplo n.º 9
0
  @Test
  public void createPrint() throws Exception {
    Statement print = f.createPrint(new True(), null);

    runStatementFor(u, print, 0.2);
    System.out.println("True should be printed.");

    // Check whether task successfully finished
    assertEquals(null, u.getTask());
    assertEquals(0, u.getFaction().getScheduler().getNbTasks());
  }
Exemplo n.º 10
0
 @Test
 public void createFalse() throws Exception {
   Statement stmt = f.createPrint(f.createFalse(null), null);
   runStatementFor(u, stmt, 0.2);
   System.out.println("The above test should print 'false'");
 }