1 // build -goexperiment arenas
3 // Copyright 2023 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
21 i := arena.New[int](a)
25 // This test doesn't reasonably expect this to fail. It's more likely
26 // that *i crashes for some reason. Still, why not check it.
27 log.Fatalf("bad i value: got %d, want %d", *i, iValue)
33 sl := arena.MakeSlice[*int](a, wantLen, wantCap)
34 if len(sl) != wantLen {
35 log.Fatalf("bad arena slice length: got %d, want %d", len(sl), wantLen)
37 if cap(sl) != wantCap {
38 log.Fatalf("bad arena slice capacity: got %d, want %d", cap(sl), wantCap)
46 // This test doesn't reasonably expect this to fail. It's more likely
47 // that sl[j] crashes for some reason. Still, why not check it.
48 log.Fatalf("bad sl[j] value: got %d, want %d", *sl[j], iValue)
52 t := reflect.TypeOf(int(0))
53 v := reflect.ArenaNew(a, t)
54 if want := reflect.PointerTo(t); v.Type() != want {
55 log.Fatalf("unexpected type for arena-allocated value: got %s, want %s", v.Type(), want)
57 i2 := v.Interface().(*int)
61 // This test doesn't reasonably expect this to fail. It's more likely
62 // that *i crashes for some reason. Still, why not check it.
63 log.Fatalf("bad i2 value: got %d, want %d", *i2, iValue)