golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/trace/event_test.go (about)

     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  // Code generated by "gen.bash" from internal/trace/v2; DO NOT EDIT.
     6  
     7  //go:build go1.21
     8  
     9  package trace
    10  
    11  import "testing"
    12  
    13  func TestPanicEvent(t *testing.T) {
    14  	// Use a sync event for this because it doesn't have any extra metadata.
    15  	ev := syncEvent(nil, 0)
    16  
    17  	mustPanic(t, func() {
    18  		_ = ev.Range()
    19  	})
    20  	mustPanic(t, func() {
    21  		_ = ev.Metric()
    22  	})
    23  	mustPanic(t, func() {
    24  		_ = ev.Log()
    25  	})
    26  	mustPanic(t, func() {
    27  		_ = ev.Task()
    28  	})
    29  	mustPanic(t, func() {
    30  		_ = ev.Region()
    31  	})
    32  	mustPanic(t, func() {
    33  		_ = ev.Label()
    34  	})
    35  	mustPanic(t, func() {
    36  		_ = ev.RangeAttributes()
    37  	})
    38  }
    39  
    40  func mustPanic(t *testing.T, f func()) {
    41  	defer func() {
    42  		if r := recover(); r == nil {
    43  			t.Fatal("failed to panic")
    44  		}
    45  	}()
    46  	f()
    47  }