Пример #1
0
  public void test_IteratorExp_checkCollectType() {
    EClassifier set = getOCLStandardLibrary().getSet();
    EClassifier orderedSet = getOCLStandardLibrary().getOrderedSet();
    EClassifier sequence = getOCLStandardLibrary().getSequence();
    EClassifier bag = getOCLStandardLibrary().getBag();
    List<EClassifier[]> badPairs = new java.util.ArrayList<EClassifier[]>();
    badPairs.add(new EClassifier[] {set, sequence});
    badPairs.add(new EClassifier[] {bag, sequence});
    badPairs.add(new EClassifier[] {sequence, bag});
    badPairs.add(new EClassifier[] {sequence, set});
    badPairs.add(new EClassifier[] {orderedSet, bag});
    List<EClassifier[]> goodPairs = new java.util.ArrayList<EClassifier[]>();
    goodPairs.add(new EClassifier[] {set, bag});
    goodPairs.add(new EClassifier[] {bag, bag});
    goodPairs.add(new EClassifier[] {sequence, sequence});
    goodPairs.add(new EClassifier[] {orderedSet, sequence});

    IteratorExp i = factory.createIteratorExp();
    i.setName("collect");

    OCLExpression source = factory.createBooleanLiteralExp();
    i.setSource(source);

    for (EClassifier[] pair : badPairs) {
      source.setType(pair[0]);
      i.setType(pair[1]);
      assertProblem(i, ExpressionsValidator.ITERATOR_EXP__COLLECT_TYPE);
    }

    for (EClassifier[] pair : goodPairs) {
      source.setType(pair[0]);
      i.setType(pair[1]);
      assertOK(i, ExpressionsValidator.ITERATOR_EXP__COLLECT_TYPE);
    }
  }
Пример #2
0
  public void test_IteratorExp_checkBooleanType() {
    IteratorExp i = factory.createIteratorExp();
    i.setType(apple);

    i.setName("select");
    assertOK(i, ExpressionsValidator.ITERATOR_EXP__BOOLEAN_TYPE);

    for (String name : Arrays.asList("forAll", "exists", "isUnique")) {
      i.setName(name);
      assertProblem(i, ExpressionsValidator.ITERATOR_EXP__BOOLEAN_TYPE);
    }

    i.setType(getOCLStandardLibrary().getBoolean());

    for (String name : Arrays.asList("forAll", "exists", "isUnique")) {
      i.setName(name);
      assertOK(i, ExpressionsValidator.ITERATOR_EXP__BOOLEAN_TYPE);
    }
  }
Пример #3
0
  public void test_IteratorExp_checkSelectRejectType() {
    IteratorExp i = factory.createIteratorExp();
    i.setType(getOCLStandardLibrary().getSet());

    OCLExpression source = factory.createBooleanLiteralExp();
    source.setType(getOCLStandardLibrary().getBag());
    i.setSource(source);

    for (String name : Arrays.asList("select", "reject")) {
      i.setName(name);
      assertProblem(i, ExpressionsValidator.ITERATOR_EXP__SELECT_REJECT_TYPE);
    }

    i.setType(getOCLStandardLibrary().getBag());

    for (String name : Arrays.asList("select", "reject")) {
      i.setName(name);
      assertOK(i, ExpressionsValidator.ITERATOR_EXP__SELECT_REJECT_TYPE);
    }
  }
Пример #4
0
  public void test_IteratorExp_checkBooleanBodyType() {
    List<String> names = Arrays.asList("select", "reject", "forAll", "exists", "any", "one");
    IteratorExp i = factory.createIteratorExp();
    i.setType(getOCLStandardLibrary().getSet());

    OCLExpression body = factory.createBooleanLiteralExp();
    body.setType(getOCLStandardLibrary().getBag());
    i.setBody(body);

    i.setName("collect");
    assertOK(i, ExpressionsValidator.ITERATOR_EXP__BOOLEAN_BODY_TYPE);

    for (String name : names) {
      i.setName(name);
      assertProblem(i, ExpressionsValidator.ITERATOR_EXP__BOOLEAN_BODY_TYPE);
    }

    body.setType(getOCLStandardLibrary().getBoolean());

    for (String name : names) {
      i.setName(name);
      assertOK(i, ExpressionsValidator.ITERATOR_EXP__BOOLEAN_BODY_TYPE);
    }
  }