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

Equal predicate for array of tuples #1065

Merged
merged 3 commits into from
Jul 18, 2023
Merged

Equal predicate for array of tuples #1065

merged 3 commits into from
Jul 18, 2023

Conversation

faroman
Copy link
Contributor

@faroman faroman commented Jul 15, 2023

Added ability to check an array of tuples for equivalence.
Nimble provides such API for tuples, but not for arrays of tuples.
The new feature was implemented by copy-pasting the Equal+Tuple.swift file with the necessary adjustments.

  • Existing behavior was NOT changed, just added new functionality

  • Nothing was refactored, but extended EqualTest.swift with new tests

  • This change introduced because I use MOCs generator from Sourcery
    which produces arrays of tuples and it will be useful to compare such arrays in a convenient way

  • Tests are added into EqualTest.swift and successfully passed (via \.test tool)

  • Code is documented

  • Public API is NOT broken (major version bump is NOT required)

  • This is a new feature (minor version bump is desirable)

Unfortunately, there is a lot of duplicated code in the tests, but I can't get rid of it :(

Added ability to check an array of tuples for equivalence (useful for MOCs generated by Sourcery)
@younata
Copy link
Member

younata commented Jul 15, 2023

I love this. It's great.

I do wonder if maybe it would be better to do this using type parameter packs? (And similarly, go back to the equal+tuples and reimplement it using type parameter packs - which would be an entirely separate PR).

OTOH, as written, this will support earlier versions of Swift.

Fixed swiftlint issues
@faroman
Copy link
Contributor Author

faroman commented Jul 17, 2023

Looks like type parameter packs is useless in this case :(
I've installed Xcode 15 and tried to rewrite equal function for tuples and arrays of tuple, but got no results. Maybe I don't understand how to implement it in a proper way. Please look in the attached files, maybe you will find a reason why they cannot not be compiled.

Also I fixed swiftlint issues

Archive.zip

@younata
Copy link
Member

younata commented Jul 18, 2023

Looks like type parameter packs is useless in this case :(
I've installed Xcode 15 and tried to rewrite equal function for tuples and arrays of tuple, but got no results. Maybe I don't understand how to implement it in a proper way. Please look in the attached files, maybe you will find a reason why they cannot not be compiled.

Bummer. I'll look into redoing this to use parameter packs (if possible) at a later date. For now, this is good and I don't see any reason to block it any more than I have. Thanks for your contribution!

Also I fixed swiftlint issues.

Thanks!

@younata younata enabled auto-merge (squash) July 18, 2023 15:47
@younata younata merged commit 02f1aa9 into Quick:main Jul 18, 2023
13 checks passed
@faroman faroman deleted the add_equal_for_array_of_tuples branch July 18, 2023 18:58
@faroman
Copy link
Contributor Author

faroman commented Jul 18, 2023

Thanks!

🤝

@ikesyo ikesyo mentioned this pull request Aug 6, 2023
cgrindel-self-hosted-renovate bot added a commit to cgrindel/rules_swift_package_manager that referenced this pull request Aug 24, 2023
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [Quick/Nimble](https://github.com/Quick/Nimble) | minor | `from:
"12.1.0"` -> `from: "12.2.0"` |

---

### Release Notes

<details>
<summary>Quick/Nimble (Quick/Nimble)</summary>

### [`v12.2.0`](https://github.com/Quick/Nimble/releases/tag/v12.2.0)

[Compare
Source](https://github.com/Quick/Nimble/compare/v12.1.0...v12.2.0)

### Highlights

the `equal` matcher now supports arrays of tuples. For example:

```swift
expect([
    (1, 2),
    (3, 4)
]).to(equal([
    (1, 2),
    (3, 4)
]))
```

Thanks [@&#8203;faroman](https://github.com/faroman) for their
contribution!

### Automatically Generated Release Notes

#### What's Changed

- Fix typo in README.md by
[@&#8203;nemesis](https://github.com/nemesis) in
[Quick/Nimble#1066
- Equal predicate for array of tuples by
[@&#8203;faroman](https://github.com/faroman) in
[Quick/Nimble#1065

#### New Contributors

- [@&#8203;nemesis](https://github.com/nemesis) made their first
contribution in
[Quick/Nimble#1066
- [@&#8203;faroman](https://github.com/faroman) made their first
contribution in
[Quick/Nimble#1065

**Full Changelog**:
Quick/Nimble@v12.1.0...v12.2.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41Ny4yIiwidXBkYXRlZEluVmVyIjoiMzYuNTcuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
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.

3 participants