wip
This commit is contained in:
+6
-1
@@ -240,7 +240,12 @@ func scopeTableTarget(append bool, t target, name string) (target, error) {
|
||||
case reflect.Map:
|
||||
return scopeMap(x, name)
|
||||
case reflect.Slice:
|
||||
return scopeSlice(append, t)
|
||||
t, err := scopeSlice(append, t)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
append = false
|
||||
return scopeTableTarget(append, t, name)
|
||||
default:
|
||||
panic(fmt.Errorf("can't scope on a %s", x.Kind()))
|
||||
}
|
||||
|
||||
@@ -452,6 +452,76 @@ B = "data"`,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "sub-table in array table",
|
||||
input: `[[Fruits]]
|
||||
Name = "apple"
|
||||
|
||||
[Fruits.Physical] # subtable
|
||||
Color = "red"
|
||||
Shape = "round"`,
|
||||
gen: func() test {
|
||||
return test{
|
||||
target: &map[string]interface{}{},
|
||||
expected: &map[string]interface{}{
|
||||
"Fruits": []interface{}{
|
||||
map[string]interface{}{
|
||||
"Name": "apple",
|
||||
"Physical": map[string]interface{}{
|
||||
"Color": "red",
|
||||
"Shape": "round",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "multiple sub-table in array tables",
|
||||
input: `[[Fruits]]
|
||||
Name = "apple"
|
||||
|
||||
[[Fruits.Varieties]] # nested array of tables
|
||||
Name = "red delicious"
|
||||
|
||||
[[Fruits.Varieties]]
|
||||
Name = "granny smith"
|
||||
|
||||
[[Fruits]]
|
||||
Name = "banana"
|
||||
|
||||
[[Fruits.Varieties]]
|
||||
Name = "plantain"`,
|
||||
gen: func() test {
|
||||
return test{
|
||||
target: &map[string]interface{}{},
|
||||
expected: &map[string]interface{}{
|
||||
"Fruits": []interface{}{
|
||||
map[string]interface{}{
|
||||
"Name": "apple",
|
||||
"Varieties": []interface{}{
|
||||
map[string]interface{}{
|
||||
"Name": "red delicious",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"Name": "granny smith",
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"Name": "banana",
|
||||
"Varieties": []interface{}{
|
||||
map[string]interface{}{
|
||||
"Name": "plantain",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, e := range examples {
|
||||
|
||||
Reference in New Issue
Block a user