<commit_before>// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !race

package test

import (
	"testing"
)

func TestAppendOfMake(t *testing.T) {
	for n := 32; n < 33; n++ { // avoid stack allocation of make()
		b := make([]byte, n)
		f := func() {
			b = append(b[:0], make([]byte, n)...)
		}
		if n := testing.AllocsPerRun(10, f); n > 0 {
			t.Errorf("got %f allocs, want 0", n)
		}
		type S []byte

		s := make(S, n)
		g := func() {
			s = append(s[:0], make(S, n)...)
		}
		if n := testing.AllocsPerRun(10, g); n > 0 {
			t.Errorf("got %f allocs, want 0", n)
		}
		h := func() {
			s = append(s[:0], make([]byte, n)...)
		}
		if n := testing.AllocsPerRun(10, h); n > 0 {
			t.Errorf("got %f allocs, want 0", n)<commit_msg>cmd/compile: disable append of make test on noopt builder<commit_after>// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !race && !goexperiment.unified

package test

import (
	"internal/testenv"
	"strings"
	"testing"
)

// TODO(cuonglm,mdempsky): figure out why Unifed IR failed?
func TestAppendOfMake(t *testing.T) {
	if strings.HasSuffix(testenv.Builder(), "-noopt") {
		t.Skip("append of make optimization is disabled on noopt builder")
	}
	for n := 32; n < 33; n++ { // avoid stack allocation of make()
		b := make([]byte, n)
		f := func() {
			b = append(b[:0], make([]byte, n)...)
		}
		if n := testing.AllocsPerRun(10, f); n > 0 {
			t.Errorf("got %f allocs, want 0", n)
		}
		type S []byte

		s := make(S, n)
		g := func() {
			s = append(s[:0], make(S, n)...)
		}
		if n := testing.AllocsPerRun(10, g); n > 0 {
			t.Errorf("got %f allocs, want 0", n)
		}
		h := func() {
			s = append(s[:0], make([]byte, n)...)
		}
		if n := testing.AllocsPerRun(10, h); n > 0 {
			t.Errorf("got %f allocs, want 0", n)
{'fraction_non_alphanumeric': 0.18525996971226652, 'fraction_numerical': 0.023220595658758204, 'mean_word_length': 2.9325396825396823, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6979955', 'n_tokens_mistral': 842, 'n_tokens_neox': 751, 'n_words': 251}