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 CacheControl tests #680

Merged
merged 8 commits into from
Mar 2, 2025

Conversation

Cyberbeni
Copy link
Contributor

Noticed that CacheControl doesn't work with .any, tried adding XCTExpectedFailure for the failing test but apparently it is not implemented on Linux. Don't know when I'll have the time to look into fixing it, so I'm only submitting the tests for now.

@adam-fowler
Copy link
Member

I added a fix so you PR passes all its tests

@Cyberbeni
Copy link
Contributor Author

Removed the func == implementation, since it wasn't working (probably because Category is RawRepresentable and that default implementation of Equatable is higher priority than default implementation for types with only equatable variables) and it also wasn't transitive. https://developer.apple.com/documentation/swift/equatable

Since equality between instances of Equatable types is an equivalence relation, any of your custom types that conform to Equatable must satisfy three conditions, for any values a, b, and c:

  • a == a is always true (Reflexivity)
  • a == b implies b == a (Symmetry)
  • a == b and b == c implies a == c (Transitivity)

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.00%. Comparing base (006cb40) to head (8bbc20e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #680      +/-   ##
==========================================
+ Coverage   83.82%   84.00%   +0.17%     
==========================================
  Files         117      117              
  Lines        7444     7444              
==========================================
+ Hits         6240     6253      +13     
+ Misses       1204     1191      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adam-fowler
Copy link
Member

An alternative solution would be to change the == implementation to ~= and remove the Equatable conformance from Category and use the ~= inside isType.

@Cyberbeni
Copy link
Contributor Author

Ok, I also removed Category.Internal as it was redundant to have the same cases for the wrapper type.

@Cyberbeni
Copy link
Contributor Author

As far as I know, the only breaking change is that a switch case over Category will produce a warning for the default case if all the cases are listed.

@adam-fowler
Copy link
Member

Ok, I also removed Category.Internal as it was redundant to have the same cases for the wrapper type.

Public enums in libraries are not a good idea, because adding cases to them is a breaking change. You need to wrap them in a struct to avoid the breaking change. See this pitch which will hopefully make it into swift https://forums.swift.org/t/pitch-extensible-enums-for-non-resilient-modules/77649

@Cyberbeni
Copy link
Contributor Author

Ah,this comes up every time I forget about it... It was even mentioned in the original proposal: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0192-non-exhaustive-enums.md#allow-enums-defined-in-source-packages-to-be-considered-non-frozen

Copy link
Member

@adam-fowler adam-fowler left a comment

Choose a reason for hiding this comment

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

Looks good

@adam-fowler adam-fowler merged commit 8219ec6 into hummingbird-project:main Mar 2, 2025
9 of 10 checks passed
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