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

Add assertions for sequences #159

Merged
merged 9 commits into from
Nov 17, 2019
Merged

Add assertions for sequences #159

merged 9 commits into from
Nov 17, 2019

Conversation

jcornaz
Copy link
Contributor

@jcornaz jcornaz commented Oct 1, 2019

Hi,

Thi PR adds assertions for sequences.

Resolves #149

  • my name is already in the AUTHORS file

@jcornaz jcornaz changed the title Feature/sequence assertions Add assertions for sequences Oct 1, 2019
@jcornaz
Copy link
Contributor Author

jcornaz commented Oct 1, 2019

I'm not sure about the shouldEqual and shouldNotEqual. In one hand it could be useful. In the other it may be astonishing, since it is not consistent with ==.

Tell me what you think about it. And I'll remove it if necessary.

@MarkusAmshove
Copy link
Owner

Thanks for the PR, I'll have time to look into it at the weekend.

I think shouldEqual should mimic the behaviour of Iterable shouldEqual Iterable.
But it needs to make sure that it doesn't run forever, since Sequences can be infinite

@MarkusAmshove
Copy link
Owner

sequence shouldEqual sequence would now resolve to T shouldEqual T, which calls assertEquals under the hood.
Can you test if this results in anything useful? If not, we should definitely add custom behavior to prevent confusion :-)

@jcornaz
Copy link
Contributor Author

jcornaz commented Oct 24, 2019

Hi @MarkusAmshove,

After some thought I don't think equality check make sense for sequences.

I think one should use shouldContainSame or have explicti toList().

Otherwise reading seq1 shouldEqual seq2 should be hard to interpret for newcommers since Sequence do not normally support equality check.

@MarkusAmshove
Copy link
Owner

That makes sense, but should we have an overload for Sequences and shouldEqual that throws to let the user know that it doesn't make sense and they should use another assertion?

Because there is Any.shouldEqual(Any), so the method would be available for Sequences :-)

@jcornaz
Copy link
Contributor Author

jcornaz commented Nov 12, 2019

should we have an overload for Sequences and shouldEqual that throws to let the user know that it doesn't make sense and they should use another assertion?

Interesting idea. Yeah it'd be nice I think. I'll add this overload.

@jcornaz
Copy link
Contributor Author

jcornaz commented Nov 16, 2019

I made the change preventing usage of shouldEqual and shouldNotEqual on sequences.

@jcornaz jcornaz closed this Nov 16, 2019
@jcornaz jcornaz deleted the feature/sequence-assertions branch November 16, 2019 21:10
@jcornaz jcornaz restored the feature/sequence-assertions branch November 16, 2019 21:10
@jcornaz jcornaz reopened this Nov 16, 2019
@MarkusAmshove MarkusAmshove mentioned this pull request Nov 17, 2019
18 tasks
@MarkusAmshove MarkusAmshove merged commit 5ef432d into MarkusAmshove:master Nov 17, 2019
@MarkusAmshove
Copy link
Owner

This is now released within 1.57

@jcornaz jcornaz deleted the feature/sequence-assertions branch November 17, 2019 21:57
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.

Assertion for sequences
2 participants