...

Source file src/cmd/compile/internal/inline/inlheur/debugflags_test.go

Documentation: cmd/compile/internal/inline/inlheur

     1  // Copyright 2023 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 inlheur
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestInlScoreAdjFlagParse(t *testing.T) {
    12  	scenarios := []struct {
    13  		value string
    14  		expok bool
    15  	}{
    16  		{
    17  			value: "returnFeedsConcreteToInterfaceCallAdj:9",
    18  			expok: true,
    19  		},
    20  		{
    21  			value: "panicPathAdj:-1/initFuncAdj:9",
    22  			expok: true,
    23  		},
    24  		{
    25  			value: "",
    26  			expok: false,
    27  		},
    28  		{
    29  			value: "nonsenseAdj:10",
    30  			expok: false,
    31  		},
    32  		{
    33  			value: "inLoopAdj:",
    34  			expok: false,
    35  		},
    36  		{
    37  			value: "inLoopAdj:10:10",
    38  			expok: false,
    39  		},
    40  		{
    41  			value: "inLoopAdj:blah",
    42  			expok: false,
    43  		},
    44  		{
    45  			value: "/",
    46  			expok: false,
    47  		},
    48  	}
    49  
    50  	for _, scenario := range scenarios {
    51  		err := parseScoreAdj(scenario.value)
    52  		t.Logf("for value=%q err is %v\n", scenario.value, err)
    53  		if scenario.expok {
    54  			if err != nil {
    55  				t.Errorf("expected parseScoreAdj(%s) ok, got err %v",
    56  					scenario.value, err)
    57  			}
    58  		} else {
    59  			if err == nil {
    60  				t.Errorf("expected parseScoreAdj(%s) failure, got success",
    61  					scenario.value)
    62  			}
    63  		}
    64  	}
    65  }
    66  

View as plain text