-
Notifications
You must be signed in to change notification settings - Fork 102
[DNM] Introduce conditional trait all/any #1087
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
Draft
hrayatnia
wants to merge
14
commits into
swiftlang:main
Choose a base branch
from
hrayatnia:1034-Introduce-conditional-trait-all-any
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[DNM] Introduce conditional trait all/any #1087
hrayatnia
wants to merge
14
commits into
swiftlang:main
from
hrayatnia:1034-Introduce-conditional-trait-all-any
+254
−5
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Introduces condition trait grouping with AND/OR operators. This allows for combining multiple condition traits to control test execution based on complex conditions. It also incorporates skip information to identify the source of the skip when a test is disabled.
Updates the `GroupedConditionTrait` to prepare for tests concurrently, improving performance. Also adds a check to ensure there are at least two condition traits before attempting to operate on them, preventing potential errors.
Addresses a scenario where a grouped condition trait might contain only a single condition. This change ensures that the single condition is properly handled, by evaluating or preparing it.
Moves the `GroupedConditionTrait` and its related extensions and enums to a dedicated file, improving code organization and maintainability. Updates tests to reflect the new file structure.
Corrects the logic for grouped conditions, particularly when both conditions are inverted. This ensures accurate evaluation of combined boolean expressions. Updates a test case to reflect the corrected logic.
Fixes an issue where the AND grouped condition was not correctly evaluating inverted conditions. This ensures the correct boolean result is returned when dealing with inverted conditions within an AND group, improving the overall accuracy of grouped condition evaluations.
Removes `GroupedConditionTrait` and implements `&&` and `||` operators directly on `ConditionTrait`. This simplifies the condition evaluation process and allows for more concise trait definitions.
Updates grouped condition traits to use closures for evaluation, improving logic and error handling. This change replaces the previous approach of storing condition traits and operations with a single closure that encapsulates the entire evaluation logic. This simplifies the code and makes it easier to reason about, especially in cases where conditions are nested. The closure-based approach also allows for more precise error handling, ensuring that the correct source location is used when skipping tests due to failed conditions.
use `GroupedConditionTrait` to enable the grouping of condition traits and modifies the `ConditionTrait` to return this new type when combining conditions using `&&` and `||` without storing all `ConditionTraits` and relevant `Operation`
Introduces a `combine` function to simplify the composition of `ConditionTrait` and `GroupedConditionTrait` instances using logical AND and OR operators. This change reduces code duplication and makes the logic more readable. Also, the `evaluate` method in `GroupedConditionTrait` is updated to only evaluate the condition and discard the result, which is the intended behavior.
Improves the structure and logic of `GroupedConditionTrait` for better readability and maintainability. Simplifies the evaluation process and introduces helper functions to clarify the logic behind AND/OR operations. Adds handling for `SkipInfo` within grouped conditions to ensure skipping is properly propagated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
public-api
Affects public API
traits
Issues and PRs related to the trait subsystem or built-in traits
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
experiment: adding overloaded
&&
and||
for mergingConditionTrait
sMotivation:
#1034
Modifications:
ConditionTrait
GroupedConditionTrait
Checklist: