diff --git a/pkg/yqlib/doc/Traverse.md b/pkg/yqlib/doc/Traverse.md index 5718cc14..b08ae705 100644 --- a/pkg/yqlib/doc/Traverse.md +++ b/pkg/yqlib/doc/Traverse.md @@ -106,7 +106,7 @@ b: *cat ``` then ```bash -yq eval '.b.[]' sample.yml +yq eval '.b[]' sample.yml ``` will output ```yaml @@ -290,7 +290,7 @@ foobar: ``` then ```bash -yq eval '.foobar.[]' sample.yml +yq eval '.foobar[]' sample.yml ``` will output ```yaml @@ -356,7 +356,7 @@ foobar: ``` then ```bash -yq eval '.foobarList.[]' sample.yml +yq eval '.foobarList[]' sample.yml ``` will output ```yaml diff --git a/pkg/yqlib/operator_traverse_path_test.go b/pkg/yqlib/operator_traverse_path_test.go index a58a8d62..9d4a44a3 100644 --- a/pkg/yqlib/operator_traverse_path_test.go +++ b/pkg/yqlib/operator_traverse_path_test.go @@ -137,7 +137,15 @@ var traversePathOperatorScenarios = []expressionScenario{ { description: "Traversing aliases with splat", document: `{a: &cat {c: frog}, b: *cat}`, - expression: `.b.[]`, + expression: `.b[]`, + expected: []string{ + "D0, P[b c], (!!str)::frog\n", + }, + }, + { + skipDoc: true, + document: `{a: &cat {c: frog}, b: *cat}`, + expression: `.b.[]`, expected: []string{ "D0, P[b c], (!!str)::frog\n", }, @@ -209,7 +217,17 @@ var traversePathOperatorScenarios = []expressionScenario{ { description: "Splatting merge anchors", document: mergeDocSample, - expression: `.foobar.[]`, + expression: `.foobar[]`, + expected: []string{ + "D0, P[foobar c], (!!str)::foo_c\n", + "D0, P[foobar a], (!!str)::foo_a\n", + "D0, P[foobar thing], (!!str)::foobar_thing\n", + }, + }, + { + skipDoc: true, + document: mergeDocSample, + expression: `.foobar.[]`, expected: []string{ "D0, P[foobar c], (!!str)::foo_c\n", "D0, P[foobar a], (!!str)::foo_a\n", @@ -260,7 +278,18 @@ var traversePathOperatorScenarios = []expressionScenario{ { description: "Splatting merge anchor lists", document: mergeDocSample, - expression: `.foobarList.[]`, + expression: `.foobarList[]`, + expected: []string{ + "D0, P[foobarList b], (!!str)::bar_b\n", + "D0, P[foobarList a], (!!str)::foo_a\n", + "D0, P[foobarList thing], (!!str)::bar_thing\n", + "D0, P[foobarList c], (!!str)::foobarList_c\n", + }, + }, + { + skipDoc: true, + document: mergeDocSample, + expression: `.foobarList.[]`, expected: []string{ "D0, P[foobarList b], (!!str)::bar_b\n", "D0, P[foobarList a], (!!str)::foo_a\n",