Ejemplo n.º 1
0
  public void test_CollectionLiteralExp_checkNoCollectionInstances() {
    CollectionLiteralExp cl = factory.createCollectionLiteralExp();
    cl.setKind(CollectionKind.COLLECTION_LITERAL);

    assertProblem(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__NO_COLLECTION_INSTANCES);

    cl.setKind(CollectionKind.BAG_LITERAL);

    assertOK(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__NO_COLLECTION_INSTANCES);
  }
Ejemplo n.º 2
0
  public void test_CollectionLiteralExp_checkBagKind() {
    CollectionLiteralExp cl = factory.createCollectionLiteralExp();
    cl.setKind(CollectionKind.COLLECTION_LITERAL);
    cl.setType(factory.createSetType());

    assertOK(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__BAG_KIND);

    cl.setKind(CollectionKind.BAG_LITERAL);

    assertProblem(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__BAG_KIND);

    cl.setType(factory.createBagType());

    assertOK(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__BAG_KIND);
  }
Ejemplo n.º 3
0
  public void test_CollectionLiteralExp_checkElementType_emptySet() {
    CollectionLiteralExp cl = factory.createCollectionLiteralExp();
    cl.setKind(CollectionKind.SET_LITERAL);
    CollectionType ctype = factory.createSetType();
    ctype.setElementType(fruit);
    cl.setType(ctype);

    assertProblem(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__ELEMENT_TYPE);

    ctype.setElementType(getOCLStandardLibrary().getOclVoid());

    assertOK(cl, ExpressionsValidator.COLLECTION_LITERAL_EXP__ELEMENT_TYPE);
  }
Ejemplo n.º 4
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);
  }