415863: Support (multiple) virtual dispatch for lazy rules Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=415863
diff --git a/tests/org.eclipse.m2m.atl.emftvm.tests/launch/LazyRuleInheritanceTest.launch b/tests/org.eclipse.m2m.atl.emftvm.tests/launch/LazyRuleInheritanceTest.launch new file mode 100644 index 0000000..68147b6 --- /dev/null +++ b/tests/org.eclipse.m2m.atl.emftvm.tests/launch/LazyRuleInheritanceTest.launch
@@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.m2m.atl.emftvm.launcher.EMFTVMTransformation"> +<stringAttribute key="ATL File Name" value="//org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.atl"/> +<booleanAttribute key="Disable JIT compiler" value="false"/> +<booleanAttribute key="Display Profiling Data" value="false"/> +<booleanAttribute key="Display Timing Data" value="true"/> +<mapAttribute key="Inout Model Options"> +<mapEntry key="trace" value="allowIntermodelReferences createNewModel"/> +</mapAttribute> +<mapAttribute key="Inout Models"> +<mapEntry key="trace" value="platform:/resource/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-trace.xmi"/> +</mapAttribute> +<mapAttribute key="Inout Models Output Locations"> +<mapEntry key="trace" value="platform:/resource/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-trace.xmi"/> +</mapAttribute> +<mapAttribute key="Input Model Options"/> +<mapAttribute key="Input Models"> +<mapEntry key="IN" value="platform:/resource/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.ecore"/> +</mapAttribute> +<mapAttribute key="Metamodel Options"> +<mapEntry key="ECORE" value="isMetametamodel"/> +</mapAttribute> +<mapAttribute key="Metamodels"> +<mapEntry key="ECORE" value=""/> +</mapAttribute> +<stringAttribute key="Module Name" value="LazyRuleInheritanceTest"/> +<stringAttribute key="Module Path" value="/org.eclipse.m2m.atl.emftvm.tests/test-data/"/> +<mapAttribute key="Output Model Options"> +<mapEntry key="OUT" value="allowIntermodelReferences"/> +</mapAttribute> +<mapAttribute key="Output Models"> +<mapEntry key="OUT" value="platform:/resource/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-out.ecore"/> +</mapAttribute> +<listAttribute key="Superimpose"/> +</launchConfiguration>
diff --git a/tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/tests/integration/IntegrationTest.java b/tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/tests/integration/IntegrationTest.java index 1244d9b..aeb55e7 100644 --- a/tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/tests/integration/IntegrationTest.java +++ b/tests/org.eclipse.m2m.atl.emftvm.tests/src/org/eclipse/m2m/atl/emftvm/tests/integration/IntegrationTest.java
@@ -68,7 +68,33 @@ } /** - * Tests regression of <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=408391">Bug # 408391</a>. + * Tests "LazyRuleInheritanceTest.atl". + */ + public void testLazyRuleInheritance() throws Exception { + final ResourceSet rs = new ResourceSetImpl(); + final ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv(); + final TimingData td = new TimingData(); + env.registerInputModel("IN", loadTestModel(rs, "/test-data/LazyRuleInheritanceTest.ecore")); + env.registerOutputModel("OUT", createTestModel(rs, "/test-data/LazyRuleInheritanceTest-out.ecore")); + env.registerInOutModel("trace", createTestModel(rs, "/test-data/LazyRuleInheritanceTest-trace.xmi")); + env.loadModule(createTestModuleResolver(), "LazyRuleInheritanceTest"); + td.finishLoading(); + env.run(td); + td.finish(); + ATLLogger.info("Finished LazyRuleInheritanceTest:\n" + td.toString()); + + final ResourceSet refRs = new ResourceSetImpl(); + loadTestModel(refRs, "/test-data/LazyRuleInheritanceTest.ecore"); + final Model refOut = loadTestModel(refRs, "/test-data/LazyRuleInheritanceTest-out.ecore"); + final Model refTrace = loadTestModel(refRs, "/test-data/LazyRuleInheritanceTest-trace.xmi"); + assertEquals(refOut.getResource(), env.getOutputModels().get("OUT").getResource()); + assertEquals(refTrace.getResource(), env.getInoutModels().get("trace").getResource()); + } + + /** + * Tests regression of + * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=408391">Bug # + * 408391</a>. */ public void testBug408391() { final ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv();
diff --git a/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-out.ecore b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-out.ecore new file mode 100644 index 0000000..b362c37 --- /dev/null +++ b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-out.ecore
@@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"> + <ecore:EPackage name="LazyRuleInheritanceTest" nsURI="LazyRuleInheritanceTest" nsPrefix="LazyRuleInheritanceTest"> + <eClassifiers xsi:type="ecore:EClass" name="ClassA"/> + <eSubpackages name="subpackage" nsURI="subpackage" nsPrefix="subpackage"> + <eClassifiers xsi:type="ecore:EClass" name="ClassB" abstract="true"/> + </eSubpackages> + </ecore:EPackage> + <ecore:EPackage name="subpackage" nsURI="subpackage" nsPrefix="subpackage"> + <eClassifiers xsi:type="ecore:EClass" name="ClassB" abstract="true"/> + </ecore:EPackage> +</xmi:XMI>
diff --git a/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-trace.xmi b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-trace.xmi new file mode 100644 index 0000000..7d49b13 --- /dev/null +++ b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest-trace.xmi
@@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="ASCII"?> +<trace:TraceLinkSet xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:trace="http://www.eclipse.org/m2m/atl/emftvm/2011/Trace"> + <rules rule="EPackage"> + <links> + <sourceElements name="s"> + <object href="LazyRuleInheritanceTest.ecore#/"/> + </sourceElements> + <targetElements name="t"> + <object href="LazyRuleInheritanceTest-out.ecore#/0"/> + </targetElements> + </links> + <links> + <sourceElements name="s"> + <object href="LazyRuleInheritanceTest.ecore#//subpackage"/> + </sourceElements> + <targetElements name="t"> + <object href="LazyRuleInheritanceTest-out.ecore#/0/subpackage"/> + </targetElements> + </links> + <links> + <sourceElements name="s"> + <object href="LazyRuleInheritanceTest.ecore#//subpackage"/> + </sourceElements> + <targetElements name="t"> + <object href="LazyRuleInheritanceTest-out.ecore#/1"/> + </targetElements> + </links> + </rules> + <rules rule="EClass"> + <links> + <sourceElements name="s"> + <object href="LazyRuleInheritanceTest.ecore#//ClassA"/> + </sourceElements> + <targetElements name="t"> + <object href="LazyRuleInheritanceTest-out.ecore#/0/ClassA"/> + </targetElements> + </links> + <links> + <sourceElements name="s"> + <object href="LazyRuleInheritanceTest.ecore#//subpackage/ClassB"/> + </sourceElements> + <targetElements name="t"> + <object href="LazyRuleInheritanceTest-out.ecore#/0/subpackage/ClassB"/> + </targetElements> + </links> + <links> + <sourceElements name="s"> + <object href="LazyRuleInheritanceTest.ecore#//subpackage/ClassB"/> + </sourceElements> + <targetElements name="t"> + <object href="LazyRuleInheritanceTest-out.ecore#/1/ClassB"/> + </targetElements> + </links> + </rules> +</trace:TraceLinkSet>
diff --git a/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.atl b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.atl new file mode 100644 index 0000000..5247760 --- /dev/null +++ b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.atl
@@ -0,0 +1,58 @@ +-- @atlcompiler emftvm +-- @nsURI ECORE=http://www.eclipse.org/emf/2002/Ecore +module LazyRuleInheritanceTest; + +create OUT : ECORE from IN : ECORE; + +lazy abstract rule EModelElement { + from + s : ECORE!EModelElement + to + t : ECORE!EModelElement +} + +lazy abstract rule ENamedElement extends EModelElement { + from + s : ECORE!ENamedElement + to + t : ECORE!ENamedElement ( + name <- s.name + ) +} + +lazy rule EPackage extends ENamedElement { + from + s : ECORE!EPackage + to + t : ECORE!EPackage ( + nsPrefix <- s.nsPrefix, + nsURI <- s.nsURI, + eClassifiers <- s.eClassifiers->collect(c | thisModule.EModelElement(c)), + eSubpackages <- s.eSubpackages->collect(c | thisModule.EModelElement(c)) + ) +} + +lazy abstract rule EClassifier extends ENamedElement { + from + s : ECORE!EClassifier + to + t : ECORE!EClassifier +} + +lazy rule EClass extends EClassifier { + from + s : ECORE!EClass + to + t : ECORE!EClass ( + "abstract" <- s."abstract" + + ) +} + +endpoint rule map() { + do { + for (p in ECORE!EPackage.allInstances()) { + thisModule.EModelElement(p); + } + } +} \ No newline at end of file
diff --git a/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.ecore b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.ecore new file mode 100644 index 0000000..8f49ea4 --- /dev/null +++ b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.ecore
@@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="LazyRuleInheritanceTest" nsURI="LazyRuleInheritanceTest" nsPrefix="LazyRuleInheritanceTest"> + <eClassifiers xsi:type="ecore:EClass" name="ClassA"/> + <eSubpackages name="subpackage" nsURI="subpackage" nsPrefix="subpackage"> + <eClassifiers xsi:type="ecore:EClass" name="ClassB" abstract="true"/> + </eSubpackages> +</ecore:EPackage>
diff --git a/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.emftvm b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.emftvm new file mode 100644 index 0000000..9276ca0 --- /dev/null +++ b/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/LazyRuleInheritanceTest.emftvm Binary files differ