Skip to content

Commit 9fa353b

Browse files
Copilotmikefarah
andcommitted
Add test coverage for parent(0) and parent(-3) edge cases
Co-authored-by: mikefarah <[email protected]>
1 parent c6ecad1 commit 9fa353b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/yqlib/operator_parent_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ var parentOperatorScenarios = []expressionScenario{
6565
"D0, P[a], (!!map)::b:\n c: cat\n",
6666
},
6767
},
68+
{
69+
description: "boundary negative",
70+
skipDoc: true,
71+
document: "a:\n b:\n c: cat\n",
72+
expression: `.a.b.c | parent(-3)`,
73+
expected: []string{
74+
"D0, P[a b], (!!map)::c: cat\n",
75+
},
76+
},
6877
{
6978
description: "large negative",
7079
skipDoc: true,
@@ -74,6 +83,15 @@ var parentOperatorScenarios = []expressionScenario{
7483
"D0, P[a b c], (!!str)::cat\n",
7584
},
7685
},
86+
{
87+
description: "parent zero",
88+
skipDoc: true,
89+
document: "a:\n b:\n c: cat\n",
90+
expression: `.a.b.c | parent(0)`,
91+
expected: []string{
92+
"D0, P[a b c], (!!str)::cat\n",
93+
},
94+
},
7795
{
7896
description: "large positive",
7997
skipDoc: true,

0 commit comments

Comments
 (0)