summaryrefslogtreecommitdiff
path: root/test/cmp.go
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2013-02-21 12:48:38 -0500
committerAlan Donovan <adonovan@google.com>2013-02-21 12:48:38 -0500
commit37563c63db1c49edacad86f5425dac22460a3801 (patch)
tree4d5f1e465b65537ec34a567318d1fa3d892c198f /test/cmp.go
parentf9ec488696969c8b3cc1fbf4e15306d6b358346c (diff)
downloadgo-37563c63db1c49edacad86f5425dac22460a3801.tar.gz
exp/ssa/interp: (#6 of 5): test interpretation of SSA form of $GOROOT/test/*.go.
The interpreter's os.Exit now triggers a special panic rather than kill the test process. (It's semantically dubious, since it will run deferred routines.) Interpret now returns its exit code rather than calling os.Exit. Also: - disabled parts of a few $GOROOT/tests via os.Getenv("GOSSAINTERP"). - remove unnecessary 'slots' param to external functions; they are never closures. Most of the tests are disabled until go/types supports shifts. They can be reenabled if you patch this workaround: https://codereview.appspot.com/7312068 R=iant, bradfitz CC=golang-dev, gri https://codereview.appspot.com/7313062
Diffstat (limited to 'test/cmp.go')
-rw-r--r--test/cmp.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/cmp.go b/test/cmp.go
index a56ca6ead..5be64561d 100644
--- a/test/cmp.go
+++ b/test/cmp.go
@@ -8,9 +8,13 @@
package main
-import "unsafe"
+import (
+ "os"
+ "unsafe"
+)
var global bool
+
func use(b bool) { global = b }
func stringptr(s string) uintptr { return *(*uintptr)(unsafe.Pointer(&s)) }
@@ -38,8 +42,12 @@ func main() {
var c string = "hello"
var d string = "hel" // try to get different pointer
d = d + "lo"
- if stringptr(c) == stringptr(d) {
- panic("compiler too smart -- got same string")
+
+ // exp/ssa/interp can't handle unsafe.Pointer.
+ if os.Getenv("GOSSAINTERP") != "" {
+ if stringptr(c) == stringptr(d) {
+ panic("compiler too smart -- got same string")
+ }
}
var e = make(chan int)
@@ -283,7 +291,7 @@ func main() {
isfalse(ix != z)
isfalse(iz != x)
}
-
+
// structs with _ fields
{
var x = struct {
@@ -296,7 +304,7 @@ func main() {
x: 1, y: 2, z: 3,
}
var ix interface{} = x
-
+
istrue(x == x)
istrue(x == ix)
istrue(ix == x)