commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1344796 - in /commons/proper/functor/trunk/src: changes/ main/java/org/apache/commons/functor/core/algorithm/ test/java/org/apache/commons/functor/ test/java/org/apache/commons/functor/core/algorithm/
Date Thu, 31 May 2012 16:12:41 GMT
Author: simonetripodi
Date: Thu May 31 16:12:39 2012
New Revision: 1344796

URL: http://svn.apache.org/viewvc?rev=1344796&view=rev
Log:
[FUNCTOR-15] Distribute tests from TestAlgorithms into several test classes under algorithm test package - patch submitted by Bruno P. Kinoshita

Added:
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoUntil.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoWhile.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestInPlaceTransform.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRecursiveEvaluation.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRemoveMatching.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRetainMatching.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestUntilDo.java   (with props)
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestWhileDo.java   (with props)
Modified:
    commons/proper/functor/trunk/src/changes/changes.xml
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoUntil.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoWhile.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FindWithinGenerator.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldLeft.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldRight.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/GeneratorContains.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/InPlaceTransform.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RecursiveEvaluation.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RemoveMatching.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RetainMatching.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/UntilDo.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/WhileDo.java
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java

Modified: commons/proper/functor/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/changes/changes.xml?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/changes/changes.xml (original)
+++ commons/proper/functor/trunk/src/changes/changes.xml Thu May 31 16:12:39 2012
@@ -26,6 +26,9 @@
       <action dev="simonetripodi" issue="FUNCTOR-16" due-to="Bruno P. Kinoshita">
         Fix checkstyle errors
       </action>
