Skip to content

Add more test coverage for narrow and cleanup existing logic with helpers#9

Merged
JRMurr merged 5 commits into
mainfrom
test-cleanup
Apr 6, 2026
Merged

Add more test coverage for narrow and cleanup existing logic with helpers#9
JRMurr merged 5 commits into
mainfrom
test-cleanup

Conversation

@JRMurr

@JRMurr JRMurr commented Apr 6, 2026

Copy link
Copy Markdown
Owner

No description provided.

JRMurr and others added 5 commits April 5, 2026 19:40
- 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>
@JRMurr JRMurr enabled auto-merge April 6, 2026 02:01
@JRMurr JRMurr merged commit bdd24a1 into main Apr 6, 2026
2 checks passed
@JRMurr JRMurr deleted the test-cleanup branch April 6, 2026 02:19
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.

1 participant