Description
The tokens_for test fixture helper is effectively duplicated across multiple test modules, creating unnecessary code duplication in test infrastructure.
Priority
Low – Test infrastructure quality issue, not blocking functionality.
Details
Affected locations:
src/parser/ast/parse_utils/params/tests.rs:10
src/parser/ast/parse_utils/type_expr/tests.rs:10
Current state:
tokens_for helper function is duplicated in at least two test modules
- Each module maintains its own copy of the same fixture setup logic
- Changes to fixture setup must be applied in multiple places
Impact
- Maintenance burden: Changes to fixture setup require updates in multiple test files
- Consistency risk: Fixture implementations can drift, causing subtle test behaviour differences
- Code duplication: Violates DRY principle even in test code
- Developer experience: Contributors may not realise the helper exists elsewhere and create more copies
Actionable Fix
Extract the shared fixture helper into one local test utility module.
Approach:
- Create a shared test utilities module (e.g.,
src/parser/ast/parse_utils/test_utils.rs or src/parser/test_helpers.rs)
- Move
tokens_for (and any other shared test helpers) to the shared module
- Update test files to import from the shared utility module
- Remove duplicated implementations
Benefits:
- Single source of truth for test fixtures
- Consistent fixture behaviour across all tests
- Easier to maintain and extend test infrastructure
- Reduces test code duplication
References
Requested by
@leynos
Description
The
tokens_fortest fixture helper is effectively duplicated across multiple test modules, creating unnecessary code duplication in test infrastructure.Priority
Low – Test infrastructure quality issue, not blocking functionality.
Details
Affected locations:
src/parser/ast/parse_utils/params/tests.rs:10src/parser/ast/parse_utils/type_expr/tests.rs:10Current state:
tokens_forhelper function is duplicated in at least two test modulesImpact
Actionable Fix
Extract the shared fixture helper into one local test utility module.
Approach:
src/parser/ast/parse_utils/test_utils.rsorsrc/parser/test_helpers.rs)tokens_for(and any other shared test helpers) to the shared moduleBenefits:
References
@leynosRequested by
@leynos