chore: Fix expectNextWithTimeoutPF (#1218)

This commit is contained in:
He-Pin(kerr) 2024-03-23 19:39:04 +08:00 committed by GitHub
parent e3410bcaa8
commit 33a845a9e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -852,10 +852,10 @@ object TestSubscriber {
* @param max wait no more than max time, otherwise throw AssertionError
*/
def expectNextWithTimeoutPF[T](max: Duration, f: PartialFunction[Any, T]): T = {
val pf: PartialFunction[SubscriberEvent, Any] = {
case OnNext(n) => n
val pf: PartialFunction[SubscriberEvent, T] = {
case OnNext(n) if f.isDefinedAt(n) => f(n)
}
expectEventWithTimeoutPF(max, pf.andThen(f))
expectEventWithTimeoutPF[T](max, pf)
}
/**