Skip to content

Commit 423395b

Browse files
committed
Update CompletenessTest.scala
1 parent a20bed8 commit 423395b

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/Observable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ trait Observable[+T]
342342
*
343343
* A well-behaved Observable does not interleave its invocations of the [[rx.lang.scala.Observer.onNext onNext]], [[rx.lang.scala.Observer.onCompleted onCompleted]], and [[rx.lang.scala.Observer.onError onError]] methods of
344344
* its [[rx.lang.scala.Observer]]s; it invokes `onCompleted` or `onError` only once; and it never invokes `onNext` after invoking either `onCompleted` or `onError`.
345-
* `synchronize` enforces this, and the Observable it returns invokes `onNext` and `onCompleted` or `onError` synchronously.
345+
* [[Observable.serialize serialize]] enforces this, and the Observable it returns invokes `onNext` and `onCompleted` or `onError` synchronously.
346346
*
347347
* @return an Observable that is a chronologically well-behaved version of the source
348348
* Observable, and that synchronously notifies its [[rx.lang.scala.Observer]]s

language-adaptors/rxjava-scala/src/test/scala/rx/lang/scala/CompletenessTest.scala

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,15 @@ class CompletenessTest extends JUnitSuite {
7171
"all(Func1[_ >: T, Boolean])" -> "forall(T => Boolean)",
7272
"buffer(Long, Long, TimeUnit)" -> "buffer(Duration, Duration)",
7373
"buffer(Long, Long, TimeUnit, Scheduler)" -> "buffer(Duration, Duration, Scheduler)",
74-
"contains(T)" -> "contains(Any)",
74+
"contains(Any)" -> "contains(U)",
7575
"count()" -> "length",
7676
"dematerialize()" -> "dematerialize(<:<[Observable[T], Observable[Notification[U]]])",
77-
"elementAt(Int)" -> "[use `.drop(index).first`]",
78-
"elementAtOrDefault(Int, T)" -> "[use `.drop(index).firstOrElse(default)`]",
77+
"elementAtOrDefault(Int, T)" -> "elementAtOrDefault(Int, U)",
7978
"first(Func1[_ >: T, Boolean])" -> commentForFirstWithPredicate,
8079
"firstOrDefault(T)" -> "firstOrElse(=> U)",
81-
"firstOrDefault(Func1[_ >: T, Boolean], T)" -> "[use `.filter(condition).firstOrElse(default)`]",
80+
"firstOrDefault(T, Func1[_ >: T, Boolean])" -> "[use `.filter(condition).firstOrElse(default)`]",
8281
"groupBy(Func1[_ >: T, _ <: K], Func1[_ >: T, _ <: R])" -> "[use `groupBy` and `map`]",
8382
"lift(Operator[_ <: R, _ >: T])" -> "lift(Subscriber[R] => Subscriber[T])",
84-
"mapMany(Func1[_ >: T, _ <: Observable[_ <: R]])" -> "flatMap(T => Observable[R])",
8583
"mapWithIndex(Func2[_ >: T, Integer, _ <: R])" -> "[combine `zipWithIndex` with `map` or with a for comprehension]",
8684
"onErrorResumeNext(Func1[Throwable, _ <: Observable[_ <: T]])" -> "onErrorResumeNext(Throwable => Observable[U])",
8785
"onErrorResumeNext(Observable[_ <: T])" -> "onErrorResumeNext(Observable[U])",
@@ -95,6 +93,7 @@ class CompletenessTest extends JUnitSuite {
9593
"publish(Func1[_ >: Observable[T], _ <: Observable[R]], T)" -> "publish(Observable[U] => Observable[R], U)",
9694
"reduce(Func2[T, T, T])" -> "reduce((U, U) => U)",
9795
"reduce(R, Func2[R, _ >: T, R])" -> "foldLeft(R)((R, T) => R)",
96+
"repeat()" -> "repeat()",
9897
"retry()" -> "retry()",
9998
"scan(Func2[T, T, T])" -> unnecessary,
10099
"scan(R, Func2[R, _ >: T, R])" -> "scan(R)((R, T) => R)",
@@ -113,8 +112,8 @@ class CompletenessTest extends JUnitSuite {
113112
"skipLast(Int)" -> "dropRight(Int)",
114113
"skipLast(Long, TimeUnit)" -> "dropRight(Duration)",
115114
"skipLast(Long, TimeUnit, Scheduler)" -> "dropRight(Duration, Scheduler)",
116-
"takeFirst()" -> "first",
117-
"takeFirst(Func1[_ >: T, Boolean])" -> commentForFirstWithPredicate,
115+
"subscribe()" -> "subscribe()",
116+
"takeFirst(Func1[_ >: T, Boolean])" -> "[use `filter(condition).take(1)`]",
118117
"takeLast(Int)" -> "takeRight(Int)",
119118
"takeWhileWithIndex(Func2[_ >: T, _ >: Integer, Boolean])" -> "[use `.zipWithIndex.takeWhile{case (elem, index) => condition}.map(_._1)`]",
120119
"timeout(Func0[_ <: Observable[U]], Func1[_ >: T, _ <: Observable[V]], Observable[_ <: T])" -> "timeout(() => Observable[U], T => Observable[V], Observable[O])",
@@ -126,7 +125,6 @@ class CompletenessTest extends JUnitSuite {
126125
"toList()" -> "toSeq",
127126
"toSortedList()" -> "[Sorting is already done in Scala's collection library, use `.toSeq.map(_.sorted)`]",
128127
"toSortedList(Func2[_ >: T, _ >: T, Integer])" -> "[Sorting is already done in Scala's collection library, use `.toSeq.map(_.sortWith(f))`]",
129-
"where(Func1[_ >: T, Boolean])" -> "filter(T => Boolean)",
130128
"window(Long, Long, TimeUnit)" -> "window(Duration, Duration)",
131129
"window(Long, Long, TimeUnit, Scheduler)" -> "window(Duration, Duration, Scheduler)",
132130

@@ -139,28 +137,22 @@ class CompletenessTest extends JUnitSuite {
139137
"combineLatest(Observable[_ <: T1], Observable[_ <: T2], Func2[_ >: T1, _ >: T2, _ <: R])" -> "combineLatest(Observable[U])",
140138
"concat(Observable[_ <: Observable[_ <: T]])" -> "concat(<:<[Observable[T], Observable[Observable[U]]])",
141139
"defer(Func0[_ <: Observable[_ <: T]])" -> "defer(=> Observable[T])",
142-
"empty()" -> "apply(T*)",
143-
"error(Throwable)" -> "apply(Throwable)",
144-
"from(Array[T])" -> "apply(T*)",
145-
"from(Iterable[_ <: T])" -> "apply(T*)",
140+
"from(Array[T])" -> "[use apply(T*)]",
141+
"from(Iterable[_ <: T])" -> "from(Iterable[T])",
146142
"from(Future[_ <: T])" -> fromFuture,
147143
"from(Future[_ <: T], Long, TimeUnit)" -> fromFuture,
148144
"from(Future[_ <: T], Scheduler)" -> fromFuture,
149-
"just(T)" -> "apply(T*)",
145+
"just(T)" -> "[use apply(T*)]",
146+
"just(T, Scheduler)" -> "[use apply(T*).subscribeOn(scheduler)]",
150147
"merge(Observable[_ <: T], Observable[_ <: T])" -> "merge(Observable[U])",
151148
"merge(Observable[_ <: Observable[_ <: T]])" -> "flatten(<:<[Observable[T], Observable[Observable[U]]])",
152149
"mergeDelayError(Observable[_ <: T], Observable[_ <: T])" -> "mergeDelayError(Observable[U])",
153150
"mergeDelayError(Observable[_ <: Observable[_ <: T]])" -> "flattenDelayError(<:<[Observable[T], Observable[Observable[U]]])",
154151
"range(Int, Int)" -> "apply(Range)",
155-
"repeat()" -> "repeat()",
156-
"retry()" -> "retry()",
157-
"sequenceEqual(Observable[_ <: T], Observable[_ <: T])" -> "[use `(first zip second) map (p => p._1 == p._2)`]",
158-
"sequenceEqual(Observable[_ <: T], Observable[_ <: T], Func2[_ >: T, _ >: T, Boolean])" -> "[use `(first zip second) map (p => equality(p._1, p._2))`]",
159152
"sum(Observable[Integer])" -> "sum(Numeric[U])",
160153
"sumDoubles(Observable[Double])" -> "sum(Numeric[U])",
161154
"sumFloats(Observable[Float])" -> "sum(Numeric[U])",
162155
"sumLongs(Observable[Long])" -> "sum(Numeric[U])",
163-
"synchronize(Observable[T])" -> "synchronize",
164156
"switchDo(Observable[_ <: Observable[_ <: T]])" -> deprecated,
165157
"switchOnNext(Observable[_ <: Observable[_ <: T]])" -> "switch(<:<[Observable[T], Observable[Observable[U]]])",
166158
"zip(Observable[_ <: T1], Observable[_ <: T2], Func2[_ >: T1, _ >: T2, _ <: R])" -> "[use instance method `zip` and `map`]",
@@ -174,7 +166,7 @@ class CompletenessTest extends JUnitSuite {
174166
"concat(" + _ + ")" -> "[unnecessary because we can use `++` instead or `Observable(o1, o2, ...).concat`]"
175167
).drop(1).toMap ++ List.iterate("T", 10)(s => s + ", T").map(
176168
// all 10 overloads of from:
177-
"from(" + _ + ")" -> "apply(T*)"
169+
"from(" + _ + ")" -> "[use apply(T*)]"
178170
).toMap ++ (3 to 9).map(i => {
179171
// zip3-9:
180172
val obsArgs = (1 to i).map(j => s"Observable[_ <: T$j], ").mkString("")
@@ -216,6 +208,8 @@ class CompletenessTest extends JUnitSuite {
216208
// TODO how can we filter out instance methods which were put into companion because
217209
// of extends AnyVal in a way which does not depend on implementation-chosen name '$extension'?
218210
.filter(! _.contains("$extension"))
211+
// `access$000` is public. How to distinguish it from others without hard-code?
212+
.filter(! _.contains("access$000"))
219213
}
220214

221215
// also applicable for Java types
@@ -373,7 +367,10 @@ class CompletenessTest extends JUnitSuite {
373367
def escape(s: String) = s.replaceAllLiterally("[", "&lt;").replaceAllLiterally("]", "&gt;")
374368

375369
println("""
376-
## Comparison of Scala Observable and Java Observable
370+
---
371+
layout: comparison
372+
title: Comparison of Scala Observable and Java Observable
373+
---
377374
378375
Note:
379376
* This table contains both static methods and instance methods.

0 commit comments

Comments
 (0)