Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordwagelaar2013-04-23 16:04:24 -0400
committerdwagelaar2013-04-23 16:04:24 -0400
commit66dca3c34f35cffbd41905020fc6351b024cddb8 (patch)
tree4542c684c4b491364653108c9aff5506a22f2a45
parentb455d7e9f2a6f5c1cb12b232b4d544a211a1b30f (diff)
downloadorg.eclipse.atl-66dca3c34f35cffbd41905020fc6351b024cddb8.tar.gz
org.eclipse.atl-66dca3c34f35cffbd41905020fc6351b024cddb8.tar.xz
org.eclipse.atl-66dca3c34f35cffbd41905020fc6351b024cddb8.zip
Add OclAny::debug() + tests.
-rw-r--r--plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/util/OCLOperations.java20
-rw-r--r--tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/util/tests/OCLOperationsTest.java26
2 files changed, 46 insertions, 0 deletions
diff --git a/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/util/OCLOperations.java b/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/util/OCLOperations.java
index c54ef6a4..232c3bdf 100644
--- a/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/util/OCLOperations.java
+++ b/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/util/OCLOperations.java
@@ -237,6 +237,26 @@ public final class OCLOperations {
// OclAny
/////////////////////////////////////////////////////////////////////
createOperation(false, "debug", Types.OCL_ANY_TYPE, Types.OCL_ANY_TYPE,
+ new String[][][]{},
+ new NativeCodeBlock() {
+ @Override
+ public Object execute(final StackFrame frame) {
+ final Object object = frame.getLocal(0, 0);
+ final StringBuffer buf = new StringBuffer();
+ if (object instanceof String) {
+ buf.append('\'');
+ buf.append((String)object);
+ buf.append('\'');
+ } else if (object instanceof LazyCollection<?>) {
+ buf.append(((LazyCollection<?>)object).asString());
+ } else {
+ buf.append(object);
+ }
+ ATLLogger.info(buf.toString());
+ return object;
+ }
+ });
+ createOperation(false, "debug", Types.OCL_ANY_TYPE, Types.OCL_ANY_TYPE,
new String[][][]{{{"message"}, Types.STRING_TYPE}},
new NativeCodeBlock() {
@Override
diff --git a/tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/util/tests/OCLOperationsTest.java b/tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/util/tests/OCLOperationsTest.java
index cde5a107..7c73b0ec 100644
--- a/tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/util/tests/OCLOperationsTest.java
+++ b/tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/util/tests/OCLOperationsTest.java
@@ -37,6 +37,32 @@ import org.eclipse.m2m.atl.emftvm.util.Types;
public class OCLOperationsTest extends TestCase {
/**
+ * Tests OclAny::debug().
+ */
+ public void testOclAnyDebug() {
+ final Operation debug = findOperation("debug", Types.OCL_ANY_TYPE, new String[][] {}, false);
+ assertNotNull(debug);
+ final StackFrame frame = new StackFrame(EmftvmFactory.eINSTANCE.createExecEnv(), debug.getBody());
+ final Object object = new Object();
+ frame.setLocals(new Object[] { object });
+ final Object result = debug.getBody().execute(frame);
+ assertSame(object, result);
+ }
+
+ /**
+ * Tests OclAny::debug(message : String).
+ */
+ public void testOclAnyDebug_String() {
+ final Operation debug = findOperation("debug", Types.OCL_ANY_TYPE, new String[][] { Types.STRING_TYPE }, false);
+ assertNotNull(debug);
+ final StackFrame frame = new StackFrame(EmftvmFactory.eINSTANCE.createExecEnv(), debug.getBody());
+ final Object object = new Object();
+ frame.setLocals(new Object[] { object, "message" });
+ final Object result = debug.getBody().execute(frame);
+ assertSame(object, result);
+ }
+
+ /**
* Tests Class::refNewInstance(args : Sequence).
*/
public void testClassRefNewInstance() {

Back to the top