@@ -3,14 +3,14 @@ import XCTest
3
3
4
4
final class OutputTests : XCTestCase {
5
5
func testInitialNoValue( ) {
6
- let output = Output < String > ( )
6
+ let output = MutableOutput < String > ( )
7
7
output. bind { _ in
8
8
XCTFail ( " should not be called as Output has no value set " )
9
9
}
10
10
}
11
11
12
12
func testInitialValue( ) {
13
- let output = Output < String > ( value: " Test " )
13
+ let output = MutableOutput < String > ( value: " Test " )
14
14
var closureCalled : Bool = false
15
15
output. debug ( identifier: " 123 " ) . bind { value in
16
16
XCTAssertEqual ( " Test " , value)
@@ -22,7 +22,7 @@ final class OutputTests: XCTestCase {
22
22
func testBinderIsCalled( ) {
23
23
let testObject = BindableMock ( )
24
24
25
- let output = Output < String > ( )
25
+ let output = MutableOutput < String > ( )
26
26
output. bind ( to: testObject. binding. text)
27
27
28
28
XCTAssertNil ( testObject. text)
@@ -36,7 +36,7 @@ final class OutputTests: XCTestCase {
36
36
let testObjectOne = BindableMock ( )
37
37
let testObjectTwo = BindableMock ( )
38
38
39
- let output = Output < String > ( )
39
+ let output = MutableOutput < String > ( )
40
40
output. bind ( to: [ testObjectOne. binding. text,
41
41
testObjectTwo. binding. text] )
42
42
@@ -52,7 +52,7 @@ final class OutputTests: XCTestCase {
52
52
func testUnbind( ) {
53
53
let testObject = BindableMock ( )
54
54
55
- let output = Output < String > ( )
55
+ let output = MutableOutput < String > ( )
56
56
let subscription = output. bind ( to: testObject. binding. text)
57
57
58
58
XCTAssertNil ( testObject. text)
@@ -69,13 +69,13 @@ final class OutputTests: XCTestCase {
69
69
}
70
70
71
71
func testCombine( ) {
72
- let output1 = Output < Bool > ( )
73
- let output2 = Output < Bool > ( )
72
+ let output1 = MutableOutput < Bool > ( )
73
+ let output2 = MutableOutput < Bool > ( )
74
74
75
75
var outputValue1 : Bool ?
76
76
var outputValue2 : Bool ?
77
77
78
- Output < Bool > . combine ( output1, output2) . bind { value1, value2 in
78
+ MutableOutput < Bool > . combine ( output1, output2) . bind { value1, value2 in
79
79
outputValue1 = value1
80
80
outputValue2 = value2
81
81
}
@@ -100,15 +100,15 @@ final class OutputTests: XCTestCase {
100
100
}
101
101
102
102
func testCombineArray( ) {
103
- let output1 = Output < Bool > ( )
104
- let output2 = Output < Bool > ( )
105
- let output3 = Output < Bool > ( )
103
+ let output1 = MutableOutput < Bool > ( )
104
+ let output2 = MutableOutput < Bool > ( )
105
+ let output3 = MutableOutput < Bool > ( )
106
106
107
107
var outputValue1 : Bool ?
108
108
var outputValue2 : Bool ?
109
109
var outputValue3 : Bool ?
110
110
111
- Output < Bool > . combine ( outputs: [ output1, output2, output3] ) . bind { valuesArray in
111
+ MutableOutput < Bool > . combine ( outputs: [ output1, output2, output3] ) . bind { valuesArray in
112
112
outputValue1 = valuesArray [ 0 ]
113
113
outputValue2 = valuesArray [ 1 ]
114
114
outputValue3 = valuesArray [ 2 ]
@@ -144,13 +144,13 @@ final class OutputTests: XCTestCase {
144
144
}
145
145
146
146
func testCombineTwoTypes( ) {
147
- let output1 = Output < Bool > ( )
148
- let output2 = Output < String > ( )
147
+ let output1 = MutableOutput < Bool > ( )
148
+ let output2 = MutableOutput < String > ( )
149
149
150
150
var outputValue1 : Bool ?
151
151
var outputValue2 : String ?
152
152
153
- Output < Bool >
153
+ MutableOutput < Bool >
154
154
. combine ( output1, output2)
155
155
. bind { value1, value2 in
156
156
outputValue1 = value1
@@ -183,9 +183,9 @@ final class OutputTests: XCTestCase {
183
183
case two
184
184
}
185
185
186
- let value = Output < TestEnum > ( )
186
+ let value = MutableOutput < TestEnum > ( )
187
187
188
- let mappedValue : Output < String > =
188
+ let mappedValue : MutableOutput < String > =
189
189
value
190
190
. map { type in
191
191
switch type {
@@ -195,6 +195,7 @@ final class OutputTests: XCTestCase {
195
195
return " two "
196
196
}
197
197
}
198
+ . asMutable ( )
198
199
199
200
value. update ( withValue: . one)
200
201
XCTAssertEqual ( mappedValue. latest, " one " )
@@ -213,9 +214,9 @@ final class OutputTests: XCTestCase {
213
214
case two
214
215
}
215
216
216
- let value = Output < TestEnum > ( )
217
+ let value = MutableOutput < TestEnum > ( )
217
218
218
- let mappedValue : Output < String > =
219
+ let mappedValue : MutableOutput < String > =
219
220
value
220
221
. flatMap { type in
221
222
switch type {
@@ -225,6 +226,7 @@ final class OutputTests: XCTestCase {
225
226
return Output ( value: " two " )
226
227
}
227
228
}
229
+ . asMutable ( )
228
230
229
231
value. update ( withValue: . one)
230
232
XCTAssertEqual ( mappedValue. latest, " one " )
@@ -237,7 +239,7 @@ final class OutputTests: XCTestCase {
237
239
}
238
240
239
241
func testFilter( ) {
240
- let value = Output < String > ( )
242
+ let value = MutableOutput < String > ( )
241
243
242
244
let filteredValue = value
243
245
. filter { string in
@@ -255,8 +257,8 @@ final class OutputTests: XCTestCase {
255
257
}
256
258
257
259
func testMerge( ) {
258
- let output1 = Output < Int > ( )
259
- let output2 = Output < Int > ( )
260
+ let output1 = MutableOutput < Int > ( )
261
+ let output2 = MutableOutput < Int > ( )
260
262
261
263
let merge = Output . merge ( output1, output2)
262
264
@@ -280,7 +282,7 @@ final class OutputTests: XCTestCase {
280
282
var currentString : String = " "
281
283
}
282
284
283
- let initial = Output < Int > ( )
285
+ let initial = MutableOutput < Int > ( )
284
286
285
287
let reduced = initial
286
288
. reduce ( initial: TestObject ( ) ) { current, number -> TestObject in
@@ -298,7 +300,7 @@ final class OutputTests: XCTestCase {
298
300
}
299
301
300
302
func testReduceValueType( ) {
301
- let initial = Output < Int > ( )
303
+ let initial = MutableOutput < Int > ( )
302
304
303
305
let reduced = initial. reduce ( initial: 0 , nextPartialResult: + )
304
306
@@ -310,16 +312,16 @@ final class OutputTests: XCTestCase {
310
312
}
311
313
312
314
func testInitialValueFunctionChain( ) {
313
- let initial = Output < Int > ( ) . initial ( 10 )
315
+ let initial = MutableOutput < Int > ( ) . initial ( 10 )
314
316
XCTAssertEqual ( initial. latest, 10 )
315
317
316
- let alreadyPopulated = Output < Int > ( value: 5 ) . initial ( 10 )
318
+ let alreadyPopulated = MutableOutput < Int > ( value: 5 ) . initial ( 10 )
317
319
XCTAssertEqual ( alreadyPopulated. latest, 5 )
318
320
319
- let left = Output ( value: 3 )
320
- let right = Output < Int > ( )
321
+ let left = MutableOutput ( value: 3 )
322
+ let right = MutableOutput < Int > ( )
321
323
322
- let combined = Output
324
+ let combined = MutableOutput
323
325
. combine ( left, right)
324
326
. map ( + )
325
327
. initial ( 20 )
@@ -335,7 +337,7 @@ final class OutputTests: XCTestCase {
335
337
336
338
func testDebug( ) {
337
339
let printer = PrinterMock ( )
338
- let output1 = Output < Bool > ( printer: printer)
340
+ let output1 = MutableOutput < Bool > ( printer: printer)
339
341
340
342
XCTAssertTrue ( printer. printValues. isEmpty)
341
343
@@ -345,16 +347,16 @@ final class OutputTests: XCTestCase {
345
347
346
348
XCTAssertEqual ( printer. printValues. count, 3 )
347
349
XCTAssertEqual ( printer. printValues [ 0 ] , " --- " )
348
- XCTAssertEqual ( printer. printValues [ 1 ] , " Binding 123 (Output <Bool>) to (Function) " )
350
+ XCTAssertEqual ( printer. printValues [ 1 ] , " Binding 123 (MutableOutput <Bool>) to (Function) " )
349
351
XCTAssertEqual ( printer. printValues [ 2 ] , " To bindings: [Bind.Subscription: (Function)] " )
350
352
351
353
output1. update ( withValue: false )
352
354
353
355
XCTAssertEqual ( printer. printValues. count, 8 )
354
356
XCTAssertEqual ( printer. printValues [ 3 ] , " --- " )
355
- XCTAssertEqual ( printer. printValues [ 4 ] , " Will update value for 123 (Output <Bool>) to false " )
357
+ XCTAssertEqual ( printer. printValues [ 4 ] , " Will update value for 123 (MutableOutput <Bool>) to false " )
356
358
XCTAssertEqual ( printer. printValues [ 5 ] , " To bindings: [Bind.Subscription: (Function)] " )
357
- XCTAssertEqual ( printer. printValues [ 6 ] , " Did update value for 123 (Output <Bool>) to false " )
359
+ XCTAssertEqual ( printer. printValues [ 6 ] , " Did update value for 123 (MutableOutput <Bool>) to false " )
358
360
XCTAssertEqual ( printer. printValues [ 7 ] , " To bindings: [Bind.Subscription: (Function)] " )
359
361
}
360
362
}
0 commit comments