summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorahaase2008-02-02 11:18:15 (EST)
committer ahaase2008-02-02 11:18:15 (EST)
commit2076b9349226501b0f59bf06388d81366804a619 (patch)
tree0d420f4afb6e1587cfb337ff96f61778180c4f67
parentf22ee6d98adcbf897c8ae2bd3678fb9ebb05428a (diff)
downloadorg.eclipse.xpand-2076b9349226501b0f59bf06388d81366804a619.zip
org.eclipse.xpand-2076b9349226501b0f59bf06388d81366804a619.tar.gz
org.eclipse.xpand-2076b9349226501b0f59bf06388d81366804a619.tar.bz2
added tests
-rw-r--r--tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/common/ExpressionBaseTest.java56
-rw-r--r--tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/expr/InitClosureExpressionTest.java2
-rw-r--r--tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/helpers/BackendTestHelper.java2
-rw-r--r--tests/org.eclipse.xtend.backend.test/todo.txt2
4 files changed, 58 insertions, 4 deletions
diff --git a/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/common/ExpressionBaseTest.java b/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/common/ExpressionBaseTest.java
new file mode 100644
index 0000000..0a01dff
--- /dev/null
+++ b/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/common/ExpressionBaseTest.java
@@ -0,0 +1,56 @@
+/*
+Copyright (c) 2008 Arno Haase.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Arno Haase - initial API and implementation
+ */
+package org.eclipse.xtend.backend.common;
+
+import static org.eclipse.xtend.backend.helpers.BackendTestHelper.*;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+
+/**
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public class ExpressionBaseTest {
+ @Test public void testExecutionListener () {
+ final List<String> log = new ArrayList<String> ();
+
+ final ExpressionBase expr = createLiteral ("a");
+
+ expr.registerExecutionListener (new ExecutionListener () {
+ public void preExecute (ExecutionContext ctx) {
+ log.add ("preFirst");
+ }
+
+ public void postExecute (Object result, ExecutionContext ctx) {
+ log.add ("postFirst");
+ }
+ });
+ expr.registerExecutionListener (new ExecutionListener () {
+ public void preExecute (ExecutionContext ctx) {
+ log.add ("preSecond");
+ }
+
+ public void postExecute (Object result, ExecutionContext ctx) {
+ log.add ("postSecond");
+ }
+ });
+
+ expr.evaluate (createEmptyExecutionContext());
+
+ assertEquals (Arrays.asList ("preFirst", "preSecond", "postSecond", "postFirst"), log);
+ }
+}
diff --git a/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/expr/InitClosureExpressionTest.java b/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/expr/InitClosureExpressionTest.java
index f230d04..d983329 100644
--- a/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/expr/InitClosureExpressionTest.java
+++ b/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/expr/InitClosureExpressionTest.java
@@ -99,7 +99,7 @@ public class InitClosureExpressionTest {
}));
- final ExecutionContext initCtx = BackendFacade.createExecutionContext (fdc, ts);
+ final ExecutionContext initCtx = BackendFacade.createExecutionContext (fdc, ts, true);
final ExpressionBase body = new InvocationOnObjectExpression ("myFunction", new ArrayList<ExpressionBase> (), false, SOURCE_POS);
final Function closure = (Function) new InitClosureExpression (new ArrayList<String>(), new ArrayList<BackendType>(), body, SOURCE_POS).evaluate (initCtx);
diff --git a/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/helpers/BackendTestHelper.java b/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/helpers/BackendTestHelper.java
index daec6f1..2c770bb 100644
--- a/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/helpers/BackendTestHelper.java
+++ b/tests/org.eclipse.xtend.backend.test/src/org/eclipse/xtend/backend/helpers/BackendTestHelper.java
@@ -33,7 +33,7 @@ public class BackendTestHelper {
*/
public static ExecutionContext createEmptyExecutionContext () {
final BackendTypesystem ts = new CompositeTypesystem ();
- return BackendFacade.createExecutionContext (new FunctionDefContextFactory (ts).create(), ts);
+ return BackendFacade.createExecutionContext (new FunctionDefContextFactory (ts).create(), ts, true);
}
public static ExpressionBase createLiteral (Object literal) {
diff --git a/tests/org.eclipse.xtend.backend.test/todo.txt b/tests/org.eclipse.xtend.backend.test/todo.txt
index b18188b..f38caf1 100644
--- a/tests/org.eclipse.xtend.backend.test/todo.txt
+++ b/tests/org.eclipse.xtend.backend.test/todo.txt
@@ -1,7 +1,5 @@
todo
----
-Java-Type <--> Canonical type
-Aufruf der Listener
CurriedFunction, CurryingExpression
GlobalParamExpression