Author: kohsuke Date: Mon Dec 26 21:31:04 2005 New Revision: 359177 URL: http://svn.apache.org/viewcvs?rev=359177&view=rev Log: added a regression test case for the null variable handling
Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/NullVariableMethodFlow.java (with props) Modified: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java Modified: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java?rev=359177&r1=359176&r2=359177&view=diff ============================================================================== --- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java (original) +++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java Mon Dec 26 21:31:04 2005 @@ -6,16 +6,23 @@ import org.apache.commons.javaflow.flow.NewObjectFlow; import org.apache.commons.javaflow.flow.NoReferenceBugFlow; import org.apache.commons.javaflow.flow.StackBugFlow; +import org.apache.commons.javaflow.flow.NullVariableMethodFlow; public final class RewritingTestCase extends AbstractTestCase { - + public void testNewObject() throws Exception { final Runnable r = new NewObjectFlow(); final Continuation c = Continuation.startWith(r); assertTrue(c == null); } + public void testNullVariableMethod() throws Exception { + final Runnable r = new NullVariableMethodFlow(); + final Continuation c = Continuation.startWith(r); + assertTrue(c == null); + } + public void testStackBug() throws Exception { final Runnable r = new StackBugFlow(); final Continuation c = Continuation.startWith(r); @@ -33,7 +40,7 @@ final Continuation c = Continuation.startWith(r); assertTrue(c != null); } - + public void testBlackRed() throws Exception { final Runnable r = new BlackRedFlow(); final Continuation c1 = Continuation.startWith(r); @@ -41,16 +48,16 @@ final Continuation c2 = Continuation.continueWith(c1); assertTrue(c2 == null); } - + public void testCounter() throws Exception { final int count = 5; final Runnable r = new CounterFlow(count); - + int i = 0; for(Continuation c = Continuation.startWith(r); c != null; c = Continuation.continueWith(c)) { i++; } - + assertTrue(i == count); } Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/NullVariableMethodFlow.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/NullVariableMethodFlow.java?rev=359177&view=auto ============================================================================== --- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/NullVariableMethodFlow.java (added) +++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/NullVariableMethodFlow.java Mon Dec 26 21:31:04 2005 @@ -0,0 +1,33 @@ +package org.apache.commons.javaflow.flow; + +import java.util.Properties; + +/** + * A regression test case for handling null in the local variables. + * + * @author Kohsuke Kawaguchi + */ +public class NullVariableMethodFlow implements Runnable { + + public void run() { + getLocalAddress(System.getProperties()); + } + + public static String getLocalAddress(Properties session) { + String x = null, y; + + // when javaflow generates the store/load code around this invocation, + // x is of the type 'null'. we have to restore the local variable + // in the correct type (in particular not java/lang/Object, but "null") + // or otherwise VerifyError occurs. + y = session.getProperty("a"); + if (y == null) { + x = session.getProperty("b"); + } + + if (y == null) + y = x; + + return y; + } +} Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/NullVariableMethodFlow.java ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]