summaryrefslogtreecommitdiff
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
commit39ff860d8973ec9388d29d4206c2f63e1c3e3dcb (patch)
treeb8e48ca2a3b0f4983102041168ebc81244a713e8 /test/stack.go
parentdefac22beba1644c0197e43df5ba7b0e2c305cf5 (diff)
downloadgo-39ff860d8973ec9388d29d4206c2f63e1c3e3dcb.tar.gz
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 9fecc9102..7b7d36f91 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);
}