Skip to content

Commit 11b10ee

Browse files
committed
Merge pull request #48 from ReactKit/remove-plusplus
Replace `x++` to `x += 1` (for Swift 2.2)
2 parents 5030b07 + b836aca commit 11b10ee

File tree

6 files changed

+38
-38
lines changed

6 files changed

+38
-38
lines changed

Sources/StateMachine.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public final class StateMachine<S: StateType, E: EventType>: Machine<S, E>
413413

414414
if _canPassCondition(route.condition, forEvent: nil, fromState: context.fromState, toState: context.toState, userInfo: context.userInfo) {
415415
if !shouldStop {
416-
chainingCount++
416+
chainingCount += 1
417417

418418
shouldIncrementChainingCount = false
419419
}
@@ -428,7 +428,7 @@ public final class StateMachine<S: StateType, E: EventType>: Machine<S, E>
428428
shouldIncrementChainingCount = true
429429

430430
if !shouldStop {
431-
allCount++
431+
allCount += 1
432432
}
433433

434434
if chainingCount < allCount {

Tests/MachineTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class MachineTests: _TestCase
229229
.State0 => .State1,
230230
.State1 => .State2,
231231
], handler: { context in
232-
invokeCount++
232+
invokeCount += 1
233233
return
234234
})
235235
}
@@ -258,7 +258,7 @@ class MachineTests: _TestCase
258258
])
259259

260260
machine.addHandler(event: .Event0) { context in
261-
invokeCount++
261+
invokeCount += 1
262262
return
263263
}
264264

@@ -285,7 +285,7 @@ class MachineTests: _TestCase
285285
.State0 => .State1,
286286
.State1 => .State2,
287287
], handler: { context in
288-
invokeCount++
288+
invokeCount += 1
289289
return
290290
})
291291

@@ -318,7 +318,7 @@ class MachineTests: _TestCase
318318
])
319319

320320
machine.addHandler(event: .Event0) { context in
321-
invokeCount++
321+
invokeCount += 1
322322
return
323323
}
324324

@@ -342,7 +342,7 @@ class MachineTests: _TestCase
342342
let machine = Machine<MyState, MyEvent>(state: .State0) { machine in
343343
machine.addRoutes(event: .Event0, transitions: [ .State0 => .State1 ])
344344
machine.addErrorHandler { event, fromState, toState, userInfo in
345-
invokeCount++
345+
invokeCount += 1
346346
}
347347
}
348348

@@ -368,7 +368,7 @@ class MachineTests: _TestCase
368368
])
369369

370370
let handlerDisposable = machine.addHandler(event: .Event0) { context in
371-
invokeCount++
371+
invokeCount += 1
372372
return
373373
}
374374

@@ -415,7 +415,7 @@ class MachineTests: _TestCase
415415
}
416416

417417
machine.addHandler(event: .Str("gogogo")) { context in
418-
invokeCount++
418+
invokeCount += 1
419419
return
420420
}
421421

@@ -475,7 +475,7 @@ class MachineTests: _TestCase
475475
return nil
476476
}
477477
}, handler: { context in
478-
invokeCount1++
478+
invokeCount1 += 1
479479
})
480480

481481
disposables += [d]
@@ -491,7 +491,7 @@ class MachineTests: _TestCase
491491
return nil
492492
}
493493
}, handler: { context in
494-
invokeCount2++
494+
invokeCount2 += 1
495495
})
496496

497497
disposables += [d2]

Tests/RouteChainTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MachineChainTests: _TestCase
1919

2020
// add 0 => 1 => 2
2121
machine.addRouteChain(.State0 => .State1 => .State2) { context in
22-
invokeCount++
22+
invokeCount += 1
2323
return
2424
}
2525

@@ -53,7 +53,7 @@ class MachineChainTests: _TestCase
5353

5454
// add 0 => 1 => 2
5555
machine.addRouteChain(.State0 => .State1 => .State2, condition: { _ in flag }) { context in
56-
invokeCount++
56+
invokeCount += 1
5757
return
5858
}
5959

@@ -121,7 +121,7 @@ class MachineChainTests: _TestCase
121121

122122
// add 0 => 1 => 2
123123
machine.addRouteChain(.State0 => .State1 => .State2) { context in
124-
invokeCount++
124+
invokeCount += 1
125125
return
126126
}
127127
// machine.addRoute(.State1 => .State3) // comment-out: 1 => 3 is not possible
@@ -144,7 +144,7 @@ class MachineChainTests: _TestCase
144144

145145
// add 0 => 1 => 2 => 0 (back home) => 2
146146
machine.addRouteChain(.State0 => .State1 => .State2 => .State0 => .State2) { context in
147-
invokeCount++
147+
invokeCount += 1
148148
return
149149
}
150150

@@ -170,7 +170,7 @@ class MachineChainTests: _TestCase
170170

171171
// add 0 => 1 => 2 => 0 (back home) => 1 => 2
172172
machine.addRouteChain(.State0 => .State1 => .State2 => .State0 => .State1 => .State2) { context in
173-
invokeCount++
173+
invokeCount += 1
174174
return
175175
}
176176

@@ -207,7 +207,7 @@ class MachineChainTests: _TestCase
207207

208208
// add 0 => 1 => 2
209209
let chainDisposable = machine.addRouteChain(.State0 => .State1 => .State2) { context in
210-
invokeCount++
210+
invokeCount += 1
211211
return
212212
}
213213

@@ -243,7 +243,7 @@ class MachineChainTests: _TestCase
243243

244244
// add 0 => 1 => 2 chainErrorHandler
245245
machine.addChainErrorHandler(transitionChain) { context in
246-
errorCount++
246+
errorCount += 1
247247
return
248248
}
249249

@@ -272,7 +272,7 @@ class MachineChainTests: _TestCase
272272

273273
// add 0 => 1 => 2 chainErrorHandler
274274
let chainErrorHandlerDisposable = machine.addChainErrorHandler(transitionChain) { context in
275-
errorCount++
275+
errorCount += 1
276276
return
277277
}
278278

Tests/RouteMappingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class RouteMappingTests: _TestCase
9999

100100
// increment `count` when any events i.e. `.CancelAction` and `.LoadAction(x)` succeed.
101101
machine.addHandler(event: .Any) { event, transition, order, userInfo in
102-
count++
102+
count += 1
103103
}
104104

105105
}
@@ -154,7 +154,7 @@ class RouteMappingTests: _TestCase
154154

155155
// increment `count` when any events i.e. `.CancelAction` and `.LoadAction(x)` succeed.
156156
machine.addHandler(.Any => .Any) { event, transition, order, userInfo in
157-
count++
157+
count += 1
158158
}
159159

160160
}

Tests/StateMachineEventTests.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class StateMachineEventTests: _TestCase
9595
let machine = StateMachine<MyState, MyEvent>(state: .State0) { machine in
9696
machine.addRoute(.State0 => .State1)
9797
machine.addRoutes(event: .Event0, transitions: [.Any => .Any]) { _ in
98-
eventCount++
98+
eventCount += 1
9999
}
100100
}
101101

@@ -260,7 +260,7 @@ class StateMachineEventTests: _TestCase
260260
.State0 => .State1,
261261
.State1 => .State2,
262262
], handler: { context in
263-
invokeCount++
263+
invokeCount += 1
264264
return
265265
})
266266
}
@@ -289,7 +289,7 @@ class StateMachineEventTests: _TestCase
289289
])
290290

291291
machine.addHandler(event: .Event0) { context in
292-
invokeCount++
292+
invokeCount += 1
293293
return
294294
}
295295

@@ -325,7 +325,7 @@ class StateMachineEventTests: _TestCase
325325
])
326326

327327
machine.addHandler(event: .Event0) { context in
328-
invokeCount++
328+
invokeCount += 1
329329
return
330330
}
331331

@@ -355,7 +355,7 @@ class StateMachineEventTests: _TestCase
355355
])
356356

357357
let handlerDisposable = machine.addHandler(event: .Event0) { context in
358-
invokeCount++
358+
invokeCount += 1
359359
return
360360
}
361361

@@ -399,27 +399,27 @@ class StateMachineEventTests: _TestCase
399399
//
400400

401401
machine.addAnyHandler(.State0 => .State1) { context in
402-
invokeCounts[0]++
402+
invokeCounts[0] += 1
403403
}
404404

405405
machine.addAnyHandler(.State1 => .State2) { context in
406-
invokeCounts[1]++
406+
invokeCounts[1] += 1
407407
}
408408

409409
machine.addAnyHandler(.State2 => .State3) { context in
410-
invokeCounts[2]++
410+
invokeCounts[2] += 1
411411
}
412412

413413
machine.addAnyHandler(.Any => .State3) { context in
414-
invokeCounts[3]++
414+
invokeCounts[3] += 1
415415
}
416416

417417
machine.addAnyHandler(.State0 => .Any) { context in
418-
invokeCounts[4]++
418+
invokeCounts[4] += 1
419419
}
420420

421421
machine.addAnyHandler(.Any => .Any) { context in
422-
invokeCounts[5]++
422+
invokeCounts[5] += 1
423423
}
424424

425425
}

Tests/StateMachineTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class StateMachineTests: _TestCase
176176
XCTAssertEqual(context.fromState, MyState.State0)
177177
XCTAssertEqual(context.toState, MyState.State1)
178178

179-
invokedCount++
179+
invokedCount += 1
180180
}
181181

182182
}
@@ -205,7 +205,7 @@ class StateMachineTests: _TestCase
205205
XCTAssertEqual(context.fromState, MyState.State0)
206206
XCTAssertEqual(context.toState, MyState.State1)
207207

208-
invokedCount++
208+
invokedCount += 1
209209
}
210210

211211
// add 1 => 0 for resetting state
@@ -340,7 +340,7 @@ class StateMachineTests: _TestCase
340340
XCTAssertEqual(context.fromState, MyState.State0)
341341
XCTAssertEqual(context.toState, MyState.State1)
342342

343-
invokedCount++
343+
invokedCount += 1
344344
}
345345

346346
}
@@ -370,7 +370,7 @@ class StateMachineTests: _TestCase
370370
XCTAssertEqual(context.fromState, MyState.State0)
371371
XCTAssertEqual(context.toState, MyState.State1)
372372

373-
invokedCount++
373+
invokedCount += 1
374374
}
375375

376376
// order = 99
@@ -380,7 +380,7 @@ class StateMachineTests: _TestCase
380380
XCTAssertEqual(context.fromState, MyState.State0)
381381
XCTAssertEqual(context.toState, MyState.State1)
382382

383-
invokedCount++
383+
invokedCount += 1
384384
}
385385

386386
}
@@ -700,7 +700,7 @@ class StateMachineTests: _TestCase
700700
}
701701

702702
}, handler: { context in
703-
invokedCount++
703+
invokedCount += 1
704704
})
705705

706706
}

0 commit comments

Comments
 (0)