transform: restore previous test behavior

I think it's much nicer to have the test output inline in the source
file, that way it's much easier to review any changes. For example, when
escape analysis is improved this is visible with removed `// OUT` lines.

This is similar to how LLVM writes its tests, and I like that style.
This commit is contained in:
Ayke van Laethem
2026-06-24 18:54:44 +02:00
committed by Ron Evans
parent 134de98ba5
commit df09dbdf0f
4 changed files with 56 additions and 51 deletions
+11 -11
View File
@@ -21,19 +21,19 @@ func main() {
s3 := make([]int, 3)
returnIntSlice(s3)
useSlice(make([]int, getUnknownNumber()))
useSlice(make([]int, getUnknownNumber())) // OUT: size is not constant
s4 := make([]byte, 300)
s4 := make([]byte, 300) // OUT: object size 300 exceeds maximum stack allocation size 256
readByteSlice(s4)
s5 := make([]int, 4)
s5 := make([]int, 4) // OUT: escapes at line 30
_ = append(s5, 5)
s6 := make([]int, 3)
s7 := []int{1, 2, 3}
copySlice(s6, s7)
c1 := getComplex128()
c1 := getComplex128() // OUT: escapes at line 37
useInterface(c1)
n3 := 5
@@ -41,13 +41,13 @@ func main() {
return n3
}()
callVariadic(3, 5, 8)
callVariadic(3, 5, 8) // OUT: escapes at line 44
s8 := []int{3, 5, 8}
s8 := []int{3, 5, 8} // OUT: escapes at line 47
callVariadic(s8...)
n4 := 3
n5 := 7
n4 := 3 // OUT: escapes at line 51
n5 := 7 // OUT: escapes at line 51
func() {
n4 = n5
}()
@@ -104,14 +104,14 @@ func nonEscapingReturnedPointer() vector3 {
var escapedSlice []int
func escapingReturnedSlice() {
s := make([]int, 3)
s := make([]int, 3) // OUT: escapes at line 108
escapedSlice = returnIntSlice(s)
}
var escapedVector3 *vector3
func escapingReturnedPointer() {
b := vector3{4, 5, 6}
b := vector3{4, 5, 6} // OUT: escapes at line 117
c := scaleVector3(&b, 0.5)
escapedVector3 = c
@@ -125,7 +125,7 @@ func recursiveScaleVector3(vec *vector3, n int) *vector3 {
}
func recursiveReturnedPointer() vector3 {
b := vector3{4, 5, 6}
b := vector3{4, 5, 6} // OUT: escapes at unknown line
c := recursiveScaleVector3(&b, 1)
return *c
+11 -11
View File
@@ -1,11 +1,11 @@
testdata/allocs2.go:24.1,24.43 1 0
testdata/allocs2.go:26.1,26.25 1 0
testdata/allocs2.go:29.1,29.22 1 0
testdata/allocs2.go:36.1,36.23 1 0
testdata/allocs2.go:44.1,44.23 1 0
testdata/allocs2.go:46.1,46.22 1 0
testdata/allocs2.go:49.1,49.9 1 0
testdata/allocs2.go:50.1,50.9 1 0
testdata/allocs2.go:107.1,107.21 1 0
testdata/allocs2.go:114.1,114.23 1 0
testdata/allocs2.go:128.1,128.23 1 0
testdata/allocs2.go:24.1,24.72 1 0
testdata/allocs2.go:26.1,26.91 1 0
testdata/allocs2.go:29.1,29.49 1 0
testdata/allocs2.go:36.1,36.50 1 0
testdata/allocs2.go:44.1,44.50 1 0
testdata/allocs2.go:46.1,46.49 1 0
testdata/allocs2.go:49.1,49.36 1 0
testdata/allocs2.go:50.1,50.36 1 0
testdata/allocs2.go:107.1,107.49 1 0
testdata/allocs2.go:114.1,114.51 1 0
testdata/allocs2.go:128.1,128.55 1 0
-11
View File
@@ -1,11 +0,0 @@
testdata/allocs2.go:24:15: object allocated on the heap: size is not constant
testdata/allocs2.go:26:12: object allocated on the heap: object size 300 exceeds maximum stack allocation size 256
testdata/allocs2.go:29:12: object allocated on the heap: escapes at line 30
testdata/allocs2.go:36:21: object allocated on the heap: escapes at line 37
testdata/allocs2.go:44:22: object allocated on the heap: escapes at line 44
testdata/allocs2.go:46:13: object allocated on the heap: escapes at line 47
testdata/allocs2.go:49:2: object allocated on the heap: escapes at line 51
testdata/allocs2.go:50:2: object allocated on the heap: escapes at line 51
testdata/allocs2.go:107:11: object allocated on the heap: escapes at line 108
testdata/allocs2.go:114:2: object allocated on the heap: escapes at line 117
testdata/allocs2.go:128:2: object allocated on the heap: escapes at unknown line