-
-
Notifications
You must be signed in to change notification settings - Fork 600
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 ability to compare tuples #227
Comments
It seems it's a swift compiler's bug to support array of tuple. I can also not append an element to an array of tuple. |
Unfortunately, swift currently doesn't have a clean way of representing arbitrary tuples for Nimble to perform equality against. There only way is to implement it for each tuple of a given size (unlabeled). For now, you'll have to compare each element in the tuple manually. |
It looks like this is coming in Swift 2.2: https://github.com/apple/swift-evolution/blob/master/proposals/0015-tuple-comparison-operators.md |
That feature from that proposal is now available in the latest Xcode, however it doesn't do much to help with @abbeycode's original feature request. Specifically, the standard library now provides additional overloads of let tuple = (1, 2)
tuple == tuple // This works now!
expect(tuple).to(equal(tuple)) // Error: Cannot invoke 'equal' with an argument list of type '(Int, Int)'
let tuples = [(1, 2)]
tuples == tuples // Error: Binary operator '==' cannot be applied to two '[(Int, Int)]' operands |
in this case: |
update CocoaPods instructions
Looks like the proposal was accepted and is now being implemented 🎉 swiftlang/swift#28833 |
It was merged but then it was reverted :( |
Implemented For arrays of tuples, you can use expect([(1, "2"), (3, "4")]).to(elementsEqual([(1, "2"), (3, "4")], by: ==)) |
I have test code like this:
I get a compiler error:
I tried removing the labels in the tuple, and I get the same error (but without the labels in the type the error prints). Is there a way to accomplish this type of matching with Nimble?
The text was updated successfully, but these errors were encountered: