summaryrefslogtreecommitdiff
path: root/test/ken/ptrvar.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2008-06-06 14:27:34 -0700
committerRob Pike <r@golang.org>2008-06-06 14:27:34 -0700
commitf47dd1a887306dbc45a43701b92a93b9ca3cd10a (patch)
tree22e573d0f4432512779320404d5df24503fc4919 /test/ken/ptrvar.go
parentbaa3be75b8d3039bd88eab7951096319655a5d45 (diff)
downloadgolang-f47dd1a887306dbc45a43701b92a93b9ca3cd10a.tar.gz
add ken's tests.
update run to work with multiple directories SVN=121485
Diffstat (limited to 'test/ken/ptrvar.go')
-rw-r--r--test/ken/ptrvar.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/ken/ptrvar.go b/test/ken/ptrvar.go
new file mode 100644
index 000000000..c2e2d611d
--- /dev/null
+++ b/test/ken/ptrvar.go
@@ -0,0 +1,54 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+
+package main
+
+type x2 struct { a,b,c int; d int; };
+var g1 x2;
+var g2 struct { a,b,c int; d x2; };
+
+func
+main()
+{
+ var x int;
+ var s1 *x2;
+ var s2 *struct { a,b,c int; d x2; };
+
+ s1 = &g1;
+ s2 = &g2;
+
+ s1.a = 1;
+ s1.b = 2;
+ s1.c = 3;
+ s1.d = 5;
+
+ s2.a = 7;
+ s2.b = 11;
+ s2.c = 13;
+ s2.d.a = 17;
+ s2.d.b = 19;
+ s2.d.c = 23;
+ s2.d.d = 20;
+
+ if(s2.d.c != 23) { panic 1; }
+ if(g2.d.c != 23) { panic 2; }
+
+ x = s1.a +
+ s1.b +
+ s1.c +
+ s1.d +
+
+ s2.a +
+ s2.b +
+ s2.c +
+ s2.d.a +
+ s2.d.b +
+ s2.d.c +
+ s2.d.d;
+
+ if(x != 121) { panic x; }
+}