Skip to content

[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
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

hrayatnia
Copy link
Contributor

experiment: adding overloaded && and || for merging ConditionTraits

Motivation:

#1034

Modifications:

  • ConditionTrait
  • possible introduction of GroupedConditionTrait

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

hrayatnia added 11 commits April 9, 2025 08:58
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.
@hrayatnia hrayatnia changed the title 1034 introduce conditional trait all any #1034 introduce conditional trait all any Apr 21, 2025
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.
@grynspan grynspan changed the title #1034 introduce conditional trait all any [DNM] Introduce conditional trait all/any Apr 26, 2025
@grynspan grynspan added enhancement New feature or request public-api Affects public API traits Issues and PRs related to the trait subsystem or built-in traits labels Apr 26, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants