"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tpl/internal/go_templates/fmtsort/sort_test.go" between
hugo-0.80.0.tar.gz and hugo-0.81.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

sort_test.go  (hugo-0.80.0):sort_test.go  (hugo-0.81.0)
skipping to change at line 14 skipping to change at line 14
package fmtsort_test package fmtsort_test
import ( import (
"fmt" "fmt"
"github.com/gohugoio/hugo/tpl/internal/go_templates/fmtsort" "github.com/gohugoio/hugo/tpl/internal/go_templates/fmtsort"
"math" "math"
"reflect" "reflect"
"strings" "strings"
"testing" "testing"
"unsafe"
) )
var compareTests = [][]reflect.Value{ var compareTests = [][]reflect.Value{
ct(reflect.TypeOf(int(0)), -1, 0, 1), ct(reflect.TypeOf(int(0)), -1, 0, 1),
ct(reflect.TypeOf(int8(0)), -1, 0, 1), ct(reflect.TypeOf(int8(0)), -1, 0, 1),
ct(reflect.TypeOf(int16(0)), -1, 0, 1), ct(reflect.TypeOf(int16(0)), -1, 0, 1),
ct(reflect.TypeOf(int32(0)), -1, 0, 1), ct(reflect.TypeOf(int32(0)), -1, 0, 1),
ct(reflect.TypeOf(int64(0)), -1, 0, 1), ct(reflect.TypeOf(int64(0)), -1, 0, 1),
ct(reflect.TypeOf(uint(0)), 0, 1, 5), ct(reflect.TypeOf(uint(0)), 0, 1, 5),
ct(reflect.TypeOf(uint8(0)), 0, 1, 5), ct(reflect.TypeOf(uint8(0)), 0, 1, 5),
skipping to change at line 35 skipping to change at line 36
ct(reflect.TypeOf(uint32(0)), 0, 1, 5), ct(reflect.TypeOf(uint32(0)), 0, 1, 5),
ct(reflect.TypeOf(uint64(0)), 0, 1, 5), ct(reflect.TypeOf(uint64(0)), 0, 1, 5),
ct(reflect.TypeOf(uintptr(0)), 0, 1, 5), ct(reflect.TypeOf(uintptr(0)), 0, 1, 5),
ct(reflect.TypeOf(string("")), "", "a", "ab"), ct(reflect.TypeOf(string("")), "", "a", "ab"),
ct(reflect.TypeOf(float32(0)), math.NaN(), math.Inf(-1), -1e10, 0, 1e10, math.Inf(1)), ct(reflect.TypeOf(float32(0)), math.NaN(), math.Inf(-1), -1e10, 0, 1e10, math.Inf(1)),
ct(reflect.TypeOf(float64(0)), math.NaN(), math.Inf(-1), -1e10, 0, 1e10, math.Inf(1)), ct(reflect.TypeOf(float64(0)), math.NaN(), math.Inf(-1), -1e10, 0, 1e10, math.Inf(1)),
ct(reflect.TypeOf(complex64(0+1i)), -1-1i, -1+0i, -1+1i, 0-1i, 0+0i, 0+1i , 1-1i, 1+0i, 1+1i), ct(reflect.TypeOf(complex64(0+1i)), -1-1i, -1+0i, -1+1i, 0-1i, 0+0i, 0+1i , 1-1i, 1+0i, 1+1i),
ct(reflect.TypeOf(complex128(0+1i)), -1-1i, -1+0i, -1+1i, 0-1i, 0+0i, 0+1 i, 1-1i, 1+0i, 1+1i), ct(reflect.TypeOf(complex128(0+1i)), -1-1i, -1+0i, -1+1i, 0-1i, 0+0i, 0+1 i, 1-1i, 1+0i, 1+1i),
ct(reflect.TypeOf(false), false, true), ct(reflect.TypeOf(false), false, true),
ct(reflect.TypeOf(&ints[0]), &ints[0], &ints[1], &ints[2]), ct(reflect.TypeOf(&ints[0]), &ints[0], &ints[1], &ints[2]),
ct(reflect.TypeOf(unsafe.Pointer(&ints[0])), unsafe.Pointer(&ints[0]), un safe.Pointer(&ints[1]), unsafe.Pointer(&ints[2])),
ct(reflect.TypeOf(chans[0]), chans[0], chans[1], chans[2]), ct(reflect.TypeOf(chans[0]), chans[0], chans[1], chans[2]),
ct(reflect.TypeOf(toy{}), toy{0, 1}, toy{0, 2}, toy{1, -1}, toy{1, 1}), ct(reflect.TypeOf(toy{}), toy{0, 1}, toy{0, 2}, toy{1, -1}, toy{1, 1}),
ct(reflect.TypeOf([2]int{}), [2]int{1, 1}, [2]int{1, 2}, [2]int{2, 0}), ct(reflect.TypeOf([2]int{}), [2]int{1, 1}, [2]int{1, 2}, [2]int{2, 0}),
ct(reflect.TypeOf(interface{}(interface{}(0))), iFace, 1, 2, 3), ct(reflect.TypeOf(interface{}(interface{}(0))), iFace, 1, 2, 3),
} }
var iFace interface{} var iFace interface{}
func ct(typ reflect.Type, args ...interface{}) []reflect.Value { func ct(typ reflect.Type, args ...interface{}) []reflect.Value {
value := make([]reflect.Value, len(args)) value := make([]reflect.Value, len(args))
skipping to change at line 122 skipping to change at line 124
}, },
{ {
chanMap(), chanMap(),
"CHAN0:0 CHAN1:1 CHAN2:2", "CHAN0:0 CHAN1:1 CHAN2:2",
}, },
{ {
pointerMap(), pointerMap(),
"PTR0:0 PTR1:1 PTR2:2", "PTR0:0 PTR1:1 PTR2:2",
}, },
{ {
unsafePointerMap(),
"UNSAFEPTR0:0 UNSAFEPTR1:1 UNSAFEPTR2:2",
},
{
map[toy]string{{7, 2}: "72", {7, 1}: "71", {3, 4}: "34"}, map[toy]string{{7, 2}: "72", {7, 1}: "71", {3, 4}: "34"},
"{3 4}:34 {7 1}:71 {7 2}:72", "{3 4}:34 {7 1}:71 {7 2}:72",
}, },
{ {
map[[2]int]string{{7, 2}: "72", {7, 1}: "71", {3, 4}: "34"}, map[[2]int]string{{7, 2}: "72", {7, 1}: "71", {3, 4}: "34"},
"[3 4]:34 [7 1]:71 [7 2]:72", "[3 4]:34 [7 1]:71 [7 2]:72",
}, },
} }
func sprint(data interface{}) string { func sprint(data interface{}) string {
skipping to change at line 162 skipping to change at line 168
func sprintKey(key reflect.Value) string { func sprintKey(key reflect.Value) string {
switch str := key.Type().String(); str { switch str := key.Type().String(); str {
case "*int": case "*int":
ptr := key.Interface().(*int) ptr := key.Interface().(*int)
for i := range ints { for i := range ints {
if ptr == &ints[i] { if ptr == &ints[i] {
return fmt.Sprintf("PTR%d", i) return fmt.Sprintf("PTR%d", i)
} }
} }
return "PTR???" return "PTR???"
case "unsafe.Pointer":
ptr := key.Interface().(unsafe.Pointer)
for i := range ints {
if ptr == unsafe.Pointer(&ints[i]) {
return fmt.Sprintf("UNSAFEPTR%d", i)
}
}
return "UNSAFEPTR???"
case "chan int": case "chan int":
c := key.Interface().(chan int) c := key.Interface().(chan int)
for i := range chans { for i := range chans {
if c == chans[i] { if c == chans[i] {
return fmt.Sprintf("CHAN%d", i) return fmt.Sprintf("CHAN%d", i)
} }
} }
return "CHAN???" return "CHAN???"
default: default:
return fmt.Sprint(key) return fmt.Sprint(key)
skipping to change at line 188 skipping to change at line 202
) )
func pointerMap() map[*int]string { func pointerMap() map[*int]string {
m := make(map[*int]string) m := make(map[*int]string)
for i := 2; i >= 0; i-- { for i := 2; i >= 0; i-- {
m[&ints[i]] = fmt.Sprint(i) m[&ints[i]] = fmt.Sprint(i)
} }
return m return m
} }
func unsafePointerMap() map[unsafe.Pointer]string {
m := make(map[unsafe.Pointer]string)
for i := 2; i >= 0; i-- {
m[unsafe.Pointer(&ints[i])] = fmt.Sprint(i)
}
return m
}
func chanMap() map[chan int]string { func chanMap() map[chan int]string {
m := make(map[chan int]string) m := make(map[chan int]string)
for i := 2; i >= 0; i-- { for i := 2; i >= 0; i-- {
m[chans[i]] = fmt.Sprint(i) m[chans[i]] = fmt.Sprint(i)
} }
return m return m
} }
type toy struct { type toy struct {
A int // Exported. A int // Exported.
 End of changes. 5 change blocks. 
0 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)