-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
adding beginWith matcher for sequence prefixes #719
Conversation
Thanks for the pull request! While this should be useful, I think the name would confused with the existing |
I could, however, this case: let y = [[Int]]()
expect(y).to(beginWith([])) won't work unless you specify the type explicitly: expect(y).to(beginWith([] as [[Int]])) without explicit type cast it calls this: Nimble/Sources/Nimble/Matchers/BeginWith.swift Lines 5 to 6 in bfcdaca
and fails with a hard to understand error (at least at first glimpse): failed - expected to begin with <[]>, got <[]> .
also this case won't work for the same reason: let y = [Int]()
expect([]).to(beginWith(y))
// or hypothetically
expect([]).to(beginWith([] as [Int])) unless: expect([] as [Int]).to(beginWith(y))
expect([] as [Int]).to(beginWith([])) So to avoid confusion and add more convenience at call site, in these and maybe some other cases, I have named it |
Fair point, thanks for pointing it out. But I'm still uncomfortable about Let's see func starts<PossiblePrefix>(with possiblePrefix: PossiblePrefix) -> Bool where PossiblePrefix : Sequence, Self.Element == PossiblePrefix.Element I propose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor comments but entirely looks good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
Hi I would like to add a convenience matcher for sequence prefixes.
So that we can expect a particular sequence to start with provided elements.
Checklist - While not every PR needs it, new features should consider this list: