Fix []*Toml.Tree being wrapped in *Toml.Value (#110)

Nodes can be either *Toml.Tree, []*Toml.Tree, or *Toml.Value.
Arrays of trees were incorrectly wrapped in a *Toml.Value,
making the conversion functions think they were leaf nodes.
This commit is contained in:
Thomas Pelletier
2016-11-23 15:48:39 +01:00
committed by GitHub
parent f7f14983c3
commit 3ddb37c944
2 changed files with 33 additions and 1 deletions
+32
View File
@@ -101,3 +101,35 @@ func TestTomlTreeConversionToMapWithTablesInMultipleChunks(t *testing.T) {
testMaps(t, treeMap, expected)
}
func TestTomlTreeConversionToMapWithArrayOfInlineTables(t *testing.T) {
tree, _ := Load(`
[params]
language_tabs = [
{ key = "shell", name = "Shell" },
{ key = "ruby", name = "Ruby" },
{ key = "python", name = "Python" }
]`)
expected := map[string]interface{}{
"params": map[string]interface{}{
"language_tabs": []interface{}{
map[string]interface{}{
"key": "shell",
"name": "Shell",
},
map[string]interface{}{
"key": "ruby",
"name": "Ruby",
},
map[string]interface{}{
"key": "python",
"name": "Python",
},
},
},
}
treeMap := tree.ToMap()
testMaps(t, treeMap, expected)
}