### Question:
SingleOnErrorResumeWith extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { Objects.requireNonNull(subscriber, "subscriber is null"); source.subscribe(new OnErrorResumeWithSubscriber<>(subscriber, fallbackFunction)); } SingleOnErrorResumeWith(Single<T> source,
                            Function<? super Throwable, ? extends Single<? extends T>> fallbackFunction); @Override void subscribe(Flow.Subscriber<? super T> subscriber);  }### Answer:
@Test public void fallbackFunctionCrash() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Single.<Integer>error(new IOException()) .onErrorResumeWith(e -> { throw new IllegalArgumentException(); }) .subscribe(ts); ts.assertFailure(IllegalArgumentException.class); assertThat(ts.getLastError().getSuppressed()[0], instanceOf(IOException.class)); }
@Test public void fallbackToError() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Single.<Integer>error(new IOException()) .onErrorResumeWith(e -> Single.error(new IllegalArgumentException())) .subscribe(ts); ts.assertFailure(IllegalArgumentException.class); }
@Test public void emptySource() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Single.<Integer>empty() .onErrorResumeWith(e -> Single.just(e.hashCode())) .subscribe(ts); ts.assertResult(); }
@Test public void emptyFallback() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Single.<Integer>error(new IOException()) .onErrorResumeWith(e -> Single.empty()) .subscribe(ts); ts.assertResult(); }
@Test public void noSelfSuppressionFailure() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Single.<Integer>error(new IllegalArgumentException()) .onErrorResumeWith(e -> { throw (IllegalArgumentException)e; }) .subscribe(ts); ts.assertFailure(IllegalArgumentException.class); }