aboutsummaryrefslogtreecommitdiff
path: root/test/stack.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-02-06 13:46:56 -0800
committerRuss Cox <rsc@golang.org>2009-02-06 13:46:56 -0800
commit0f4f2a61836bba7dadb0cbdd00dfa53ba549555e (patch)
treeb8e48ca2a3b0f4983102041168ebc81244a713e8 /test/stack.go
parent187cf78a7c2fff4c1f606dacc412d5dda84f45b2 (diff)
downloadgo-0f4f2a61836bba7dadb0cbdd00dfa53ba549555e.tar.gz
go-0f4f2a61836bba7dadb0cbdd00dfa53ba549555e.zip
closures - runtime and debugger support, test case
R=r DELTA=257 (250 added, 1 deleted, 6 changed) OCL=24509 CL=24565
Diffstat (limited to 'test/stack.go')
-rw-r--r--test/stack.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/stack.go b/test/stack.go
index 9fecc9102c..7b7d36f916 100644
--- a/test/stack.go
+++ b/test/stack.go
@@ -5,7 +5,7 @@
// license that can be found in the LICENSE file.
// Try to tickle stack splitting bugs by doing
-// go and defer at different stack depths.
+// go, defer, and closure calls at different stack depths.
package main
@@ -38,6 +38,18 @@ func recur(n int) {
if s != len(t) {
panicln("bad go", s);
}
+ f := func(t T) int {
+ s := 0;
+ for i := 0; i < len(t); i++ {
+ s += t[i];
+ }
+ s += n;
+ return s;
+ };
+ s = f(t);
+ if s != len(t) + n {
+ panicln("bad func", s, "at level", n);
+ }
if n > 0 {
recur(n-1);
}