diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/closure.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/closure.go b/test/closure.go index 97361a1df..8bb516d29 100644 --- a/test/closure.go +++ b/test/closure.go @@ -73,6 +73,10 @@ func h() { f(500); } +func newfunc() (func(int) int) { + return func(x int) int { return x } +} + func main() { go f(); @@ -85,4 +89,12 @@ func main() { go h(); check([]int{100,200,101,201,500,101,201,500}); + + x, y := newfunc(), newfunc(); + if x == y { + panicln("newfunc returned same func"); + } + if x(1) != 1 || y(2) != 2 { + panicln("newfunc returned broken funcs"); + } } |