commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r413659 - in /jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation: rewrite/SimpleSynchronized.java rewrite/SimpleTryCatch.java tests/AbstractSimpleTestCase.java
Date Mon, 12 Jun 2006 14:08:21 GMT
Author: tcurdt
Date: Mon Jun 12 07:08:21 2006
New Revision: 413659

URL: http://svn.apache.org/viewvc?rev=413659&view=rev
Log:
tests for the outstanding issues: try/catch/finally/synchronized

Added:
    jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSynchronized.java
  (with props)
    jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleTryCatch.java
  (with props)
Modified:
    jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSynchronized.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSynchronized.java?rev=413659&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSynchronized.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSynchronized.java
Mon Jun 12 07:08:21 2006
@@ -0,0 +1,30 @@
+package org.apache.commons.javaflow.bytecode.transformation.rewrite;
+
+import org.apache.commons.javaflow.Continuation;
+
+public final class SimpleSynchronized implements Runnable {
+
+	public boolean a = false;
+	public boolean b = false;
+	public boolean c = false;
+	public boolean d = false;
+	public boolean e = false;
+	public boolean f = false;
+
+	private Object o = new Object();
+	
+	public void run() {		
+		a = true;
+		Continuation.suspend();
+		b = true;
+		synchronized(o) {
+			c = true;
+			Continuation.suspend();
+			d = true;
+		}
+		e = true;
+		Continuation.suspend();
+		f = true;		
+    }
+
+}
\ No newline at end of file

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSynchronized.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleSynchronized.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleTryCatch.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleTryCatch.java?rev=413659&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleTryCatch.java
(added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleTryCatch.java
Mon Jun 12 07:08:21 2006
@@ -0,0 +1,39 @@
+package org.apache.commons.javaflow.bytecode.transformation.rewrite;
+
+import org.apache.commons.javaflow.Continuation;
+
+public final class SimpleTryCatch implements Runnable {
+
+	public boolean a = false;
+	public boolean b = false;
+	public boolean c = false;
+	public boolean d = false;
+	public boolean e = false;
+	public boolean f = false;
+
+	private final boolean throwException;
+	
+	public SimpleTryCatch(final boolean pThrowException) {
+		throwException = pThrowException;
+	}
+	
+	public void run() {
+    	try {
+    		a = true;
+    		Continuation.suspend();
+    		if (throwException) {
+    			throw new Exception("exception");
+    		}
+    		b = true;
+    	} catch(Exception e) {
+    		c = true;
+    		Continuation.suspend();
+    		d = true;
+    	} finally {
+    		e = true;
+    		Continuation.suspend();
+    		f = true;
+    	}    	
+    }
+
+}
\ No newline at end of file

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleTryCatch.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/SimpleTryCatch.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java?rev=413659&r1=413658&r2=413659&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSimpleTestCase.java
Mon Jun 12 07:08:21 2006
@@ -3,12 +3,119 @@
 import org.apache.commons.javaflow.Continuation;
 import org.apache.commons.javaflow.bytecode.transformation.AbstractTransformerTestCase;
 import org.apache.commons.javaflow.bytecode.transformation.rewrite.Simple;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.SimpleSynchronized;
+import org.apache.commons.javaflow.bytecode.transformation.rewrite.SimpleTryCatch;
 
 public abstract class AbstractSimpleTestCase extends AbstractTransformerTestCase {
 
     public void testSimpleSuspend() throws Exception {
-        final Runnable r = new Simple();
+        final Simple r = new Simple();
         final Continuation c = Continuation.startWith(r);
         assertTrue(c != null);
+    }
+
+    public void testSimpleTryCatchWithoutException() throws Exception {
+        final SimpleTryCatch r = new SimpleTryCatch(false);
+        Continuation c;
+
+        c = Continuation.startWith(r);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);    
+    }
+
+    public void testSimpleTryCatchWithException() throws Exception {
+        final SimpleTryCatch r = new SimpleTryCatch(true);
+        Continuation c;
+
+        c = Continuation.startWith(r);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertTrue(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);    
+    }
+
+    public void testSimpleSynchronized() throws Exception {
+        final SimpleSynchronized r = new SimpleSynchronized();
+        Continuation c;
+
+        c = Continuation.startWith(r);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message