Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare StreamSubject for adding Truth.assertThat(Stream). #1220

Closed
wants to merge 0 commits into from

Conversation

copybara-service[bot]
Copy link
Contributor

Prepare StreamSubject for adding Truth.assertThat(Stream).

At that point, some calls to assertThat(Object) will become calls to the new overload. That would be a problem if:

  • they call isEqualTo or isNotEqualTo, which we've turned into throwing @DoNotCall methods
  • they have already collected the Stream or they want to operate on the Stream afterward

This CL makes isEqualTo and isNotEqualTo "work" (though it leaves them deprecated, since they're still a bad idea), and it avoids collecting the Stream until necessary.

The isEqualTo change requires some weird plumbing because I made its failure message retain our warning about Stream.equals. That requires creating a new StreamSubject with a different FailureMetadata instance, which isn't the kind of thing we normally do. (We've done something similar in ThrowableSubject, but it is simpler because (a) ThrowableSubject uses the "normal" (i.e.., non-no-arg) check and (b) ThrowableSubject doesn't have to worry about avoiding re-collecting a Stream.)

We may want to clamp back down on isEqualTo in the future. I've set myself a calendar reminder for mid-year. For now, I just want to make assertThat(Stream), which will already be mildly disruptive, from being even more disruptive.

(progress toward #746)

RELNOTES=Made StreamSubject avoid collecting the Stream until necessary, and made its isEqualTo and isNotEqualTo methods no longer always throw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants