go/src/runtime/defer_test.go

// Make sure open-coded defer exit code is not lost, even when there is an
// unconditional panic (hence no return from the function)
func TestUnconditionalPanic(t *testing.T) {}

var glob

// Test an open-coded defer and non-open-coded defer - make sure both defers run
// and call recover()
func TestOpenAndNonOpenDefers(t *testing.T) {}

//go:noinline
func testOpen(t *testing.T, arg int) {}

// Test a non-open-coded defer and an open-coded defer - make sure both defers run
// and call recover()
func TestNonOpenAndOpenDefers(t *testing.T) {}

var list

// Make sure that conditional open-coded defers are activated correctly and run in
// the correct order.
func TestConditionalDefers(t *testing.T) {}

func testConditionalDefers(n int) {}

// Test that there is no compile-time or run-time error if an open-coded defer
// call is removed by constant propagation and dead-code elimination.
func TestDisappearingDefer(t *testing.T) {}

// This tests an extra recursive panic behavior that is only specified in the
// code. Suppose a first panic P1 happens and starts processing defer calls. If a
// second panic P2 happens while processing defer call D in frame F, then defer
// call processing is restarted (with some potentially new defer calls created by
// D or its callees). If the defer processing reaches the started defer call D
// again in the defer stack, then the original panic P1 is aborted and cannot
// continue panic processing or be recovered. If the panic P2 does a recover at
// some point, it will naturally remove the original panic P1 from the stack
// (since the original panic had to be in frame F or a descendant of F).
func TestAbortedPanic(t *testing.T) {}

// This tests that recover() does not succeed unless it is called directly from a
// defer function that is directly called by the panic.  Here, we first call it
// from a defer function that is created by the defer function called directly by
// the panic.  In
func TestRecoverMatching(t *testing.T) {}

type nonSSAable

type bigStruct

type containsBigStruct

func mknonSSAable() nonSSAable {}

var (
	globint1
	globint2
	globint3
)

//go:noinline
func sideeffect(n int64) int64 {}

func sideeffect2(in containsBigStruct) containsBigStruct {}

// Test that nonSSAable arguments to defer are handled correctly and only evaluated once.
func TestNonSSAableArgs(t *testing.T) {}

//go:noinline
func doPanic() {}

func TestDeferForFuncWithNoExit(t *testing.T) {}

// Test case approximating issue #37664, where a recursive function (interpreter)
// may do repeated recovers/re-panics until it reaches the frame where the panic
// can actually be handled. The recurseFnPanicRec() function is testing that there
// are no stale defer structs on the defer chain after the interpreter() sequence,
// by writing a bunch of 0xffffffffs into several recursive stack frames, and then
// doing a single panic-recover which would invoke any such stale defer structs.
func TestDeferWithRepeatedRepanics(t *testing.T) {}

func interpreter(level int, maxlevel int, rec int) {}

func recurseFnPanicRec(level int, maxlevel int) {}

var saveInt

func recurseFn(level int, maxlevel int) {}

// Try to reproduce issue #37688, where a pointer to an open-coded defer struct is
// mistakenly held, and that struct keeps a pointer to a stack-allocated defer
// struct, and that stack-allocated struct gets overwritten or the stack gets
// moved, so a memory error happens on GC.
func TestIssue37688(t *testing.T) {}

type foo

//go:noinline
func (f *foo) method1() {}

//go:noinline
func (f *foo) method2() {}

func g2() {}

func g3() {}

var globstruct

func ff1(ap *foo, a, b, c, d, e, f, g, h, i int) {}

func rec1(max int) {}

func TestIssue43921(t *testing.T) {}

func expect(t *testing.T, n int, err any) {}

func TestIssue43920(t *testing.T) {}

func step(t *testing.T, steps *int, want int) {}

func TestIssue43941(t *testing.T) {}