Skip to content

Proposal to Upstream Specific Navigation Test Pattern currently used to test OCaml #156

@PizieDust

Description

@PizieDust

Currently, combobulate primarily supports a testing pattern based on static markers (e.g., ①, ②) defined in fixture files. While effective for simple end-state verification, for OCaml we have introduced a more robust navigation Pattern.
This methodology allows for testing the traversal logic of the tree rather than just the final position of the point. We propose upstreaming the helpers used in this method to provide a standardized way to test structural navigation in complex, functional languages.

  • Indentation-Aware Targeting: Unlike standard searches, these tests combine re-search-forward with back-to-indentation. This ensures the point lands precisely on the keyword (e.g., let) rather than leading whitespace, which is critical for accurate Tree-sitter node activation in indented OCaml code.

  • Granular Traversal Verification: Traversal is broken down into named steps. This provides high-resolution debugging; if a navigation path fails, the developer knows exactly which node transition (e.g., "move to [" or "move to number") was the breaking point.

  • Vertical vs. Horizontal Validation: The method allows us to test different navigation strategies on the same code block. For example, testing both via a "down" path (parent-child) and a "next" path (sibling).

  • Dynamic State Check: Instead of relying on pre-placed overlays in a fixture, this method verifies the combobulate-node-type at every single step, ensuring the Tree-sitter parser is returning the expected node category at every point of the journey.

Example:

(combobulate-step "move to [" 
  (combobulate-navigate-down) 
  (should (equal (combobulate-node-type (combobulate-node-at-point)) "["))) 

(combobulate-step "move to first number" 
  (combobulate-navigate-down) 
  (should (equal (combobulate-node-type (combobulate-node-at-point)) "number"))) 

(combobulate-step "move to second number (sibling)" 
  (combobulate-navigate-next) 
  (should (equal (combobulate-node-type (combobulate-node-at-point)) "number")))

We propose upstreaming this new testing pattern

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions