aboutsummaryrefslogtreecommitdiff
path: root/test/convert.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-03-12 19:04:38 -0700
committerRuss Cox <rsc@golang.org>2009-03-12 19:04:38 -0700
commit8f194bf5ff15e3f62ce02669bf48d54a6342260e (patch)
tree215ba82d2713550ef0ead44a627dd78579275bfa /test/convert.go
parent9b5d82327b1498b74611d539f9812d3cce13cbc3 (diff)
downloadgo-8f194bf5ff15e3f62ce02669bf48d54a6342260e.tar.gz
go-8f194bf5ff15e3f62ce02669bf48d54a6342260e.zip
make 6g constants behave as ken proposes. (i hope.)
various bug fixes and tests involving constants. test/const1.go is the major new test case. R=ken OCL=26216 CL=26224
Diffstat (limited to 'test/convert.go')
-rw-r--r--test/convert.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/convert.go b/test/convert.go
new file mode 100644
index 0000000000..11369e5211
--- /dev/null
+++ b/test/convert.go
@@ -0,0 +1,53 @@
+// $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
+
+import "unsafe"
+
+func typeof(x interface{}) string {
+ val, typ, indir := sys.Reflect(x);
+ return typ;
+}
+
+func f() int {
+ return 0;
+}
+
+func g() int {
+ return 0;
+}
+
+type T func() int
+
+var m = map[string] T {
+ "f": f
+}
+
+type A int
+type B int
+
+var a A = 1;
+var b B = 2;
+var x int;
+
+func main() {
+ want := typeof(g);
+ if t := typeof(f); t != want {
+ panicln("type of f is", t, "want", want);
+ }
+
+ want = typeof(x);
+ if t := typeof(+a); t != want {
+ panicln("type of +a is", t, "want", want);
+ }
+ if t := typeof(a+0); t != want {
+ panicln("type of a+0 is", t, "want", want);
+ }
+ if t := typeof(a+b); t != want {
+ panicln("type of a+b is", t, "want", want);
+ }
+}