+      <action dev="simonetripodi" issue="FUNCTOR-15" due-to="Bruno P. Kinoshita">
+        Distribute tests from TestAlgorithms into several test classes under algorithm test package
+      </action>
       <action dev="simonetripodi" issue="FUNCTOR-9" due-to="Bruno P. Kinoshita">
         Make Limit and Offset Serializable
       </action>

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoUntil.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoUntil.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoUntil.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoUntil.java Thu May 31 16:12:39 2012
@@ -48,4 +48,12 @@ public class DoUntil extends PredicatedL
             getBody().run();
         } while (!getTest().test());
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "DoUntil<" + getBody() + "," + getTest() + ">";
+    }
 }

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoWhile.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoWhile.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoWhile.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/DoWhile.java Thu May 31 16:12:39 2012
@@ -48,4 +48,12 @@ public class DoWhile extends PredicatedL
             getBody().run();
         } while (getTest().test());
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "DoWhile<" + getBody() + "," + getTest() + ">";
+    }
 }

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FindWithinGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FindWithinGenerator.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FindWithinGenerator.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FindWithinGenerator.java Thu May 31 16:12:39 2012
@@ -157,6 +157,14 @@ public final class FindWithinGenerator<E
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "FindWithinGenerator<" + ifNone + "," + useIfNone + ">";
+    }
+
+    /**
      * Get a static {@link FindWithinGenerator} instance.
      * @return {@link FindWithinGenerator}
      */

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldLeft.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldLeft.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldLeft.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldLeft.java Thu May 31 16:12:39 2012
@@ -157,4 +157,12 @@ public class FoldLeft<T> implements Unar
         return "FoldLeft".hashCode() << 2 ^ function.hashCode();
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "FoldLeft<" + function + ">";
+    }
+
 }

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldRight.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldRight.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldRight.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldRight.java Thu May 31 16:12:39 2012
@@ -168,4 +168,12 @@ public class FoldRight<T> implements Una
         return "FoldRight".hashCode() << 2 ^ function.hashCode();
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "FoldRight<" + function + ">";
+    }
+
 }

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/GeneratorContains.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/GeneratorContains.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/GeneratorContains.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/GeneratorContains.java Thu May 31 16:12:39 2012
@@ -100,6 +100,14 @@ public final class GeneratorContains<T> 
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "GeneratorContains";
+    }
+
+    /**
      * Get a static {@link GeneratorContains} instance.
      * @return {@link GeneratorContains}
      */

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/InPlaceTransform.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/InPlaceTransform.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/InPlaceTransform.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/InPlaceTransform.java Thu May 31 16:12:39 2012
@@ -67,6 +67,14 @@ public final class InPlaceTransform<T>
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "InPlaceTransform";
+    }
+
+    /**
      * Get an {@link InPlaceTransform} instance.
      * @return InPlaceTransform
      */

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java Thu May 31 16:12:39 2012
@@ -115,6 +115,14 @@ public final class IndexOfInGenerator<T>
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "IndexOfInGenerator";
+    }
+
+    /**
      * Get a static {@link IndexOfInGenerator} instance.
      * @return {@link IndexOfInGenerator}
      */

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RecursiveEvaluation.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RecursiveEvaluation.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RecursiveEvaluation.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RecursiveEvaluation.java Thu May 31 16:12:39 2012
@@ -106,6 +106,14 @@ public class RecursiveEvaluation impleme
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "RecursiveEvaluation<" + functionType + "," + function + ">";
+    }
+
+    /**
      * Get the class of the specified object, or <code>null</code> if <code>o</code> is <code>null</code>.
      * @param f Object to check
      * @return Class found

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RemoveMatching.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RemoveMatching.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RemoveMatching.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RemoveMatching.java Thu May 31 16:12:39 2012
@@ -69,6 +69,14 @@ public final class RemoveMatching<T>
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "RemoveMatching";
+    }
+
+    /**
      * Get a static {@link RemoveMatching} instance.
      * @return {@link RemoveMatching}
      */

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RetainMatching.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RetainMatching.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RetainMatching.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RetainMatching.java Thu May 31 16:12:39 2012
@@ -70,6 +70,14 @@ public final class RetainMatching<T>
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "RetainMatching";
+    }
+
+    /**
      * Get a static {@link RetainMatching} instance.
      * @return {@link RetainMatching}
      */

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/UntilDo.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/UntilDo.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/UntilDo.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/UntilDo.java Thu May 31 16:12:39 2012
@@ -48,4 +48,12 @@ public class UntilDo extends PredicatedL
             getBody().run();
         }
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "UntilDo<" + getTest() + "," + getBody() + ">";
+    }
 }

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/WhileDo.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/WhileDo.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/WhileDo.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/WhileDo.java Thu May 31 16:12:39 2012
@@ -48,4 +48,12 @@ public class WhileDo extends PredicatedL
             getBody().run();
         }
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return "WhileDo<" + getTest() + "," + getBody() + ">";
+    }
 }

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java?rev=1344796&r1=1344795&r2=1344796&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java (original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java Thu May 31 16:12:39 2012
@@ -17,37 +17,20 @@
 package org.apache.commons.functor;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.NoSuchElementException;
 import java.util.Set;
 
 import org.apache.commons.functor.adapter.LeftBoundPredicate;
 import org.apache.commons.functor.core.Identity;
 import org.apache.commons.functor.core.IsEqual;
-import org.apache.commons.functor.core.Limit;
-import org.apache.commons.functor.core.Offset;
-import org.apache.commons.functor.core.algorithm.DoUntil;
-import org.apache.commons.functor.core.algorithm.DoWhile;
-import org.apache.commons.functor.core.algorithm.FindWithinGenerator;
-import org.apache.commons.functor.core.algorithm.FoldLeft;
-import org.apache.commons.functor.core.algorithm.FoldRight;
-import org.apache.commons.functor.core.algorithm.GeneratorContains;
-import org.apache.commons.functor.core.algorithm.InPlaceTransform;
-import org.apache.commons.functor.core.algorithm.RecursiveEvaluation;
-import org.apache.commons.functor.core.algorithm.RemoveMatching;
-import org.apache.commons.functor.core.algorithm.RetainMatching;
-import org.apache.commons.functor.core.algorithm.UntilDo;
-import org.apache.commons.functor.core.algorithm.WhileDo;
 import org.apache.commons.functor.core.composite.UnaryNot;
 import org.apache.commons.functor.generator.FilteredGenerator;
 import org.apache.commons.functor.generator.Generator;
@@ -98,22 +81,7 @@ public class TestAlgorithms {
     // Tests
     // ------------------------------------------------------------------------
 
-    @Test
-    public void testDetect() {
-        assertEquals(new Integer(3),FindWithinGenerator.instance().evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsThree));
-        try {
-            FindWithinGenerator.instance().evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsTwentyThree);
-            fail("Expected NoSuchElementException");
-        } catch(NoSuchElementException e) {
-            // expected
-        }
-    }
-
-    @Test
-    public void testDetectIfNone() {
-        assertEquals(new Integer(3),new FindWithinGenerator("Xyzzy").evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsThree));
-        assertEquals("Xyzzy",new FindWithinGenerator("Xyzzy").evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsTwentyThree));
-    }
+    
 
     @Test
     public void testRun() {
@@ -151,31 +119,6 @@ public class TestAlgorithms {
     }
 
     @Test
-    public void testRetain() {
-        RetainMatching.instance().run(list.iterator(),isEven);
-        assertEquals(evens,list);
-    }
-
-    @Test
-    public void testRemove() {
-        RemoveMatching.instance().run(list.iterator(),isOdd);
-        assertEquals(evens,list);
-    }
-
-    @Test
-    public void testTransform() {
-        InPlaceTransform.instance().run(
-            list.listIterator(),
-            new UnaryFunction() {
-                public Object evaluate(Object obj) {
-                    return new Integer(((Number) obj).intValue()*2);
-                }
-            }
-        );
-        assertEquals(doubled,list);
-    }
-
-    @Test
     public void testApplyToGenerator() {
         Generator gen = new IntegerRange(1,5);
         Summer summer = new Summer();
@@ -215,107 +158,6 @@ public class TestAlgorithms {
         }
     }
 
-    @Test
-    public void testContains() {
-        assertTrue(GeneratorContains.instance().test(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsThree));
-        assertFalse(GeneratorContains.instance().test(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsTwentyThree));
-    }
-
-    @Test
-    public void testFoldLeft() {
-        FoldLeft foldLeft = new FoldLeft(new BinaryFunction() {
-            public Object evaluate(Object a, Object b) {
-                return new Integer(((Number) a).intValue() + ((Number) b).intValue());
-            }
-        });
-        assertEquals(new Integer(sum), foldLeft.evaluate(IteratorToGeneratorAdapter.adapt(list.iterator())));
-        assertEquals(new Integer(sum), foldLeft.evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()), new Integer(0)));
-    }
-
-    @Test
-    public void testFoldRight() {
-        FoldRight foldRight = new FoldRight(new BinaryFunction() {
-            public Object evaluate(Object left, Object right) {
-                StringBuffer buf = left instanceof StringBuffer ? (StringBuffer) left : new StringBuffer().append(left);
-                return buf.append(right);
-            }
-        });
-        assertEquals("0123456789", foldRight.evaluate(IteratorToGeneratorAdapter.adapt(list.iterator())).toString());
-        assertEquals("0123456789x", foldRight.evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()), "x").toString());
-    }
-
-    @Test
-    public void testDoUntil() {
-        for (int i=0;i<3;i++){
-            Counter counter = new Counter();
-            new DoUntil(counter, new Offset(i)).run();
-            assertEquals(i+1,counter.count);
-        }
-    }
-
-    @Test
-    public void testDoWhile() {
-        for (int i=0;i<3;i++){
-            Counter counter = new Counter();
-            new DoWhile(counter, new Limit(i)).run();
-            assertEquals(i+1,counter.count);
-        }
-    }
-
-    @Test
-    public void testUntilDo() {
-        for (int i=0;i<3;i++){
-            Counter counter = new Counter();
-            new UntilDo(new Offset(i), counter).run();
-            assertEquals(i,counter.count);
-        }
-    }
-
-    @Test
-    public void testWhileDo() {
-        for (int i=0;i<3;i++){
-            Counter counter = new Counter();
-            new WhileDo(new Limit(i),counter).run();
-            assertEquals(i,counter.count);
-        }
-    }
-
-    @Test
-    public void testRecurse() {
-        assertEquals(new Integer(5), new RecursiveEvaluation(new RecFunc(0, false)).evaluate());
-
-        // this version will return a function. since it is not the same type
-        // as RecFunc recursion will end.
-        Function func = (Function) new RecursiveEvaluation(new RecFunc(0, true)).evaluate();
-        assertEquals(new Integer(5), func.evaluate());
-    }
-
-    /** Recursive function for test. */
-    class RecFunc implements Function {
-        int times = 0; boolean returnFunc = false;
-
-        public RecFunc(int times, boolean returnFunc) {
-            this.times = times;
-            this.returnFunc = returnFunc;
-        }
-
-        public Object evaluate() {
-            if (times < 5) {
-                return new RecFunc(++times, returnFunc);
-            } else {
-                if (returnFunc) {
-                    return new Function() {
-                        public Object evaluate() {
-                            return new Integer(times);
-                        }
-                    };
-                } else {
-                    return new Integer(times);
-                }
-            }
-        }
-    }
-
     // Attributes
     // ------------------------------------------------------------------------
     private List list = null;

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoUntil.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoUntil.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoUntil.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoUntil.java Thu May 31 16:12:39 2012
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.functor.Procedure;
+import org.apache.commons.functor.core.Offset;
+import org.apache.commons.functor.core.algorithm.DoUntil;
+import org.junit.Test;
+
+/**
+ * Tests {@link DoUntil} algorithm.
+ */
+public class TestDoUntil {
+
+    @Test
+    public final void testObjectEquals() throws Exception {
+        Counter counter = new Counter();
+        Object obj = new DoUntil(counter, new Offset(10));
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new DoUntil(counter, new Offset(10));
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testDoUntil() {
+        for(int i=0;i<3;++i){
+            Counter counter = new Counter();
+            new DoUntil(counter, new Offset(i)).run();
+            assertEquals(i+1,counter.count);
+        }
+    }
+
+    // Classes
+    // ------------------------------------------------------------------------
+
+    static class Counter implements Procedure {
+        public void run() {
+            count++;
+        }
+        public int count = 0;
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoUntil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoUntil.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoUntil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoWhile.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoWhile.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoWhile.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoWhile.java Thu May 31 16:12:39 2012
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.functor.Procedure;
+import org.apache.commons.functor.core.Limit;
+import org.apache.commons.functor.core.algorithm.DoWhile;
+import org.junit.Test;
+
+/**
+ * Tests {@link DoWhile} algorithm.
+ */
+public class TestDoWhile {
+
+    @Test
+    public final void testObjectEquals() throws Exception {
+        Counter counter = new Counter();
+        Object obj = new DoWhile(counter, new Limit(10));
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new DoWhile(counter, new Limit(10));
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testDoWhile() {
+        for(int i=0;i<3;i++){
+            Counter counter = new Counter();
+            new DoWhile(counter, new Limit(i)).run();
+            assertEquals(i+1,counter.count);
+        }
+    }
+
+    // Classes
+    // ------------------------------------------------------------------------
+
+    static class Counter implements Procedure {
+        public void run() {
+            count++;
+        }
+        public int count = 0;
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoWhile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoWhile.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestDoWhile.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java Thu May 31 16:12:39 2012
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.adapter.LeftBoundPredicate;
+import org.apache.commons.functor.core.IsEqual;
+import org.apache.commons.functor.core.algorithm.FindWithinGenerator;
+import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.junit.Test;
+
+/**
+ * Tests {@link FindWithinGenerator} algorithm.
+ */
+public class TestFindWithinGenerator extends BaseFunctorTest {
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new FindWithinGenerator<Object>();
+    }
+
+    @Test
+    public void testObjectEqualsWithIfNone() throws Exception {
+        Object obj = new FindWithinGenerator<Object>(1);
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new FindWithinGenerator<Object>(1);
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testObjectEqualsWithNullDefault() throws Exception {
+        Object obj = new FindWithinGenerator<Object>(null);
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new FindWithinGenerator<Object>(null);
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testDetect() {
+        assertEquals(new Integer(3),new FindWithinGenerator<Integer>().evaluate(IteratorToGeneratorAdapter.adapt(numbers.iterator()),equalsThree));
+        try {
+            new FindWithinGenerator<Integer>().evaluate(IteratorToGeneratorAdapter.adapt(numbers.iterator()),equalsTwentyThree);
+            fail("Expected NoSuchElementException");
+        } catch(NoSuchElementException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testDetectIfNone() {
+        assertEquals(new Integer(3),new FindWithinGenerator<Integer>(new Integer(3)).evaluate(IteratorToGeneratorAdapter.adapt(numbers.iterator()),equalsThree));
+        assertEquals("Xyzzy",new FindWithinGenerator<String>("Xyzzy").evaluate(IteratorToGeneratorAdapter.adapt(strings.iterator()),equalsXyZ));
+    }
+
+    @Test
+    public void testInstance() {
+        assertNotNull("FindWithinGenerator instance must not be null", FindWithinGenerator.instance());
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    private List<Integer> numbers = Arrays.asList(0,1,2,3,4,5,6,7,8,9);
+    private List<String> strings = Arrays.asList("Zyx", "xxyZ");
+    private UnaryPredicate<Integer> equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
+    private UnaryPredicate<Integer> equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
+    private UnaryPredicate<String> equalsXyZ = LeftBoundPredicate.bind(IsEqual.instance(),"xyZ");
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java Thu May 31 16:12:39 2012
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.functor.BinaryFunction;
+import org.apache.commons.functor.core.algorithm.FoldLeft;
+import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.junit.Test;
+
+/**
+ * Tests {@link FoldLeft} algorithm.
+ */
+public class TestFoldLeft {
+
+    @Test
+    public final void testObjectEquals() throws Exception {
+        Object obj = new FoldLeft<Integer>(new BinaryFunction<Integer, Integer, Integer>() {
+            public Integer evaluate(Integer a, Integer b) {
+                return new Integer(a + b);
+            }
+        });
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new FoldLeft<Integer>(new BinaryFunction<Integer, Integer, Integer>() {
+            public Integer evaluate(Integer a, Integer b) {
+                return new Integer(a + b);
+            }
+        });
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testFoldLeft() {
+        FoldLeft<Integer> foldLeft = new FoldLeft<Integer>(new BinaryFunction<Integer, Integer, Integer>() {
+            public Integer evaluate(Integer a, Integer b) {
+                return new Integer(a + b);
+            }
+        });
+        assertEquals(new Integer(sum), foldLeft.evaluate(IteratorToGeneratorAdapter.adapt(list.iterator())));
+        assertEquals(new Integer(sum), foldLeft.evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()), new Integer(0)));
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+    private List<Integer> list = Arrays.asList(0,1,2);
+    private int sum = 3;
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java Thu May 31 16:12:39 2012
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.functor.BinaryFunction;
+import org.apache.commons.functor.core.algorithm.FoldRight;
+import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.junit.Test;
+
+/**
+ * Tests {@link FoldRight} algorithm.
+ */
+public class TestFoldRight {
+
+    @Test
+    public final void testObjectEquals() throws Exception {
+        Object obj = new FoldRight<Object>(new BinaryFunction<Object, Object, Object>() {
+            public Object evaluate(Object left, Object right) {
+                StringBuffer buf = left instanceof StringBuffer ? (StringBuffer) left : new StringBuffer().append(left);
+                return buf.append(right);
+            }
+        });
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new FoldRight<Object>(new BinaryFunction<Object, Object, Object>() {
+            public Object evaluate(Object left, Object right) {
+                StringBuffer buf = left instanceof StringBuffer ? (StringBuffer) left : new StringBuffer().append(left);
+                return buf.append(right);
+            }
+        });
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testFoldRight() {
+        FoldRight<Object> foldRight = new FoldRight<Object>(new BinaryFunction<Object, Object, Object>() {
+            public Object evaluate(Object left, Object right) {
+                StringBuffer buf = left instanceof StringBuffer ? (StringBuffer) left : new StringBuffer().append(left);
+                return buf.append(right);
+            }
+        });
+        assertEquals("0123456789", foldRight.evaluate(IteratorToGeneratorAdapter.adapt(list.iterator())).toString());
+        assertEquals("0123456789x", foldRight.evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()), "x").toString());
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+    private List<Object> list = Arrays.<Object>asList(0,1,2,3,4,5,6,7,8,9);
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java Thu May 31 16:12:39 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.adapter.LeftBoundPredicate;
+import org.apache.commons.functor.core.IsEqual;
+import org.apache.commons.functor.core.algorithm.GeneratorContains;
+import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.junit.Test;
+
+/**
+ * Tests {@link GeneratorContains} algorithm.
+ */
+public class TestGeneratorContains extends BaseFunctorTest {
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new GeneratorContains<Integer>();
+    }
+
+    @Test
+    public void testContains() {
+        assertTrue(new GeneratorContains<Integer>().test(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsThree));
+        assertFalse(new GeneratorContains<Integer>().test(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsTwentyThree));
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    private List<Integer> list = Arrays.asList(0,1,2,3,4,5,6,7,8,9);
+    private UnaryPredicate<Integer> equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
+    private UnaryPredicate<Integer> equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestInPlaceTransform.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestInPlaceTransform.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestInPlaceTransform.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestInPlaceTransform.java Thu May 31 16:12:39 2012
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.core.algorithm.InPlaceTransform;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link InPlaceTransform} algorithm.
+ */
+public class TestInPlaceTransform extends BaseFunctorTest {
+
+    // Lifecycle
+    // ------------------------------------------------------------------------
+
+    @Before
+    public void setUp() throws Exception {
+        list = new ArrayList<Integer>();
+        doubled = new ArrayList<Integer>();
+        for (int i=0;i<10;i++) {
+            list.add(new Integer(i));
+            doubled.add(new Integer(i*2));
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        list = null;
+        doubled = null;
+    }
+
+    // Tests
+    // ------------------------------------------------------------------------
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new InPlaceTransform<Integer>();
+    }
+
+    @Test
+    public void testTransform() {
+        new InPlaceTransform<Integer>().run(
+            list.listIterator(),
+            new UnaryFunction<Integer, Integer>() {
+                public Integer evaluate(Integer obj) {
+                    return new Integer(obj*2);
+                }
+            }
+        );
+        assertEquals(doubled,list);
+    }
+
+    public void testInstance() {
+        assertNotNull("InPlaceTransform must not be null", InPlaceTransform.instance());
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+    private List<Integer> list = null;
+    private List<Integer> doubled = null;
+
+    // Classes
+    // ------------------------------------------------------------------------
+
+    static class Doubler implements UnaryFunction<Integer, Integer> {
+        public Integer evaluate(Integer obj) {
+            return new Integer(2*obj);
+        }
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestInPlaceTransform.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestInPlaceTransform.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestInPlaceTransform.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java Thu May 31 16:12:39 2012
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.adapter.LeftBoundPredicate;
+import org.apache.commons.functor.core.IsEqual;
+import org.apache.commons.functor.core.algorithm.IndexOfInGenerator;
+import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.junit.Test;
+
+/**
+ * Tests {@link IndexOfInGenerator} algorithm.
+ */
+public class TestIndexOfInGenerator extends BaseFunctorTest {
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new IndexOfInGenerator<Integer>();
+    }
+
+    @Test
+    public void testIndexOfInGenerator() {
+        assertEquals(3L, new IndexOfInGenerator<Integer>().evaluate(IteratorToGeneratorAdapter.adapt(list.iterator()),equalsThree));
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    private List<Integer> list = Arrays.asList(0,1,2,3,4,5,6,7,8,9);
+    private UnaryPredicate<Integer> equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRecursiveEvaluation.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRecursiveEvaluation.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRecursiveEvaluation.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRecursiveEvaluation.java Thu May 31 16:12:39 2012
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.functor.Function;
+import org.apache.commons.functor.core.algorithm.RecursiveEvaluation;
+import org.junit.Test;
+
+/**
+ * Tests {@link RecursiveEvaluation} algorithm.
+ */
+public class TestRecursiveEvaluation {
+
+    @Test
+    public final void testObjectEquals() throws Exception {
+        Object obj = new RecursiveEvaluation(new RecFunc(0, false));
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new RecursiveEvaluation(new RecFunc(0, false));
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testRecurse() {
+        assertEquals(new Integer(5), new RecursiveEvaluation(new RecFunc(0, false)).evaluate());
+
+        // this version will return a function. since it is not the same type
+        // as RecFunc recursion will end.
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        Function<Object> func = (Function) new RecursiveEvaluation(new RecFunc(0, true)).evaluate();
+        assertEquals(new Integer(5), func.evaluate());
+    }
+
+    /** Recursive function for test. */
+    class RecFunc implements Function<Object> {
+        int times = 0; boolean returnFunc = false;
+
+        public RecFunc(int times, boolean returnFunc) {
+            this.times = times;
+            this.returnFunc = returnFunc;
+        }
+
+        public Object evaluate() {
+            if (times < 5) {
+                return new RecFunc(++times, returnFunc);
+            } else {
+                if (returnFunc) {
+                    return new Function<Object>() {
+                        public Object evaluate() {
+                            return new Integer(times);
+                        }
+                    };
+                } else {
+                    return new Integer(times);
+                }
+            }
+        }
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRecursiveEvaluation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRecursiveEvaluation.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRecursiveEvaluation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRemoveMatching.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRemoveMatching.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRemoveMatching.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRemoveMatching.java Thu May 31 16:12:39 2012
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.core.algorithm.RemoveMatching;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link RemoveMatching} algorithm.
+ */
+public class TestRemoveMatching extends BaseFunctorTest {
+
+    // Lifecycle
+    // ------------------------------------------------------------------------
+
+    @Before
+    public void setUp() throws Exception {
+        list = new ArrayList<Integer>();
+        evens = new ArrayList<Integer>();
+        for (int i=0;i<10;i++) {
+            list.add(new Integer(i));
+            if (i%2 == 0) {
+                evens.add(new Integer(i));
+            }
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        list = null;
+        evens = null;
+    }
+
+    // Tests
+    // ------------------------------------------------------------------------
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new RemoveMatching<Integer>();
+    }
+
+    @Test
+    public void testRemove() {
+        new RemoveMatching<Integer>().run(list.iterator(),isOdd);
+        assertEquals(evens,list);
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+    private List<Integer> list = null;
+    private List<Integer> evens = null;
+    private UnaryPredicate<Integer> isOdd = new UnaryPredicate<Integer>() {
+        public boolean test(Integer obj) {
+            return obj % 2 != 0;
+        }
+    };
+
+    // Classes
+    // ------------------------------------------------------------------------
+
+    static class Doubler implements UnaryFunction<Integer, Integer> {
+        public Integer evaluate(Integer obj) {
+            return new Integer(2*obj);
+        }
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRemoveMatching.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRemoveMatching.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRemoveMatching.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRetainMatching.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRetainMatching.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRetainMatching.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRetainMatching.java Thu May 31 16:12:39 2012
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.core.algorithm.RetainMatching;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link RetainMatching} algorithm.
+ */
+public class TestRetainMatching extends BaseFunctorTest {
+
+    // Lifecycle
+    // ------------------------------------------------------------------------
+
+    @Before
+    public void setUp() throws Exception {
+        list = new ArrayList<Integer>();
+        odds = new ArrayList<Integer>();
+        for (int i=0;i<10;i++) {
+            list.add(new Integer(i));
+            if (i%2 != 0) {
+                odds.add(new Integer(i));
+            }
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        list = null;
+        odds = null;
+    }
+
+    // Tests
+    // ------------------------------------------------------------------------
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new RetainMatching<Integer>();
+    }
+
+    @Test
+    public void testRemove() {
+        new RetainMatching<Integer>().run(list.iterator(),isOdd);
+        assertEquals(odds,list);
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+    private List<Integer> list = null;
+    private List<Integer> odds = null;
+    private UnaryPredicate<Integer> isOdd = new UnaryPredicate<Integer>() {
+        public boolean test(Integer obj) {
+            return obj % 2 != 0;
+        }
+    };
+
+    // Classes
+    // ------------------------------------------------------------------------
+
+    static class Doubler implements UnaryFunction<Integer, Integer> {
+        public Integer evaluate(Integer obj) {
+            return new Integer(2*obj);
+        }
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRetainMatching.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRetainMatching.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestRetainMatching.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestUntilDo.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestUntilDo.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestUntilDo.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestUntilDo.java Thu May 31 16:12:39 2012
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.functor.Procedure;
+import org.apache.commons.functor.core.Offset;
+import org.apache.commons.functor.core.algorithm.UntilDo;
+import org.junit.Test;
+
+/**
+ * Tests {@link UntilDo} algorithm.
+ */
+public class TestUntilDo {
+
+    @Test
+    public final void testObjectEquals() throws Exception {
+        Counter counter = new Counter();
+        Object obj = new UntilDo(new Offset(10), counter);
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new UntilDo(new Offset(10), counter);
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testUntilDo() {
+        for (int i=0;i<3;i++){
+            Counter counter = new Counter();
+            new UntilDo(new Offset(i), counter).run();
+            assertEquals(i,counter.count);
+        }
+    }
+
+    // Classes
+    // ------------------------------------------------------------------------
+
+    static class Counter implements Procedure {
+        public void run() {
+            count++;
+        }
+        public int count = 0;
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestUntilDo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestUntilDo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestUntilDo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestWhileDo.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestWhileDo.java?rev=1344796&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestWhileDo.java (added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestWhileDo.java Thu May 31 16:12:39 2012
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.algorithm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.functor.Procedure;
+import org.apache.commons.functor.core.Limit;
+import org.apache.commons.functor.core.Offset;
+import org.apache.commons.functor.core.algorithm.WhileDo;
+import org.junit.Test;
+
+/**
+ * Tests {@link WhileDo} algorithm.
+ */
+public class TestWhileDo {
+
+    @Test
+    public final void testObjectEquals() throws Exception {
+        Counter counter = new Counter();
+        Object obj = new WhileDo(new Offset(10), counter);
+        assertEquals("equals must be reflexive",obj,obj);
+        assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
+        assertTrue(! obj.equals(null) ); // should be able to compare to null
+
+        Object obj2 = new WhileDo(new Offset(10), counter);
+        if (obj.equals(obj2)) {
+            assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
+            assertEquals("equals must be symmetric",obj2,obj);
+        } else {
+            assertTrue("equals must be symmetric",! obj2.equals(obj));
+        }
+    }
+
+    @Test
+    public void testWhileDo() {
+        for (int i=0;i<3;i++){
+            Counter counter = new Counter();
+            new WhileDo(new Limit(i),counter).run();
+            assertEquals(i,counter.count);
+        }
+    }
+
+    // Classes
+    // ------------------------------------------------------------------------
+
+    static class Counter implements Procedure {
+        public void run() {
+            count++;
+        }
+        public int count = 0;
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestWhileDo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestWhileDo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/algorithm/TestWhileDo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message