Add tests: $match should match sibling OR parent docs, not both #5

Open
opened 2026-03-04 22:15:46 +00:00 by flamingcow · 0 comments
Owner

$match in a multi-doc stream can match either sibling documents in the same file or documents from parent files. The code in findMatches prioritizes parents: if any parent doc matches, siblings are not checked. This is intentional but has no dedicated test coverage.

Requested tests:

  1. $match matches a parent document:

a.yaml:

name: x
val: 1

a.b.yaml:

$match:
  name: x
z: 1

Expected: {name: x, val: 1, z: 1}

  1. $match matches a sibling document in the same file:

a.yaml:

name: x
val: 1
---
$match:
  name: x
z: 1

Expected: {name: x, val: 1, z: 1}

  1. $match matches sibling but leaves non-matching sibling alone:

a.yaml:

name: x
val: 1
---
name: y
val: 2
---
$match:
  name: x
z: 1

Expected: {name: x, val: 1, z: 1} and {name: y, val: 2}

`$match` in a multi-doc stream can match either sibling documents in the same file or documents from parent files. The code in `findMatches` prioritizes parents: if any parent doc matches, siblings are not checked. This is intentional but has no dedicated test coverage. **Requested tests:** 1. `$match` matches a parent document: a.yaml: ```yaml name: x val: 1 ``` a.b.yaml: ```yaml $match: name: x z: 1 ``` Expected: `{name: x, val: 1, z: 1}` 2. `$match` matches a sibling document in the same file: a.yaml: ```yaml name: x val: 1 --- $match: name: x z: 1 ``` Expected: `{name: x, val: 1, z: 1}` 3. `$match` matches sibling but leaves non-matching sibling alone: a.yaml: ```yaml name: x val: 1 --- name: y val: 2 --- $match: name: x z: 1 ``` Expected: `{name: x, val: 1, z: 1}` and `{name: y, val: 2}`
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bkl/bkl#5