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://golang.org/cl/7312068
R=iant, bradfitz
CC=golang-dev, gri
https://golang.org/cl/7313062
diff --git a/test/cmp.go b/test/cmp.go
index a56ca6e..5be6456 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 @@
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 @@
isfalse(ix != z)
isfalse(iz != x)
}
-
+
// structs with _ fields
{
var x = struct {
@@ -296,7 +304,7 @@
x: 1, y: 2, z: 3,
}
var ix interface{} = x
-
+
istrue(x == x)
istrue(x == ix)
istrue(ix == x)