Skip to content

Commit 703d456

Browse files
committed
Revert "Improve #16."
This reverts commit cd05d71.
1 parent cd05d71 commit 703d456

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

SwiftStateTests/StateMachineChainTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ class StateMachineChainTests: _TestCase
5050
var invokeCount = 0
5151

5252
// add 0 => 1 => 2
53-
machine.addRouteChain(.State0 => .State1 => .State2, condition: { _ in flag }) { (context) -> Void in
53+
machine.addRouteChain(.State0 => .State1 => .State2, condition: { _ -> Bool in
54+
return flag
55+
}) { (context) -> Void in
5456
invokeCount++
5557
return
5658
}

SwiftStateTests/StateMachineTests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ class StateMachineTests: _TestCase
103103
var flag = false
104104

105105
// add 0 => 1
106-
machine.addRoute(.State0 => .State1, condition: { _ in flag })
106+
machine.addRoute(.State0 => .State1, condition: { _ -> Bool in
107+
return flag
108+
})
107109

108110
XCTAssertFalse(machine.hasRoute(.State0 => .State1))
109111

@@ -161,7 +163,9 @@ class StateMachineTests: _TestCase
161163
machine.addRoute(.State0 => .State1)
162164

163165
// add 0 => 1 with condition + conditionalHandler
164-
machine.addRoute(.State0 => .State1, condition: { _ in flag }) { context in
166+
machine.addRoute(.State0 => .State1, condition: { _ -> Bool in
167+
return flag
168+
}) { context in
165169
returnedTransition = context.transition
166170
}
167171

SwiftStateTests/StateRouteTests.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,12 @@ class StateRouteTests: _TestCase
1818
XCTAssertEqual(route.transition.toState, MyState.State1)
1919
XCTAssertTrue(route.condition == nil)
2020

21-
//
22-
// comment-out:
23-
// `condition` using lazy-evaluated-@autoclosure is removed due to Swift 1.2 change
24-
//
25-
// From Release Note:
26-
// > The @autoclosure attribute on parameters now implies the new @noescape attribute.
27-
// > This intentionally limits the power of @autoclosure to control-flow and lazy evaluation use cases.
28-
//
29-
// let route2 = StateRoute<MyState>(transition: .State1 => .State2, condition: false)
30-
// XCTAssertEqual(route2.transition.fromState, MyState.State1)
31-
// XCTAssertEqual(route2.transition.toState, MyState.State2)
32-
// XCTAssertTrue(route2.condition != nil)
21+
let route2 = StateRoute<MyState>(transition: .State1 => .State2, condition: { _ -> Bool in
22+
return false
23+
})
24+
XCTAssertEqual(route2.transition.fromState, MyState.State1)
25+
XCTAssertEqual(route2.transition.toState, MyState.State2)
26+
XCTAssertTrue(route2.condition != nil)
3327

3428
let route3 = StateRoute<MyState>(transition: .State2 => .State3, condition: { transition in false })
3529
XCTAssertEqual(route3.transition.fromState, MyState.State2)

0 commit comments

Comments
 (0)