Skip to content

tpl: intersect needs some love #1952

@moorereason

Description

@moorereason

The following test cases fail when added to tpl/template_funcs_test.go:TestIntersect:

{[]string{"a", "b", "c"}, []string{"a", "b", "b"}, []string{"a", "b"}},
{[]interface{}{"a", "b", "c"}, []interface{}{"a", "b", "b"}, []interface{}{"a", "b"}},

Test results:

--- FAIL: TestIntersect (0.00s)
        template_funcs_test.go:791: [0] got [a b b] but expected [a b]
        template_funcs_test.go:791: [1] got [] but expected [a b]

Regarding test 0, in is used by intersect to avoid adding duplicates to the new set. In this case, in is receiving a reflect.Value struct, but the reflect.Struct case is not handled by in.

Regarding test 1, intersect does not handle the reflect.Interface case. See Questions about "intersect" function forum discussion.

Tests were done in Go 1.6 and Hugo HEAD.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions