Skip to content

Commit 6a32dea

Browse files
committed
Consistent example format
1 parent 172ebae commit 6a32dea

29 files changed

+438
-408
lines changed

tests/java/itrx/chapter3/combining/CombineLatestTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ public void example() {
2323
.take(6)
2424
.subscribe(System.out::println);
2525

26-
// Left emits
27-
// Right emits
28-
// 0 - 0
29-
// Left emits
30-
// 1 - 0
31-
// Left emits
32-
// 2 - 0
33-
// Right emits
34-
// 2 - 1
35-
// Left emits
36-
// 3 - 1
37-
// Right emits
38-
// 3 - 2
26+
// Left emits
27+
// Right emits
28+
// 0 - 0
29+
// Left emits
30+
// 1 - 0
31+
// Left emits
32+
// 2 - 0
33+
// Right emits
34+
// 2 - 1
35+
// Left emits
36+
// 3 - 1
37+
// Right emits
38+
// 3 - 2
3939
}
4040

4141

tests/java/itrx/chapter3/combining/ConcatTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public void exampleConcat() {
1616
Observable.concat(seq1, seq2)
1717
.subscribe(System.out::println);
1818

19-
// 0
20-
// 1
21-
// 2
22-
// 10
23-
// 11
24-
// 12
19+
// 0
20+
// 1
21+
// 2
22+
// 10
23+
// 11
24+
// 12
2525
}
2626

