Add more test coverage for narrow and cleanup existing logic with helpers#9
Merged
Conversation
- Add 37 unit tests for the 3 public functions in narrow.rs (previously zero test coverage): analyze_condition, detect_conditional_fn, and detect_conditional_apply_narrowing. Covers all match arms: null equality, literal comparisons, hasattr, negation, AND/OR combinators, type predicate builtins, compound predicates, select chain predicates, curried hasAttr, aliased builtins, and edge cases. - Extract find_name and find_ref_expr from nameres.rs local test module into shared tests.rs so they can be reused across test modules. - Add find_if_condition and find_apply helpers to tests.rs for narrow and future test use. - Make indoc a workspace dependency (was hardcoded in 4 crate Cargo.tomls) and add it as a dev-dependency for lang_ast. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the repeated `h.open() + h.wait_for_diagnostics(TIMEOUT)` pattern across 21 e2e test files with a single `h.open_and_wait()` call. Instances where the diagnostics result is used for assertions are left as-is. Net reduction of ~70 lines of boilerplate. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add expect_type_alias, expect_val_decl, and expect_module helpers that replace the verbose match+panic pattern for asserting TixDeclaration variants. Updated 15 tests to use the helpers, reducing nesting depth and boilerplate. Tests needing access to doc/source/span fields keep their existing match patterns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move int(), string(), bool_(), null(), float(), number(), path() helpers from collect.rs local test module to tests.rs so they can be reused by other test modules. collect.rs now imports them via crate::tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Consolidate per-function #[allow(dead_code)] on shared primitive helpers into a single module-level annotation. - Extract inline AST navigation from conditional_apply_optional_string test into the detect_apply_narrowing helper, reducing the test body to a straightforward assert pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.