1
2
3
4
5 package scan_test
6
7 import (
8 "internal/goarch"
9 "internal/runtime/gc"
10 "internal/runtime/gc/scan"
11 "testing"
12 )
13
14 type expandFunc func(sizeClass int, packed *gc.ObjMask, unpacked *gc.PtrMask)
15
16 func testExpand(t *testing.T, expF expandFunc) {
17 expR := scan.ExpandReference
18
19 testObjs(t, func(t *testing.T, sizeClass int, objs *gc.ObjMask) {
20 var want, got gc.PtrMask
21 expR(sizeClass, objs, &want)
22 expF(sizeClass, objs, &got)
23
24 for i := range want {
25 if got[i] != want[i] {
26 t.Errorf("expansion differs from reference at bit %d", i*goarch.PtrSize)
27 if goarch.PtrSize == 4 {
28 t.Logf("got: %032b", got[i])
29 t.Logf("want: %032b", want[i])
30 } else {
31 t.Logf("got: %064b", got[i])
32 t.Logf("want: %064b", want[i])
33 }
34 }
35 }
36 })
37 }
38
View as plain text