2727
public void exampleConcatDynamic() {
@@ -37,12 +37,12 @@ public void exampleConcatDynamic() {
3737
Observable.concat(words.groupBy(v -> v.charAt(0)))
3838
.subscribe(System.out::println);
3939

40-
// First
41-
// Fourth
42-
// Fifth
43-
// Second
44-
// Sixth
45-
// Third
40+
// First
41+
// Fourth
42+
// Fifth
43+
// Second
44+
// Sixth
45+
// Third
4646
}
4747

4848

tests/java/itrx/chapter3/combining/MergeTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ public void example() {
2020
.take(10)
2121
.subscribe(System.out::println);
2222

23-
// Second
24-
// First
25-
// Second
26-
// Second
27-
// First
28-
// Second
29-
// Second
30-
// First
31-
// Second
32-
// First
23+
// Second
24+
// First
25+
// Second
26+
// Second
27+
// First
28+
// Second
29+
// Second
30+
// First
31+
// Second
32+
// First
3333
}
3434

3535

tests/java/itrx/chapter3/combining/RepeatTest.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public void exampleRepeat() {
3939
.take(4)
4040
.subscribe(System.out::println);
4141

42-
// 0
43-
// 1
44-
// 0
45-
// 1
42+
// 0
43+
// 1
44+
// 0
45+
// 1
4646
}
4747

4848
public void exampleRepeat2() {
@@ -51,10 +51,10 @@ public void exampleRepeat2() {
5151
words.repeat(2)
5252
.subscribe(System.out::println);
5353

54-
// 0
55-
// 1
56-
// 0
57-
// 1
54+
// 0
55+
// 1
56+
// 0
57+
// 1
5858
}
5959

6060
public void exampleRepeatWhen2() {
@@ -67,11 +67,11 @@ public void exampleRepeatWhen2() {
6767
})
6868
.subscribe(new PrintSubscriber("repeatWhen"));
6969

70-
// repeatWhen: 0
71-
// repeatWhen: 1
72-
// repeatWhen: 0
73-
// repeatWhen: 1
74-
// repeatWhen: Completed
70+
// repeatWhen: 0
71+
// repeatWhen: 1
72+
// repeatWhen: 0
73+
// repeatWhen: 1
74+
// repeatWhen: Completed
7575
}
7676

7777
public void exampleRepeatWithInterval() {
@@ -86,16 +86,16 @@ public void exampleRepeatWithInterval() {
8686
.take(2) // Stop after second repetition
8787
.subscribe(new PrintSubscriber("repeatWhen"));
8888

89-
// repeatWhen: 0
90-
// repeatWhen: 1
91-
// repeatWhen: 2
92-
// repeatWhen: 3
93-
// repeatWhen: 4
94-
// repeatWhen: 0
95-
// repeatWhen: 1
96-
// repeatWhen: 2
97-
// repeatWhen: 3
98-
// repeatWhen: 4
89+
// repeatWhen: 0
90+
// repeatWhen: 1
91+
// repeatWhen: 2
92+
// repeatWhen: 3
93+
// repeatWhen: 4
94+
// repeatWhen: 0
95+
// repeatWhen: 1
96+
// repeatWhen: 2
97+
// repeatWhen: 3
98+
// repeatWhen: 4
9999
}
100100

101101

tests/java/itrx/chapter3/combining/StartWithTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public void example() {
1515
values.startWith(-1,-2)
1616
.subscribe(System.out::println);
1717

18-
// -1
19-
// -2
20-
// 0
21-
// 1
22-
// 2
18+
// -1
19+
// -2
20+
// 0
21+
// 1
22+
// 2
2323
}
2424

2525

tests/java/itrx/chapter3/combining/SwitchOnNext.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,22 @@ public void example() {
2525
.take(10)
2626
.subscribe(System.out::println);
2727

28-
// 0
29-
// 0
30-
// 0
31-
// 1
32-
// 1
33-
// 1
34-
// 2
35-
// 2
36-
// 2
37-
// 3
28+
// 0
29+
// 0
30+
// 0
31+
// 1
32+
// 1
33+
// 1
34+
// 2
35+
// 2
36+
// 2
37+
// 3
3838
}
39-
39+
40+
41+
//
42+
// Test
43+
//
4044

4145
@Test
4246
public void test() {

tests/java/itrx/chapter3/combining/ZipTest.java

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,34 @@ public void example() {
2323
.take(6)
2424
.subscribe(System.out::println);
2525

26-
// Left emits
27-
// Right emits
28-
// 0 - 0
29-
// Left emits
30-
// Right emits
31-
// Left emits
32-
// 1 - 1
33-
// Left emits
34-
// Right emits
35-
// 2 - 2
36-
// Left emits
37-
// Left emits
38-
// Right emits
39-
// 3 - 3
40-
// Left emits
41-
// Right emits
42-
// 4 - 4
43-
// Left emits
44-
// Right emits
45-
// Left emits
46-
// 5 - 5
26+
// Left emits
27+
// Right emits
28+
// 0 - 0
29+
// Left emits
30+
// Right emits
31+
// Left emits
32+
// 1 - 1
33+
// Left emits
34+
// Right emits
35+
// 2 - 2
36+
// Left emits
37+
// Left emits
38+
// Right emits
39+
// 3 - 3
40+
// Left emits
41+
// Right emits
42+
// 4 - 4
43+
// Left emits
44+
// Right emits
45+
// Left emits
46+
// 5 - 5
4747
}
4848

49+
50+
//
51+
// Test
52+
//
53+
4954
@Test
5055
public void test() {
5156
TestScheduler scheduler = Schedulers.test();

tests/java/itrx/chapter3/custom/ComposeTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ public void exampleComposeFromClass() {
5252
.compose(new RunningAverage())
5353
.subscribe(System.out::println);
5454

55-
// 2.0
56-
// 2.5
57-
// 5.0
58-
// 6.75
59-
// 6.2
55+
// 2.0
56+
// 2.5
57+
// 5.0
58+
// 6.75
59+
// 6.2
6060
}
6161

6262
public void exampleComposeParameterised() {
6363
Observable.just(2, 3, 10, 12, 4)
6464
.compose(new RunningAverage(5))
6565
.subscribe(System.out::println);
6666

67-
// 2.0
68-
// 2.5
69-
// 3.0
67+
// 2.0
68+
// 2.5
69+
// 3.0
7070
}
7171

7272

tests/java/itrx/chapter3/custom/LiftTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public void exampleLift() {
5353
.lift(MyMap.create(i -> i + "!"))
5454
.subscribe(System.out::println);
5555

56-
// 0!
57-
// 1!
58-
// 2!
59-
// 3!
60-
// 4!
56+
// 0!
57+
// 1!
58+
// 2!
59+
// 3!
60+
// 4!
6161
}
6262

6363

tests/java/itrx/chapter3/error/ResumeTest.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public void onNext(Object v) {
3131
System.out.println(name + ": " + v);
3232
}
3333
}
34+
35+
public static void main(String[] args) {
36+
new ResumeTest().exampleOnExceptionResumeNextNoException();
37+
}
3438

3539
public void exampleOnErrorReturn() {
3640
Observable<String> values = Observable.create(o -> {
@@ -43,9 +47,9 @@ public void exampleOnErrorReturn() {
4347
.onErrorReturn(e -> "Error: " + e.getMessage())
4448
.subscribe(v -> System.out.println(v));
4549

46-
// Rx
47-
// is
48-
// Error: adjective unknown
50+
// Rx
51+
// is
52+
// Error: adjective unknown
4953
}
5054

5155
public void exampleOnErrorResumeNext() {
@@ -59,10 +63,10 @@ public void exampleOnErrorResumeNext() {
5963
.onErrorResumeNext(Observable.just(Integer.MAX_VALUE))
6064
.subscribe(new PrintSubscriber("with onError: "));
6165

62-
// with onError: 1
63-
// with onError: 2
64-
// with onError: 2147483647
65-
// with onError: Completed
66+
// with onError: 1
67+
// with onError: 2
68+
// with onError: 2147483647
69+
// with onError: Completed
6670
}
6771

6872
public void exampleOnErrorResumeNextRethrow() {
@@ -75,6 +79,10 @@ public void exampleOnErrorResumeNextRethrow() {
7579
values
7680
.onErrorResumeNext(e -> Observable.error(new UnsupportedOperationException(e)))
7781
.subscribe(new PrintSubscriber("with onError: "));
82+
83+
// with onError: : 1
84+
// with onError: : 2
85+
// with onError: : Error: java.lang.UnsupportedOperationException: java.lang.Exception: Oops
7886
}
7987

8088
public void exampleOnExceptionResumeNext() {
@@ -87,6 +95,10 @@ public void exampleOnExceptionResumeNext() {
8795
values
8896
.onExceptionResumeNext(Observable.just("hard"))
8997
.subscribe(v -> System.out.println(v));
98+
99+
// Rx
100+
// is
101+
// hard
90102
}
91103

92104
@SuppressWarnings("serial")
@@ -100,6 +112,10 @@ public void exampleOnExceptionResumeNextNoException() {
100112
values
101113
.onExceptionResumeNext(Observable.just("hard"))
102114
.subscribe(v -> System.out.println(v));
115+
116+
// Rx
117+
// is
118+
// uncaught exception
103119
}
104120

105121

0 commit comments

Comments
 (0)