Exemplo n.º 1
0
 public void test_set_tooBig() {
   ASTNode node = booleanLiteral(true);
   NodeList<ASTNode> list = new NodeList<ASTNode>(argumentList());
   try {
     list.set(1, node);
     fail("Expected IndexOutOfBoundsException");
   } catch (IndexOutOfBoundsException exception) {
     // Expected
   }
 }
Exemplo n.º 2
0
  public void test_set() {
    ArrayList<ASTNode> nodes = new ArrayList<ASTNode>();
    ASTNode firstNode = booleanLiteral(true);
    ASTNode secondNode = booleanLiteral(false);
    ASTNode thirdNode = booleanLiteral(true);
    nodes.add(firstNode);
    nodes.add(secondNode);
    nodes.add(thirdNode);
    NodeList<ASTNode> list = new NodeList<ASTNode>(argumentList());
    list.addAll(nodes);
    assertSize(3, list);

    ASTNode fourthNode = integer(0);
    assertSame(secondNode, list.set(1, fourthNode));
    assertSize(3, list);
    assertSame(firstNode, list.get(0));
    assertSame(fourthNode, list.get(1));
    assertSame(thirdNode, list.get(2));
  }