From 3431aebb2cd825a67b02ce6dee4a9af251e42e05 Mon Sep 17 00:00:00 2001 From: Steven WdV Date: Sun, 20 Jul 2025 13:28:14 +0200 Subject: [PATCH] Add tests for accessing `!!str <<` --- pkg/yqlib/operator_anchors_aliases_test.go | 9 +++++++++ pkg/yqlib/operator_traverse_path_test.go | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/pkg/yqlib/operator_anchors_aliases_test.go b/pkg/yqlib/operator_anchors_aliases_test.go index 988af027..d66522c2 100644 --- a/pkg/yqlib/operator_anchors_aliases_test.go +++ b/pkg/yqlib/operator_anchors_aliases_test.go @@ -438,6 +438,15 @@ var anchorOperatorScenarios = []expressionScenario{ "D0, P[], (!!map)::{a: 1, a: 2}\n", }, }, + { + skipDoc: true, + description: "!!str << should not be treated as merge anchor", + document: `{!!str <<: {a: 37}}`, + expression: `explode(.).a`, + expected: []string{ + "D0, P[a], (!!null)::null\n", + }, + }, } func TestAnchorAliasOperatorScenarios(t *testing.T) { diff --git a/pkg/yqlib/operator_traverse_path_test.go b/pkg/yqlib/operator_traverse_path_test.go index 65ec97f9..0b29376c 100644 --- a/pkg/yqlib/operator_traverse_path_test.go +++ b/pkg/yqlib/operator_traverse_path_test.go @@ -631,6 +631,15 @@ var traversePathOperatorScenarios = []expressionScenario{ "D0, P[<<], (!!int)::37\n", }, }, + { + skipDoc: true, + description: "!!str << should not be treated as merge anchor", + document: `{!!str <<: {a: 37}}`, + expression: `.a`, + expected: []string{ + "D0, P[a], (!!null)::null\n", + }, + }, } func TestTraversePathOperatorScenarios(t *testing.T) {