@Test
 public void test_cg_implies_calls() throws ParserException {
   TestOCL ocl = createOCL();
   StandardLibrary standardLibrary = ocl.getStandardLibrary();
   ExpressionInOCL query = ocl.createQuery(standardLibrary.getOclVoidType(), "self->any(true)");
   String textQuery =
       "name = 'closure' implies\n" + "type.oclAsType(CollectionType).elementType = null";
   ocl.assertQueryTrue(query.getOwnedBody(), textQuery);
   ocl.dispose();
 }
 @Test
 public void test_cg_caught_if() throws ParserException {
   TestOCL ocl = createOCL();
   StandardLibrary standardLibrary = ocl.getStandardLibrary();
   ExpressionInOCL query = ocl.createQuery(standardLibrary.getOclVoidType(), "self->any(true)");
   String textQuery =
       "name = 'closure' implies\n"
           + "if self.ownedSource?.type.oclIsKindOf(SequenceType) or self.ownedSource?.type.oclIsKindOf(OrderedSetType)"
           + "then self.type.oclIsKindOf(OrderedSetType) else self.type.oclIsKindOf(SetType) endif";
   ocl.assertQueryTrue(query.getOwnedBody(), textQuery);
   ocl.dispose();
 }
예제 #3
0
 @Override
 public String toString() {
   OCLExpression bodyExpression = specification.getOwnedBody();
   if (bodyExpression != null) {
     return "<"
         + delegateDomain.getURI()
         + ":query> "
         + bodyExpression; //$NON-NLS-1$ //$NON-NLS-2$
   } else {
     return "<"
         + delegateDomain.getURI()
         + ":query> "
         + specification.getBody(); // $NON-NLS-1$ //$NON-NLS-2$
   }
 }
 @Test
 public void test_self_scope() {
   TestOCL ocl = createOCL();
   ExpressionInOCL query = ocl.assertQuery(null, "Sequence{1}");
   CollectionLiteralExp coll = (CollectionLiteralExp) query.getOwnedBody();
   CollectionItem item = (CollectionItem) coll.getOwnedParts().get(0);
   ocl.assertQueryTrue(item, "type = ownedItem.type");
   //		ocl.assertQueryInvalid(null, "type = item.type");		// A2.2 def'n of invalid = invalid
   ocl.assertQueryInvalid(
       null,
       "let item : CollectionItem = null in item.type = item"); // A2.2 def'n of invalid = invalid
   ocl.assertQueryInvalid(
       null,
       "let item : CollectionItem = invalid in item.type = item"); // A2.2 def'n of invalid =
                                                                   // invalid
   ocl.dispose();
 }