summaryrefslogtreecommitdiffhomepage
path: root/tpl/collections
diff options
context:
space:
mode:
authorCameron Moore <[email protected]>2017-05-21 21:10:27 -0500
committerBjørn Erik Pedersen <[email protected]>2017-06-08 21:01:15 +0200
commitb82cd82f1198a371ed94bda7faafe22813f4cb29 (patch)
tree7f074385bfc31ad75b7fea7f4d01211aaf448d8b /tpl/collections
parent204c3a9e32fcf6617ede978e35d3e2e89a5b491c (diff)
downloadhugo-b82cd82f1198a371ed94bda7faafe22813f4cb29.tar.gz
hugo-b82cd82f1198a371ed94bda7faafe22813f4cb29.zip
tpl/collections: Add uint support to In
Diffstat (limited to 'tpl/collections')
-rw-r--r--tpl/collections/collections.go8
-rw-r--r--tpl/collections/collections_test.go4
2 files changed, 10 insertions, 2 deletions
diff --git a/tpl/collections/collections.go b/tpl/collections/collections.go
index 5d2cf3b35..06ed788ca 100644
--- a/tpl/collections/collections.go
+++ b/tpl/collections/collections.go
@@ -261,6 +261,13 @@ func (ns *Namespace) In(l interface{}, v interface{}) bool {
return true
}
}
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ switch vv.Kind() {
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ if vv.Uint() == lvv.Uint() {
+ return true
+ }
+ }
case reflect.Float32, reflect.Float64:
switch vv.Kind() {
case reflect.Float32, reflect.Float64:
@@ -564,7 +571,6 @@ func (ns *Namespace) Union(l1, l2 interface{}) (interface{}, error) {
if l1v.Type() != l2v.Type() &&
l1v.Type().Elem().Kind() != reflect.Interface &&
l2v.Type().Elem().Kind() != reflect.Interface {
-
return r.Interface(), nil
}
diff --git a/tpl/collections/collections_test.go b/tpl/collections/collections_test.go
index 811cb4c87..52b4cdf59 100644
--- a/tpl/collections/collections_test.go
+++ b/tpl/collections/collections_test.go
@@ -298,6 +298,7 @@ func TestIntersect(t *testing.T) {
{[]interface{}{int16(1), int16(2), int16(3)}, []int16{1, 2, 2}, []interface{}{int16(1), int16(2)}},
{[]interface{}{int32(1), int32(2), int32(3)}, []int32{1, 2, 2}, []interface{}{int32(1), int32(2)}},
{[]interface{}{int64(1), int64(2), int64(3)}, []int64{1, 2, 2}, []interface{}{int64(1), int64(2)}},
+ {[]interface{}{uint(1), uint(2), uint(3)}, []uint{1, 2, 2}, []interface{}{uint(1), uint(2)}},
{[]interface{}{float32(1), float32(2), float32(3)}, []float32{1, 2, 2}, []interface{}{float32(1), float32(2)}},
{[]interface{}{float64(1), float64(2), float64(3)}, []float64{1, 2, 2}, []interface{}{float64(1), float64(2)}},
@@ -604,10 +605,11 @@ func TestUnion(t *testing.T) {
{[]float32{2.2, 4.4}, []interface{}{1.1, 2.2, 4.4}, []float32{2.2, 4.4, 1.1}, false},
// []interface{} ∪ []T
- {[]interface{}{"a", "b", "c", "c"}, []string{"a", "b", "b"}, []interface{}{"a", "b", "c"}, false},
+ {[]interface{}{"a", "b", "c", "c"}, []string{"a", "b", "d"}, []interface{}{"a", "b", "c", "d"}, false},
{[]interface{}{}, []string{}, []interface{}{}, false},
{[]interface{}{1, 2}, []int{2, 3}, []interface{}{1, 2, 3}, false},
{[]interface{}{1, 2}, []int8{2, 3}, []interface{}{1, 2, int8(3)}, false},
+ {[]interface{}{uint(1), uint(2)}, []uint{2, 3}, []interface{}{uint(1), uint(2), uint(3)}, false},
{[]interface{}{1.1, 2.2}, []float64{2.2, 3.3}, []interface{}{1.1, 2.2, 3.3}, false},
// errors