Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Efftinge2011-08-09 15:53:37 +0000
committerEd Merks2011-08-09 15:53:59 +0000
commite93af52f643f7c858ee563a091c5bce0e00b8161 (patch)
tree3356b6910c06e5066e5df064fba722c6f502b458 /org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.xtend
parentbcb6ced01df3f0ee885b00271c8191e9b2a80abc (diff)
downloadorg.eclipse.emf-e93af52f643f7c858ee563a091c5bce0e00b8161.tar.gz
org.eclipse.emf-e93af52f643f7c858ee563a091c5bce0e00b8161.tar.xz
org.eclipse.emf-e93af52f643f7c858ee563a091c5bce0e00b8161.zip
Started work on Interpreter
Diffstat (limited to 'org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.xtend')
-rw-r--r--org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.xtend67
1 files changed, 67 insertions, 0 deletions
diff --git a/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.xtend b/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.xtend
new file mode 100644
index 000000000..7c0200cfb
--- /dev/null
+++ b/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.xtend
@@ -0,0 +1,67 @@
+package org.eclipse.emf.ecore.xcore.tests.interpreter
+
+import com.google.inject.Inject
+import org.eclipse.emf.common.util.BasicEList
+import org.eclipse.emf.ecore.EClass
+import org.eclipse.emf.ecore.EPackage
+import org.eclipse.emf.ecore.xcore.XPackage
+import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider
+import org.eclipse.xtext.junit4.InjectWith
+import org.eclipse.xtext.junit4.XtextRunner
+import org.eclipse.xtext.junit4.util.ParseHelper
+import org.eclipse.xtext.junit4.validation.ValidationTestHelper
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import static org.junit.Assert.*
+
+@RunWith(typeof(XtextRunner))
+@InjectWith(typeof(XcoreInjectorProvider))
+class XcoreInterpreterTest {
+
+ @Inject
+ ParseHelper<XPackage> parse
+
+ @Inject
+ ValidationTestHelper validator
+
+ @Test
+ def void testInterpretation() {
+ val pack = parse.parse('''
+ package foo.bar
+
+ class Foo {
+ op String doStuff(String msg) {
+ return "Foo says hi to "+msg
+ }
+ }
+ ''')
+ validator.assertNoErrors(pack)
+ val ePackage = pack.eResource.contents.get(2) as EPackage
+ val fooClass = ePackage.getEClassifier("Foo") as EClass
+ val foo = ePackage.EFactoryInstance.create(fooClass)
+ assertEquals("Foo says hi to Bar", foo.eInvoke(fooClass.EOperations.head, new BasicEList(newArrayList("Bar"))))
+ }
+
+ @Test
+ def void testInterpretation_2() {
+ val pack = parse.parse('''
+ package foo.bar
+
+ class Foo {
+ op String call1(String msg) {
+ return "call1"+call2("call1"+msg)
+ }
+
+ op String call2(String msg) {
+ return "call2"+msg
+ }
+ }
+ ''')
+ validator.assertNoErrors(pack)
+ val ePackage = pack.eResource.contents.get(2) as EPackage
+ val fooClass = ePackage.getEClassifier("Foo") as EClass
+ val foo = ePackage.EFactoryInstance.create(fooClass)
+ assertEquals("call1call2call1Bar", foo.eInvoke(fooClass.EOperations.head, new BasicEList(newArrayList("Bar"))))
+ }
+} \ No newline at end of file

Back to the top