Support lists of deeply marked values

This commit is contained in:
Pam Selle 2020-09-25 13:33:44 -04:00
parent 3dde9efc75
commit 0b3c21a3eb
2 changed files with 17 additions and 2 deletions

View File

@ -26,8 +26,8 @@ func LongestCommonSubsequence(xs, ys []cty.Value) []cty.Value {
for y := 0; y < len(ys); y++ {
for x := 0; x < len(xs); x++ {
unmarkedX, xMarks := xs[x].Unmark()
unmarkedY, yMarks := ys[y].Unmark()
unmarkedX, xMarks := xs[x].UnmarkDeep()
unmarkedY, yMarks := ys[y].UnmarkDeep()
eqV := unmarkedX.Equals(unmarkedY)
if len(xMarks) != len(yMarks) {
eqV = cty.False

View File

@ -87,6 +87,21 @@ func TestLongestCommonSubsequence(t *testing.T) {
[]cty.Value{cty.NumberIntVal(2)},
[]cty.Value{},
},
{
[]cty.Value{
cty.MapVal(map[string]cty.Value{"a": cty.StringVal("x").Mark("sensitive")}),
cty.MapVal(map[string]cty.Value{"b": cty.StringVal("y")}),
},
[]cty.Value{
cty.MapVal(map[string]cty.Value{"a": cty.StringVal("x").Mark("sensitive")}),
cty.MapVal(map[string]cty.Value{"b": cty.StringVal("y")}),
cty.MapVal(map[string]cty.Value{"c": cty.StringVal("z")}),
},
[]cty.Value{
cty.MapVal(map[string]cty.Value{"a": cty.StringVal("x").Mark("sensitive")}),
cty.MapVal(map[string]cty.Value{"b": cty.StringVal("y")}),
},
},
}
for _, test := range tests {