コード例 #1
0
  public void test_TupleLiteralExp_checkPartsUnique() {
    TupleLiteralExp t = factory.createTupleLiteralExp();
    TupleLiteralPart part1 = factory.createTupleLiteralPart();
    part1.setName("a");
    part1.setType(getOCLStandardLibrary().getString());
    t.getPart().add(part1);
    TupleLiteralPart part2 = factory.createTupleLiteralPart();
    part2.setName("a");
    part2.setType(getOCLStandardLibrary().getInteger());
    t.getPart().add(part2);

    assertProblem(t, ExpressionsValidator.TUPLE_LITERAL_EXP__PARTS_UNIQUE);

    part2.setName("b");

    assertOK(t, ExpressionsValidator.TUPLE_LITERAL_EXP__PARTS_UNIQUE);
  }
コード例 #2
0
  public void test_CollectionRange_checkRangeType() {
    CollectionRange r = factory.createCollectionRange();
    r.setType(fruit);

    IntegerLiteralExp first = factory.createIntegerLiteralExp();
    first.setType(apple);
    TupleLiteralExp last = factory.createTupleLiteralExp();
    last.setType(color);

    r.setFirst(first);
    r.setLast(last);

    assertProblem(r, ExpressionsValidator.COLLECTION_RANGE__RANGE_TYPE);

    last.setType(fruit);

    assertOK(r, ExpressionsValidator.COLLECTION_RANGE__RANGE_TYPE);
  }
コード例 #3
0
  public void test_TupleLiteralExp_checkTupleType() {
    TupleLiteralExp t = factory.createTupleLiteralExp();
    TupleLiteralPart part1 = factory.createTupleLiteralPart();
    part1.setName("a");
    part1.setType(getOCLStandardLibrary().getString());
    t.getPart().add(part1);
    TupleLiteralPart part2 = factory.createTupleLiteralPart();
    part2.setName("b");
    part2.setType(getOCLStandardLibrary().getInteger());
    t.getPart().add(part2);

    t.setType(getOCLStandardLibrary().getBag());

    assertProblem(t, ExpressionsValidator.TUPLE_LITERAL_EXP__TUPLE_TYPE);

    TupleType tt = factory.createTupleType();
    t.setType(tt);

    assertProblem(t, ExpressionsValidator.TUPLE_LITERAL_EXP__TUPLE_TYPE);

    EStructuralFeature a =
        ocl.getEnvironment()
            .getUMLReflection()
            .createProperty("a", getOCLStandardLibrary().getString());
    tt.getEStructuralFeatures().add(a);
    part1.setAttribute(a);

    assertProblem(t, ExpressionsValidator.TUPLE_LITERAL_EXP__TUPLE_TYPE);

    EStructuralFeature b =
        ocl.getEnvironment()
            .getUMLReflection()
            .createProperty("b", getOCLStandardLibrary().getInteger());
    tt.getEStructuralFeatures().add(b);
    part2.setAttribute(b);

    assertOK(t, ExpressionsValidator.TUPLE_LITERAL_EXP__TUPLE_TYPE);
  }