Skip to content

Commit

Permalink
reflect: test repeats with large scalar tails
Browse files Browse the repository at this point in the history
This adds a GC bitmap test of a type with many pointer bits and a
large scalar tail, such as the one in issue #11286. This test would
have failed prior to the fix in a8ae93f. This test is a more direct
version of the test introduced in that commit (which was distilled
from the failing test in the issue).

Change-Id: I2e716cd1000b49bde237f5da6d857e8983fe7e7a
Reviewed-on: https://go-review.googlesource.com/11423
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
aclements committed Jun 26, 2015
1 parent 4b28755 commit e0e47e2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/reflect/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4571,8 +4571,12 @@ func TestGCBits(t *testing.T) {
uintptr
*byte
}
type Xbigptrscalar struct {
_ [100]*byte
_ [100]uintptr
}

var Tscalar, Tptr, Tscalarptr, Tptrscalar Type
var Tscalar, Tptr, Tscalarptr, Tptrscalar, Tbigptrscalar Type
{
// Building blocks for types constructed by reflect.
// This code is in a separate block so that code below
Expand All @@ -4591,10 +4595,15 @@ func TestGCBits(t *testing.T) {
uintptr
*byte
}
type Bigptrscalar struct {
_ [100]*byte
_ [100]uintptr
}
Tscalar = TypeOf(Scalar{})
Tptr = TypeOf(Ptr{})
Tscalarptr = TypeOf(Scalarptr{})
Tptrscalar = TypeOf(Ptrscalar{})
Tbigptrscalar = TypeOf(Bigptrscalar{})
}

empty := []byte{}
Expand Down Expand Up @@ -4632,6 +4641,8 @@ func TestGCBits(t *testing.T) {
verifyGCBits(t, ArrayOf(1, ArrayOf(10000, Tptrscalar)), rep(10000, lit(1, 0)))
verifyGCBits(t, TypeOf([2][10000]Xptrscalar{}), rep(2*10000, lit(1, 0)))
verifyGCBits(t, ArrayOf(2, ArrayOf(10000, Tptrscalar)), rep(2*10000, lit(1, 0)))
verifyGCBits(t, TypeOf([4]Xbigptrscalar{}), join(rep(3, join(rep(100, lit(1)), rep(100, lit(0)))), rep(100, lit(1))))
verifyGCBits(t, ArrayOf(4, Tbigptrscalar), join(rep(3, join(rep(100, lit(1)), rep(100, lit(0)))), rep(100, lit(1))))

verifyGCBitsSlice(t, TypeOf([]Xptr{}), 0, empty)
verifyGCBitsSlice(t, SliceOf(Tptr), 0, empty)
Expand All @@ -4657,6 +4668,8 @@ func TestGCBits(t *testing.T) {
verifyGCBitsSlice(t, SliceOf(ArrayOf(10000, Tptrscalar)), 1, rep(10000, lit(1, 0)))
verifyGCBitsSlice(t, TypeOf([][10000]Xptrscalar{}), 2, rep(10000, lit(1, 0)))
verifyGCBitsSlice(t, SliceOf(ArrayOf(10000, Tptrscalar)), 2, rep(10000, lit(1, 0)))
verifyGCBitsSlice(t, TypeOf([]Xbigptrscalar{}), 4, join(rep(100, lit(1)), rep(100, lit(0))))
verifyGCBitsSlice(t, SliceOf(Tbigptrscalar), 4, join(rep(100, lit(1)), rep(100, lit(0))))

verifyGCBits(t, TypeOf((chan [100]Xscalar)(nil)), lit(1))
verifyGCBits(t, ChanOf(BothDir, ArrayOf(100, Tscalar)), lit(1))
Expand Down

0 comments on commit e0e47e2

Please sign in to comment.