package org.eclipse.xtext.xtext2ecore;

import java.util.List;

import org.eclipse.emf.ecore.EPackage;
import org.eclipse.xtext.Grammar;
import org.eclipse.xtext.XtextLanguageFacade;
import org.eclipse.xtext.XtextStandaloneSetup;
import org.eclipse.xtext.tests.AbstractGeneratorTest;
import org.eclipse.xtext.xtextutil.XtextutilPackage;

public class MultiEPackagesTest extends AbstractGeneratorTest {
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		XtextutilPackage.eINSTANCE.getAbstractType();
		XtextStandaloneSetup.doSetup();
		with(XtextLanguageFacade.LANGUAGE_ID);
	}
	
	@SuppressWarnings("unchecked")
	public void testMultiEpackageGen() throws Exception {
		Grammar model = (Grammar) getModel("generate foo 'foo' generate bar 'bar' as bar Foo : 'foo' bar=Bar; Bar returns bar::Bar : flag?='bar';");
		List<EPackage> result = (List<EPackage>) invokeWithXtend("transform()", model);
		assertEquals(2,result.size());
		assertWithXtend("1", "get(0).eClassifiers.size", result);
		assertWithXtend("'Foo'", "get(0).eClassifiers.first().name", result);
		
		assertWithXtend("1", "get(1).eClassifiers.size", result);
		assertWithXtend("'Bar'", "get(1).eClassifiers.first().name", result);
	}
	
	@Override
	protected String[] importedExtensions() {
		return new String[]{"org::eclipse::xtext::xtext2ecore::Xtext2Ecore"};
	}
}

@@ -647,24 +647,14 @@
 test
-MultiEpackageGen
+Simple
 () t
@@ -1196,21 +1196,909 @@
 esult);%0A
-
 %09%7D%0A%09%0A
+%09@SuppressWarnings(%22unchecked%22)%0A%09public void testInheritance() throws Exception %7B%0A%09%09Grammar model = (Grammar) getModel(%22generate foo 'foo' generate bar 'bar' as bar Main : Foo %7C Bar; Foo : 'foo' bar=Bar; Bar returns bar::Bar : flag?='bar';%22);%0A%09%09List%3CEPackage%3E result = (List%3CEPackage%3E) invokeWithXtend(%22transform()%22, model);%0A%09%09assertEquals(2,result.size());%0A%09%09assertWithXtend(%222%22, %22get(0).eClassifiers.size%22, result);%0A%09%09assertWithXtend(%22'Main'%22, %22get(0).eClassifiers.get(0).name%22, result);%0A%09%09assertWithXtend(%22'Foo'%22, %22get(0).eClassifiers.get(1).name%22, result);%0A%09%09assertWithXtend(%22'Main'%22, %22get(0).eClassifiers.get(1).eSuperTypes.first().name%22, result);%0A%09%09%0A%09%09assertWithXtend(%221%22, %22get(1).eClassifiers.size%22, result);%0A%09%09assertWithXtend(%22'Bar'%22, %22get(1).eClassifiers.first().name%22, result);%0A%09%09assertWithXtend(%22'Main'%22, %22get(1).eClassifiers.first().eSuperTypes.first().name%22, result);%0A%09%7D%0A%09%0A%09%0A
 %09@Overri

test added