Fix ToMap for tables in nested mixed-type arrays (#461)

Co-authored-by: Micah Stetson <micah@schoolsplp.com>
This commit is contained in:
Thomas Pelletier
2021-01-06 20:34:25 -05:00
committed by GitHub
parent 2e01f733df
commit ba1b12be14
2 changed files with 39 additions and 19 deletions
+24 -3
View File
@@ -296,12 +296,33 @@ func TestTreeWriteToMapWithArrayOfInlineTables(t *testing.T) {
}
func TestTreeWriteToMapWithTableInMixedArray(t *testing.T) {
tree, _ := Load(`a = ["foo", {bar = "baz"}]`)
tree, _ := Load(`a = [
"foo",
[
"bar",
{baz = "quux"},
],
[
{a = "b"},
{c = "d"},
],
]`)
expected := map[string]interface{}{
"a": []interface{}{
"foo",
map[string]interface{}{
"bar": "baz",
[]interface{}{
"bar",
map[string]interface{}{
"baz": "quux",
},
},
[]interface{}{
map[string]interface{}{
"a": "b",
},
map[string]interface{}{
"c": "d",
},
},
},
}