summaryrefslogtreecommitdiff
path: root/test/iota.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2008-06-06 13:28:03 -0700
committerRob Pike <r@golang.org>2008-06-06 13:28:03 -0700
commita680dbdfffda9c49d77447312e6dd000db3592bb (patch)
tree9fc78195cd6f45b370bba69597b64afd6e0f7bb3 /test/iota.go
parent8b253a1f55765e07b98d1f32e3f6d704fd69f956 (diff)
downloadgo-a680dbdfffda9c49d77447312e6dd000db3592bb.tar.gz
lots of new tests
SVN=121464
Diffstat (limited to 'test/iota.go')
-rw-r--r--test/iota.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/iota.go b/test/iota.go
new file mode 100644
index 000000000..22cf876bb
--- /dev/null
+++ b/test/iota.go
@@ -0,0 +1,30 @@
+// $G $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
+
+func assert(cond bool, msg string) {
+ if !cond {
+ print "assertion fail: ", msg, "\n";
+ panic 1;
+ }
+}
+
+const (
+ x int = iota;
+ y = iota;
+ z = 1 << iota;
+ f float = 2 * iota;
+ g float = 4.5 * float(iota);
+);
+
+func main() {
+ assert(x == 0, "x");
+ assert(y == 1, "y");
+ assert(z == 4, "z");
+ assert(f == 6.0, "f");
+ assert(g == 18.0, "g");
+}