Recursion detection fixed for memoized functions

This commit is contained in:
Andrey Breslav
2013-12-30 19:29:06 +04:00
parent 968e380321
commit 161998d2b8
2 changed files with 27 additions and 4 deletions
@@ -130,6 +130,27 @@ public class StorageManagerTest extends TestCase {
doTestExceptionPreserved(apply(f, ""), UnsupportedOperationException.class, counter);
}
public void testRecursionDetection() throws Exception {
class C {
MemoizedFunctionToNotNull<String, String> rec = m.createMemoizedFunction(
new Function1<String, String>() {
@Override
public String invoke(String s) {
return rec.invoke("!!!");
}
}
);
}
try {
new C().rec.invoke("");
fail();
}
catch (AssertionError e) {
assertEquals("Recursion detected on input: !!!", e.getMessage());
}
}
// Values
public void testNotNullLazyComputedOnce() throws Exception {