From b025000f2065d1f5ae7c1ee416fb24effba0a299 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sun, 11 Oct 2020 11:46:07 +1100 Subject: [PATCH] cool, both work --- pkg/yqlib/treeops/data_tree_navigator_test.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pkg/yqlib/treeops/data_tree_navigator_test.go b/pkg/yqlib/treeops/data_tree_navigator_test.go index b882ccf5..7d87ebf9 100644 --- a/pkg/yqlib/treeops/data_tree_navigator_test.go +++ b/pkg/yqlib/treeops/data_tree_navigator_test.go @@ -637,6 +637,37 @@ func TestDataTreeNavigatorArrayEqualsSelf(t *testing.T) { test.AssertResult(t, expected, resultsToString(results)) } +func TestDataTreeNavigatorArrayEqualsSelfSplatFirst(t *testing.T) { + + nodes := readDoc(t, `- cat +- dog +- frog`) + + path, errPath := treeCreator.ParsePath("*(. == *og)") + if errPath != nil { + t.Error(errPath) + } + results, errNav := treeNavigator.GetMatchingNodes(nodes, path) + + if errNav != nil { + t.Error(errNav) + } + + expected := ` +-- Node -- + Document 0, path: [1] + Tag: !!str, Kind: ScalarNode, Anchor: + dog + +-- Node -- + Document 0, path: [2] + Tag: !!str, Kind: ScalarNode, Anchor: + frog +` + + test.AssertResult(t, expected, resultsToString(results)) +} + func TestDataTreeNavigatorArrayEquals(t *testing.T) { nodes := readDoc(t, `- { b: apple, animal: rabbit }