Пример #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_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);
  }