-
Notifications
You must be signed in to change notification settings - Fork 83
Proposal to Upstream Specific Navigation Test Pattern currently used to test OCaml #156
Description
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-forwardwithback-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