Skip to content

Commit c76757b

Browse files
committed
Updated tests for Xcode 8 beta 6.
1 parent 6b8a1ec commit c76757b

File tree

8 files changed

+43
-45
lines changed

8 files changed

+43
-45
lines changed

ReactiveCocoaTests/Swift/KeyValueObservingSpec.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class KeyValueObservingSpec: QuickSpec {
169169
}
170170

171171
concurrentQueue.sync(flags: .barrier) {}
172-
expect(observedValue).toEventually(be(2))
172+
expect(observedValue).toEventually(equal(2))
173173
}
174174

175175
it("should handle changes being made on another queue using deliverOn") {
@@ -190,7 +190,7 @@ class KeyValueObservingSpec: QuickSpec {
190190
}
191191

192192
concurrentQueue.sync(flags: .barrier) {}
193-
expect(observedValue).toEventually(be(2))
193+
expect(observedValue).toEventually(equal(2))
194194
}
195195

196196
it("async disposal of target") {
@@ -210,7 +210,7 @@ class KeyValueObservingSpec: QuickSpec {
210210
}
211211

212212
concurrentQueue.sync(flags: .barrier) {}
213-
expect(observedValue).toEventually(be(2))
213+
expect(observedValue).toEventually(equal(2))
214214
}
215215
}
216216

@@ -315,7 +315,7 @@ class KeyValueObservingSpec: QuickSpec {
315315

316316
it("should be able to classify weak references") {
317317
"weakProperty".withCString { cString in
318-
let propertyPointer = class_getProperty(object.dynamicType, cString)
318+
let propertyPointer = class_getProperty(type(of: object), cString)
319319
expect(propertyPointer) != nil
320320

321321
if let pointer = propertyPointer {
@@ -330,7 +330,7 @@ class KeyValueObservingSpec: QuickSpec {
330330

331331
it("should be able to classify blocks") {
332332
"block".withCString { cString in
333-
let propertyPointer = class_getProperty(object.dynamicType, cString)
333+
let propertyPointer = class_getProperty(type(of: object), cString)
334334
expect(propertyPointer) != nil
335335

336336
if let pointer = propertyPointer {
@@ -345,7 +345,7 @@ class KeyValueObservingSpec: QuickSpec {
345345

346346
it("should be able to classify non object properties") {
347347
"integer".withCString { cString in
348-
let propertyPointer = class_getProperty(object.dynamicType, cString)
348+
let propertyPointer = class_getProperty(type(of: object), cString)
349349
expect(propertyPointer) != nil
350350

351351
if let pointer = propertyPointer {

ReactiveCocoaTests/Swift/ObjectiveCBridgingSpec.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class ObjectiveCBridgingSpec: QuickSpec {
105105
expect(lastValue).to(beNil())
106106

107107
for number in [1, 2, 3] {
108-
observer.sendNext(number)
109-
expect(lastValue) == number
108+
observer.sendNext(number as NSNumber)
109+
expect(lastValue) == number as NSNumber
110110
}
111111

112112
expect(didComplete) == false
@@ -119,15 +119,15 @@ class ObjectiveCBridgingSpec: QuickSpec {
119119
let racSignal = signal.toRACSignal()
120120

121121
let expectedError = TestError.error2
122-
var error: Error?
122+
var error: TestError?
123123

124124
racSignal.subscribeError {
125-
error = $0
125+
error = $0 as? TestError
126126
return
127127
}
128128

129129
observer.sendFailed(expectedError)
130-
expect(error) == expectedError as NSError
130+
expect(error) == expectedError
131131
}
132132

133133
it("should maintain userInfo on NSError") {
@@ -156,7 +156,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
156156
subscriptions += 1
157157
}
158158

159-
return .success(subscriptions)
159+
return .success(subscriptions as NSNumber)
160160
}
161161
let racSignal = producer.toRACSignal()
162162

@@ -170,7 +170,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
170170
let racSignal = producer.toRACSignal().materialize()
171171

172172
let event = racSignal.first() as? RACEvent
173-
expect(event?.error) == TestError.error1 as NSError
173+
expect(event?.error as? NSError) == TestError.error1 as NSError
174174
}
175175

176176
it("should maintain userInfo on NSError") {
@@ -191,7 +191,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
191191
var enabledSubject: RACSubject!
192192
var enabled = false
193193

194-
var action: Action<AnyObject?, AnyObject?, NSError>!
194+
var action: Action<Any?, Any?, NSError>!
195195

196196
beforeEach {
197197
enabledSubject = RACSubject()
@@ -222,7 +222,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
222222
}
223223

224224
it("should execute the command once per start()") {
225-
let producer = action.apply(0)
225+
let producer = action.apply(0 as NSNumber)
226226
expect(results) == []
227227

228228
producer.start()
@@ -231,7 +231,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
231231
producer.start()
232232
expect(results).toEventually(equal([ 1, 1 ]))
233233

234-
let otherProducer = action.apply(2)
234+
let otherProducer = action.apply(2 as NSNumber)
235235
expect(results) == [ 1, 1 ]
236236

237237
otherProducer.start()
@@ -257,7 +257,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
257257

258258
action = Action(enabledIf: enabledProperty) { input in
259259
let inputNumber = input as! Int
260-
return SignalProducer(value: "\(inputNumber + 1)")
260+
return SignalProducer(value: "\(inputNumber + 1)" as NSString)
261261
}
262262

263263
expect(action.isEnabled.value) == true
@@ -280,7 +280,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
280280
}
281281

282282
it("should apply and start a signal once per execution") {
283-
let signal = command.execute(0)
283+
let signal = command.execute(0 as NSNumber)
284284

285285
do {
286286
try signal.asynchronouslyWaitUntilCompleted()
@@ -289,7 +289,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
289289
try signal.asynchronouslyWaitUntilCompleted()
290290
expect(results) == [ "1" ]
291291

292-
try command.execute(2).asynchronouslyWaitUntilCompleted()
292+
try command.execute(2 as NSNumber).asynchronouslyWaitUntilCompleted()
293293
expect(results) == [ "1", "3" ]
294294
} catch {
295295
XCTFail("Failed to wait for completion")

ReactiveCocoaTests/Swift/PropertySpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ class PropertySpec: QuickSpec {
13941394
var property: DynamicProperty<Int>!
13951395

13961396
let propertyValue: () -> Int? = {
1397-
if let value: AnyObject = property?.value {
1397+
if let value: Any = property?.value {
13981398
return value as? Int
13991399
} else {
14001400
return nil

ReactiveCocoaTests/Swift/SchedulerSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SchedulerSpec: QuickSpec {
2626
}
2727

2828
describe("UIScheduler") {
29-
func dispatchSyncInBackground(_ action: () -> Void) {
29+
func dispatchSyncInBackground(_ action: @escaping () -> Void) {
3030
let group = DispatchGroup()
3131

3232
let globalQueue: DispatchQueue

ReactiveCocoaTests/Swift/SignalProducerLiftingSpec.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,16 +516,16 @@ class SignalProducerLiftingSpec: QuickSpec {
516516

517517
if i % 3 == 0 {
518518
expectation.append([Int]((i - 2)...i))
519-
expect(observedValues) == expectation
519+
expect(observedValues as NSArray) == expectation as NSArray
520520
} else {
521-
expect(observedValues) == expectation
521+
expect(observedValues as NSArray) == expectation as NSArray
522522
}
523523
}
524524

525525
observer.sendCompleted()
526526

527527
expectation.append([7])
528-
expect(observedValues) == expectation
528+
expect(observedValues as NSArray) == expectation as NSArray
529529
}
530530

531531
it("should collect values until it matches a certain value") {
@@ -543,7 +543,7 @@ class SignalProducerLiftingSpec: QuickSpec {
543543
}
544544

545545
producer.startWithCompleted {
546-
expect(expectedValues) == []
546+
expect(expectedValues as NSArray) == [] as NSArray
547547
}
548548

549549
expectedValues
@@ -568,7 +568,7 @@ class SignalProducerLiftingSpec: QuickSpec {
568568
}
569569

570570
producer.startWithCompleted {
571-
expect(expectedValues) == []
571+
expect(expectedValues as NSArray) == [] as NSArray
572572
}
573573

574574
expectedValues
@@ -1077,7 +1077,7 @@ class SignalProducerLiftingSpec: QuickSpec {
10771077
class Payload {
10781078
let action: () -> Void
10791079

1080-
init(onDeinit action: () -> Void) {
1080+
init(onDeinit action: @escaping () -> Void) {
10811081
self.action = action
10821082
}
10831083

ReactiveCocoaTests/Swift/SignalProducerSpec.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ class SignalProducerSpec: QuickSpec {
698698
observerA.sendCompleted()
699699
observerB.sendCompleted()
700700

701-
expect(values) == [[1, 2], [3, 2]]
701+
expect(values as NSArray) == [[1, 2], [3, 2]]
702702
}
703703

704704
it("should start signal producers in order as defined") {
@@ -723,7 +723,7 @@ class SignalProducerSpec: QuickSpec {
723723
}
724724

725725
expect(ids) == [1, 2]
726-
expect(values) == [[1, 2]]
726+
expect(values as NSArray) == [[1, 2]] as NSArray
727727
}
728728
}
729729

@@ -735,7 +735,7 @@ class SignalProducerSpec: QuickSpec {
735735
let producer = SignalProducer.zip([producerA, producerB])
736736
let result = producer.collect().single()
737737

738-
expect(result?.value) == [[1, 3], [2, 4]]
738+
expect(result?.value.map { $0 as NSArray }) == [[1, 3], [2, 4]] as NSArray
739739
}
740740

741741
it("should start signal producers in order as defined") {
@@ -760,7 +760,7 @@ class SignalProducerSpec: QuickSpec {
760760
}
761761

762762
expect(ids) == [1, 2]
763-
expect(values) == [[1, 2]]
763+
expect(values as NSArray) == [[1, 2]] as NSArray
764764
}
765765
}
766766

@@ -774,7 +774,7 @@ class SignalProducerSpec: QuickSpec {
774774
let tick2 = startDate.addingTimeInterval(2)
775775
let tick3 = startDate.addingTimeInterval(3)
776776

777-
var dates: [NSDate] = []
777+
var dates: [Date] = []
778778
producer.startWithNext { dates.append($0) }
779779

780780
scheduler.advance(by: 0.9)
@@ -926,7 +926,7 @@ class SignalProducerSpec: QuickSpec {
926926

927927
let producer = timer(interval: 2, on: testScheduler, leeway: 0)
928928

929-
var next: NSDate?
929+
var next: Date?
930930
producer.start(on: startScheduler).startWithNext { next = $0 }
931931

932932
startScheduler.advance(by: 2)
@@ -1700,7 +1700,7 @@ class SignalProducerSpec: QuickSpec {
17001700
expect(result).to(beNil())
17011701

17021702
observer.sendNext(1)
1703-
expect(result).toEventually(be(1), timeout: 5.0)
1703+
expect(result).toEventually(equal(1), timeout: 5.0)
17041704
}
17051705

17061706
it("should return a nil result if no values are sent before completion") {
@@ -1753,7 +1753,7 @@ class SignalProducerSpec: QuickSpec {
17531753
expect(result).to(beNil())
17541754

17551755
observer.sendCompleted()
1756-
expect(result).toEventually(be(1))
1756+
expect(result).toEventually(equal(1))
17571757
}
17581758

17591759
it("should return a nil result if no values are sent before completion") {
@@ -2151,7 +2151,7 @@ class SignalProducerSpec: QuickSpec {
21512151
final class Value {
21522152
private let deinitBlock: () -> Void
21532153

2154-
init(deinitBlock: () -> Void) {
2154+
init(deinitBlock: @escaping () -> Void) {
21552155
self.deinitBlock = deinitBlock
21562156
}
21572157

@@ -2232,7 +2232,7 @@ extension SignalProducer {
22322232

22332233
/// Creates a producer that can be started as many times as elements in `results`.
22342234
/// Each signal will immediately send either a value or an error.
2235-
private static func attemptWithResults<C: Collection where C.Iterator.Element == Result<Value, Error>, C.IndexDistance == C.Index, C.Index == Int>(_ results: C) -> SignalProducer<Value, Error> {
2235+
fileprivate static func attemptWithResults<C: Collection>(_ results: C) -> SignalProducer<Value, Error> where C.Iterator.Element == Result<Value, Error>, C.IndexDistance == C.Index, C.Index == Int {
22362236
let resultCount = results.count
22372237
var operationIndex = 0
22382238

ReactiveCocoaTests/Swift/SignalSpec.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -893,21 +893,20 @@ class SignalSpec: QuickSpec {
893893
var expectation: [[Int]] = []
894894

895895
for i in 1...7 {
896-
897896
observer.sendNext(i)
898897

899898
if i % 3 == 0 {
900899
expectation.append([Int]((i - 2)...i))
901-
expect(observedValues) == expectation
900+
expect(observedValues as NSArray) == expectation as NSArray
902901
} else {
903-
expect(observedValues) == expectation
902+
expect(observedValues as NSArray) == expectation as NSArray
904903
}
905904
}
906905

907906
observer.sendCompleted()
908907

909908
expectation.append([7])
910-
expect(observedValues) == expectation
909+
expect(observedValues as NSArray) == expectation as NSArray
911910
}
912911

913912
it("should collect values until it matches a certain value") {
@@ -925,7 +924,7 @@ class SignalSpec: QuickSpec {
925924
}
926925

927926
signal.observeCompleted {
928-
expect(expectedValues) == []
927+
expect(expectedValues as NSArray) == []
929928
}
930929

931930
expectedValues
@@ -950,7 +949,7 @@ class SignalSpec: QuickSpec {
950949
}
951950

952951
signal.observeCompleted {
953-
expect(expectedValues) == []
952+
expect(expectedValues as NSArray) == []
954953
}
955954

956955
expectedValues

ReactiveCocoaTests/Swift/TestLogger.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import Foundation
1010
@testable import ReactiveCocoa
1111

1212
final class TestLogger {
13-
private var expectations: [(String) -> Void]
13+
fileprivate var expectations: [(String) -> Void]
1414

1515
init(expectations: [(String) -> Void]) {
1616
self.expectations = expectations
1717
}
1818
}
1919

2020
extension TestLogger {
21-
2221
func logEvent(_ identifier: String, event: String, fileName: String, functionName: String, lineNumber: Int) {
2322
expectations.removeFirst()("[\(identifier)] \(event)")
2423
}

0 commit comments

Comments
 (0)