Increase testNodeJs timeout to 30s

Tweak shape-contour intersection test
This commit is contained in:
Abe Pazos
2025-07-17 13:38:12 +02:00
parent 660cac3445
commit f2ea6a89a1
2 changed files with 27 additions and 16 deletions

View File

@@ -76,7 +76,13 @@ kotlin {
js(IR) { js(IR) {
browser() browser()
nodejs() nodejs {
testTask {
useMocha {
timeout = "30s"
}
}
}
} }
sourceSets { sourceSets {

View File

@@ -45,7 +45,13 @@ class TestComposition {
} }
class TestCompositionIntersections { class TestCompositionIntersections {
@Test
fun `use a shape as a mask for line segments`() {
// Make sure intersections do not fail randomly, which was fixed in
// https://github.com/openrndr/orx/commit/e8f50b3dd153ed82de121e9017cf42f6ea95ac8e
val bounds = Rectangle(Vector2.ZERO, 640.0, 480.0) val bounds = Rectangle(Vector2.ZERO, 640.0, 480.0)
// Create a 2D torus
val outline = Shape( val outline = Shape(
listOf( listOf(
Circle(bounds.center, 70.0).contour.reversed, Circle(bounds.center, 70.0).contour.reversed,
@@ -55,13 +61,12 @@ class TestCompositionIntersections {
val radius = outline.bounds.dimensions.length / 2 val radius = outline.bounds.dimensions.length / 2
val off = outline.bounds.center val off = outline.bounds.center
val num = radius.toInt()
@Test val compositions = List(100) {
fun `use a shape as a mask for line segments`() { // Create compositions featuring horizontal lines
// Make sure intersections do not fail randomly, which was fixed in // visible inside the torus shape. Change the number of
// https://github.com/openrndr/orx/commit/e8f50b3dd153ed82de121e9017cf42f6ea95ac8e // lines to make sure the calculations are not cached.
val svg = List(50) { val num = radius.toInt() + it
drawComposition { drawComposition {
lineSegments(List(num) { segNum -> lineSegments(List(num) { segNum ->
val yNorm = (segNum / (num - 1.0)) val yNorm = (segNum / (num - 1.0))
@@ -76,8 +81,8 @@ class TestCompositionIntersections {
} }
} }
val shapes = svg.last().findShapes() val shapes = compositions.last().findShapes()
val dimensions = svg.last().bounds.dimensions val dimensions = compositions.last().bounds.dimensions
assertTrue(shapes.isNotEmpty(), "shapes should not be empty") assertTrue(shapes.isNotEmpty(), "shapes should not be empty")
assertTrue(shapes.first().shape.contours.isNotEmpty(), "contour should not be empty") assertTrue(shapes.first().shape.contours.isNotEmpty(), "contour should not be empty")