@@ -261,6 +261,42 @@ struct AlignmentTests {
261261 #expect( bounds? . maximum. y ≈ 0 )
262262 }
263263
264+ // MARK: - whileAligned
265+
266+ @Test func `2D while Aligned matches rotated around center`() async throws {
267+ let geometry = Rectangle ( x: 10 , y: 6 )
268+ . translated ( x: 20 , y: 10 )
269+ let viaWhileAligned = geometry
270+ . whileAligned ( at: . center) { $0. rotated ( 90 ° ) }
271+ let viaPivot = geometry. rotated ( 90 ° , around: . center)
272+
273+ let whileBounds = try await viaWhileAligned. bounds
274+ let pivotBounds = try await viaPivot. bounds
275+
276+ #expect( whileBounds? . minimum. x ≈ pivotBounds? . minimum. x)
277+ #expect( whileBounds? . maximum. x ≈ pivotBounds? . maximum. x)
278+ #expect( whileBounds? . minimum. y ≈ pivotBounds? . minimum. y)
279+ #expect( whileBounds? . maximum. y ≈ pivotBounds? . maximum. y)
280+ }
281+
282+ @Test func `3D while Aligned matches rotated around center`() async throws {
283+ let geometry = Box ( x: 10 , y: 6 , z: 4 )
284+ . translated ( x: 20 , y: 10 , z: 5 )
285+ let viaWhileAligned = geometry
286+ . whileAligned ( at: . center) { $0. rotated ( y: 90 ° ) }
287+ let viaPivot = geometry. rotated ( y: 90 ° , around: . center)
288+
289+ let whileBounds = try await viaWhileAligned. bounds
290+ let pivotBounds = try await viaPivot. bounds
291+
292+ #expect( whileBounds? . minimum. x ≈ pivotBounds? . minimum. x)
293+ #expect( whileBounds? . maximum. x ≈ pivotBounds? . maximum. x)
294+ #expect( whileBounds? . minimum. y ≈ pivotBounds? . minimum. y)
295+ #expect( whileBounds? . maximum. y ≈ pivotBounds? . maximum. y)
296+ #expect( whileBounds? . minimum. z ≈ pivotBounds? . minimum. z)
297+ #expect( whileBounds? . maximum. z ≈ pivotBounds? . maximum. z)
298+ }
299+
264300 // MARK: - Edge Cases
265301
266302 @Test func `align none leaves geometry unchanged `() async throws {
0 commit comments