module test; metamodel UML : 'http://www.eclipse.org/uml2/3.0.0/UML'; import OCL; static def : allClasses : Sequence(UML!Class) = OclAny::allInstances()->union( UML!Class.allInstances()); def : allModuleNames : Set(String) = self.modules.getKeys()->map(k | k.toString()); context UML!Class def : umlQualifiedName(sep : String) : String = (let parent : OclAny = self.refImmediateComposite() in if parent.oclIsUndefined() then self.name else parent.umlQualifiedName() + sep + self.name endif) + let slottest : String = 'test' in slottest; context Collection(OclAny) def : map(f : Lambda(OclAny):OclAny) : Collection(OclAny) = self->collect(e | f(e)); context Collection(OclAny) def : join(f : Lambda(OclAny, OclAny) : OclAny) : OclAny = self->iterate(e; acc : OclAny = OclUndefined | if acc.oclIsUndefined() then e else f(acc, e) endif ); context OclAny def : name() : String = ''; context String def : name() : String = if self.isEmpty() then super.name() else self endif; context OclAny def : name : String = self.name(); context String def : name : String = super.name; static def : map : Map(OclAny, OclAny) = Map{ (1, 'one'), (2, 'two'), (3, 'three') }; static def : tuple : Tuple(a : String, b : String) = Tuple{ a = 'one', b = 'two' }; static def : tupleType : TupleType(a : String, b : String) = Tuple{ a = 'one', b = 'two' }; context Env static def : main() : Set(String) = (36 + 3.5).toString().debug('arithmetic test') + env.allModuleNames->join(x, y | x + ', ' + y).debug('module names') + Env::map.debug('map').toString() + Env::tuple.debug('tuple').toString();