Skip to content

Commit cd05d71

Browse files
committed
Improve #16.
1 parent fefc4d9 commit cd05d71

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

SwiftStateTests/StateMachineChainTests.swift

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

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

SwiftStateTests/StateMachineTests.swift

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

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

110108
XCTAssertFalse(machine.hasRoute(.State0 => .State1))
111109

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

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

SwiftStateTests/StateRouteTests.swift

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

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)
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)
2733

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

0 commit comments

Comments
 (0)