From ae6c891d80b565b4d41f444b148451e863993a84 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Mon, 11 Mar 2024 18:03:48 +0300 Subject: [PATCH] #2891: cageWithDepth --- .../test/java/EOorg/EOeolang/EOcageTest.java | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java index e44e790f16..1e94ea0709 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java @@ -309,11 +309,7 @@ void throwsExceptionIfRecursion() { @Test void doesNotThrowExceptionIfSmallDepth() { - final EOcage cage = new EOcage(Phi.Φ); - EOcageTest.writeTo( - cage, - new RecursiveDummy(EOcageTest.RecursionTests.MAX_DEPTH / 2, cage) - ); + final EOcage cage = cageWithDepth(MAX_DEPTH / 2); Assertions.assertDoesNotThrow( () -> new Dataized(cage).take(), String.format( @@ -330,11 +326,7 @@ void doesNotThrowExceptionIfSmallDepth() { */ @Test void doesNotThrowExceptionIfMaxDepth() { - final EOcage cage = new EOcage(Phi.Φ); - writeTo( - cage, - new RecursiveDummy(MAX_DEPTH, cage) - ); + final EOcage cage = cageWithDepth(MAX_DEPTH); Assertions.assertDoesNotThrow( () -> new Dataized(cage).take(), String.format( @@ -348,11 +340,7 @@ void doesNotThrowExceptionIfMaxDepth() { @Test void throwsExceptionIfBigDepth() { - final EOcage cage = new EOcage(Phi.Φ); - writeTo( - cage, - new RecursiveDummy(EOcageTest.RecursionTests.MAX_DEPTH + 1, cage) - ); + final EOcage cage = cageWithDepth(MAX_DEPTH + 1); Assertions.assertThrows( ExAbstract.class, () -> new Dataized(cage).take(), @@ -365,6 +353,29 @@ void throwsExceptionIfBigDepth() { ); } + @Test + void doesNotThrowIfDataizesConcurrently() { + final EOcage cage = cageWithDepth(MAX_DEPTH); + Assertions.assertDoesNotThrow( + () -> new Dataized(cage).take(), + String.format( + "We expect that dataizing of nested cage which recursion depth is equal to property %s = %s does not throw %s", + PhTracedEnclosure.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, + System.getProperty(PhTracedEnclosure.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME), + ExAbstract.class + ) + ); + } + + private EOcage cageWithDepth(int depth) { + final EOcage cage = new EOcage(Phi.Φ); + writeTo( + cage, + new RecursiveDummy(MAX_DEPTH, cage) + ); + return cage; + } + /** * Recursive {@link Phi}. * @since 0.1