|
259 | 259 | store.scope(state: self.toLocalState, action: TestAction.send) |
260 | 260 | ) |
261 | 261 |
|
262 | | - for step in steps { |
| 262 | + func assert(step: Step) { |
263 | 263 | var expectedState = toLocalState(snapshotState) |
264 | 264 |
|
265 | 265 | func expectedStateShouldMatch(actualState: LocalState) { |
|
383 | 383 | } catch { |
384 | 384 | _XCTFail("Threw error: \(error)", file: step.file, line: step.line) |
385 | 385 | } |
| 386 | + |
| 387 | + case let .sequence(subSteps): |
| 388 | + subSteps.forEach(assert(step:)) |
386 | 389 | } |
387 | 390 | } |
388 | 391 |
|
| 392 | + steps.forEach(assert(step:)) |
| 393 | + |
389 | 394 | if !receivedActions.isEmpty { |
390 | 395 | _XCTFail( |
391 | 396 | """ |
|
542 | 547 | Step(.do(work), file: file, line: line) |
543 | 548 | } |
544 | 549 |
|
545 | | - fileprivate enum StepType { |
| 550 | + /// A step that captures a sub-sequence of steps. |
| 551 | + /// |
| 552 | + /// - Parameter steps: An array of `Step` |
| 553 | + /// - Returns: A step that captures a sub-sequence of steps. |
| 554 | + public static func sequence( |
| 555 | + _ steps: [Step], |
| 556 | + file: StaticString = #file, |
| 557 | + line: UInt = #line |
| 558 | + ) -> Step { |
| 559 | + Step(.sequence(steps), file: file, line: line) |
| 560 | + } |
| 561 | + |
| 562 | + /// A step that captures a sub-sequence of steps. |
| 563 | + /// |
| 564 | + /// - Parameter steps: A variadic list of `Step` |
| 565 | + /// - Returns: A step that captures a sub-sequence of steps. |
| 566 | + public static func sequence( |
| 567 | + _ steps: Step..., |
| 568 | + file: StaticString = #file, |
| 569 | + line: UInt = #line |
| 570 | + ) -> Step { |
| 571 | + Step(.sequence(steps), file: file, line: line) |
| 572 | + } |
| 573 | + |
| 574 | + fileprivate indirect enum StepType { |
546 | 575 | case send(LocalAction, (inout LocalState) throws -> Void) |
547 | 576 | case receive(Action, (inout LocalState) throws -> Void) |
548 | 577 | case environment((inout Environment) throws -> Void) |
549 | 578 | case `do`(() throws -> Void) |
| 579 | + case sequence([Step]) |
550 | 580 | } |
551 | 581 | } |
552 | 582 |
|
|
0 commit comments