package main
+import "runtime"
+
var c = make(chan int)
func check(a []int) {
func newfunc() func(int) int { return func(x int) int { return x } }
func main() {
+ var fail bool
+
go f()
check([]int{1, 4, 5, 4})
go h()
check([]int{100, 200, 101, 201, 500, 101, 201, 500})
+ runtime.UpdateMemStats()
+ n0 := runtime.MemStats.Mallocs
+
x, y := newfunc(), newfunc()
if x(1) != 1 || y(2) != 2 {
println("newfunc returned broken funcs")
- panic("fail")
+ fail = true
+ }
+
+ runtime.UpdateMemStats()
+ if n0 != runtime.MemStats.Mallocs {
+ println("newfunc allocated unexpectedly")
+ fail = true
}
ff(1)
+
+ if fail {
+ panic("fail")
+ }
}
func ff(x int) {