예제 #1
0
  public void test_CollectionItem_checkItemType() {
    CollectionItem i = factory.createCollectionItem();
    CollectionType ctype = factory.createCollectionType();
    ctype.setElementType(fruit);
    i.setType(ctype);

    CollectionLiteralExp item = factory.createCollectionLiteralExp();
    CollectionType itemType = factory.createCollectionType();
    itemType.setElementType(apple);
    item.setType(itemType);

    i.setItem(item);

    assertProblem(i, ExpressionsValidator.COLLECTION_ITEM__ITEM_TYPE);

    item.setType(ctype);

    assertOK(i, ExpressionsValidator.COLLECTION_ITEM__ITEM_TYPE);
  }
예제 #2
0
  public void test_CollectionLiteralExp_checkElementType() {
    CollectionLiteralExp cl = factory.createCollectionLiteralExp();
    cl.setKind(CollectionKind.SET_LITERAL);
    CollectionType ctype = factory.createSetType();
    ctype.setElementType(fruit);
    cl.setType(ctype);

    CollectionItem item1 = factory.createCollectionItem();
    item1.setType(apple);
    CollectionItem item2 = factory.createCollectionItem();
    item2.setType(color);

    cl.getPart().add(item1);
    cl.getPart().add(item2);

    assertProblem(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__ELEMENT_TYPE);

    item2.setType(fruit);

    assertOK(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__ELEMENT_TYPE);
  }