Source file src/internal/runtime/maps/mapaccess1_inline_test.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package maps_test
     6  
     7  import (
     8  	"fmt"
     9  	"internal/testenv"
    10  	"os/exec"
    11  	"strings"
    12  	"testing"
    13  )
    14  
    15  func TestInline(t *testing.T) {
    16  	testenv.MustHaveGoBuild(t)
    17  	cmd := exec.Command("go", "build", "-gcflags=-m", "internal/runtime/maps")
    18  	out, err := cmd.CombinedOutput()
    19  	if err != nil {
    20  		t.Fatalf("exec.Command error: %v\n\n%s", err, out)
    21  	}
    22  
    23  	base := "runtime_mapaccess2"
    24  	funcs := map[string]bool{
    25  		base:              false,
    26  		base + "_fast32":  false,
    27  		base + "_fast64":  false,
    28  		base + "_faststr": false,
    29  		base + "_fat":     false,
    30  	}
    31  
    32  	for _, line := range strings.Split(string(out), "\n") {
    33  		const phrase = ": inlining call to "
    34  		if i := strings.Index(line, base); i != -1 {
    35  			func_name := line[i:]
    36  			fmt.Println("Found match:", func_name)
    37  			funcs[func_name] = true // visited
    38  		}
    39  	}
    40  
    41  	for f, visited := range funcs {
    42  		if !visited {
    43  			t.Fatalf("Didn't inline %v", f)
    44  		}
    45  	}
    46  }
    47  

View as plain text