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

Make it clear that identity matchers only work with reference types #299

Merged
merged 2 commits into from
Jun 2, 2016

Conversation

lukeredpath
Copy link
Contributor

To clear up any confusion that might arise (see #298).

This might be obvious to an experienced Swift developer but it could catch people out (like me - see Quick#298).
@@ -492,6 +492,9 @@ expect(actual).toNot(beIdenticalTo(expected))
expect(actual) !== expected
```

Its important to remember that beIdenticalTo only makes sense when comparing types with reference semantics, which have a notion of identity. In Swift, that means a `class`. This matcher will not work with types with value semantics such as `struct` or `enum`. If you need to compare two value types, you can either compare individual properties or if it makes sense to do so, make your type implement `Equatable` and use Nimble's equivalence matchers instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Do you think it makes sense to have "beIdenticalTo" as "beIdenticalTo"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I missed that one.

@ashfurrow ashfurrow merged commit acb0f53 into Quick:master Jun 2, 2016
@ashfurrow
Copy link
Member

Thanks a lot!

Megal pushed a commit to Megal/Nimble that referenced this pull request Jul 31, 2019
Make it clear that identity matchers only work with reference types
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.

2 participants