Fixing HCL non string key issue #2795

This commit is contained in:
Mike Farah
2026-08-19 13:50:42 +10:00
parent 5c302ee313
commit 6a182b6a30
3 changed files with 39 additions and 6 deletions
+35
View File
@@ -176,6 +176,41 @@ var hclFormatScenarios = []formatScenario{
expected: "obj: {a: 1, b: \"two\"}\n",
scenarioType: "decode",
},
{
description: "object with integer keys",
skipDoc: true,
input: `obj = { 1 = "one", 2 = "two" }`,
expected: "obj: {1: \"one\", 2: \"two\"}\n",
scenarioType: "decode",
},
{
description: "object with boolean keys",
skipDoc: true,
input: `obj = { (true) = "yes", (false) = "no" }`,
expected: "obj: {true: \"yes\", false: \"no\"}\n",
scenarioType: "decode",
},
{
description: "object with float keys",
skipDoc: true,
input: `obj = { (3.14) = "pi" }`,
expected: "obj: {3.14: \"pi\"}\n",
scenarioType: "decode",
},
{
description: "object with mixed scalar keys",
skipDoc: true,
input: `obj = { a = 1, 1 = "one", (true) = "yes" }`,
expected: "obj: {a: 1, 1: \"one\", true: \"yes\"}\n",
scenarioType: "decode",
},
{
description: "nested object with integer keys",
skipDoc: true,
input: `config = { levels = { 1 = "debug", 2 = "info" } }`,
expected: "config: {levels: {1: \"debug\", 2: \"info\"}}\n",
scenarioType: "decode",
},
{
description: "nested block",
skipDoc: true,