Skip to content

Commit

Permalink
objectionary#2891: cageWithDepth
Browse files Browse the repository at this point in the history
  • Loading branch information
levBagryansky committed Mar 11, 2024
1 parent 86466bb commit ae6c891
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(),
Expand All @@ -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
Expand Down

0 comments on commit ae6c891

Please sign in to comment.