go/src/cmd/compile/internal/rangefunc/rangefunc_test.go

type Seq

type Seq2

// OfSliceIndex returns a Seq2 over the elements of s. It is equivalent
// to range s.
func OfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] {}

// BadOfSliceIndex is "bad" because it ignores the return value from yield
// and just keeps on iterating.
func BadOfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] {}

// VeryBadOfSliceIndex is "very bad" because it ignores the return value from yield
// and just keeps on iterating, and also wraps that call in a defer-recover so it can
// keep on trying after the first panic.
func VeryBadOfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] {}

// SwallowPanicOfSliceIndex hides panics and converts them to normal return
func SwallowPanicOfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] {}

// PanickyOfSliceIndex iterates the slice but panics if it exits the loop early
func PanickyOfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] {}

// CooperativeBadOfSliceIndex calls the loop body from a goroutine after
// a ping on a channel, and returns recover()on that same channel.
func CooperativeBadOfSliceIndex[T any, S ~[]T](s S, proceed chan any) Seq2[int, T] {}

type TrickyIterator

func (ti *TrickyIterator) iterEcho(s []int) Seq2[int, int] {}

func (ti *TrickyIterator) iterAll(s []int) Seq2[int, int] {}

func (ti *TrickyIterator) iterOne(s []int) Seq2[int, int] {}

func (ti *TrickyIterator) iterZero(s []int) Seq2[int, int] {}

func (ti *TrickyIterator) fail() {}

const DONE

const READY

const PANIC

const EXHAUSTED

const MISSING_PANIC

// Check2 wraps the function body passed to iterator forall
// in code that ensures that it cannot (successfully) be called
// either after body return false (control flow out of loop) or
// forall itself returns (the iteration is now done).
//
// Note that this can catch errors before the inserted checks.
func Check2[U, V any](forall Seq2[U, V]) Seq2[U, V] {}

func Check[U any](forall Seq[U]) Seq[U] {}

func matchError(r any, x string) bool {}

func matchErrorHelper(t *testing.T, r any, x string) {}

type errorString

func (e errorString) Error() string {}

const RERR_DONE

const RERR_PANIC

const RERR_EXHAUSTED

const RERR_MISSING

const CERR_PFX

const CERR_DONE

const CERR_PANIC

const CERR_EXHAUSTED

const CERR_MISSING

var fail

// TestNoVars ensures that versions of rangefunc that use zero or one
// iteration variable (instead of two) run the proper number of times
// and in the one variable case supply the proper values.
// For #65236.
func TestNoVars(t *testing.T) {}

func TestCheck(t *testing.T) {}

func TestCooperativeBadOfSliceIndex(t *testing.T) {}

func TestCooperativeBadOfSliceIndexCheck(t *testing.T) {}

func TestTrickyIterAll(t *testing.T) {}

func TestTrickyIterOne(t *testing.T) {}

func TestTrickyIterZero(t *testing.T) {}

func TestTrickyIterZeroCheck(t *testing.T) {}

func TestTrickyIterEcho(t *testing.T) {}

func TestTrickyIterEcho2(t *testing.T) {}

// TestBreak1 should just work, with well-behaved iterators.
// (The misbehaving iterator detector should not trigger.)
func TestBreak1(t *testing.T) {}

// TestBreak2 should just work, with well-behaved iterators.
// (The misbehaving iterator detector should not trigger.)
func TestBreak2(t *testing.T) {}

// TestContinue should just work, with well-behaved iterators.
// (The misbehaving iterator detector should not trigger.)
func TestContinue(t *testing.T) {}

// TestBreak3 should just work, with well-behaved iterators.
// (The misbehaving iterator detector should not trigger.)
func TestBreak3(t *testing.T) {}

// TestBreak1BadA should end in a panic when the outer-loop's
// single-level break is ignore by BadOfSliceIndex
func TestBreak1BadA(t *testing.T) {}

// TestBreak1BadB should end in a panic, sooner, when the inner-loop's
// (nested) single-level break is ignored by BadOfSliceIndex
func TestBreak1BadB(t *testing.T) {}

// TestMultiCont0 tests multilevel continue with no bad iterators
// (it should just work)
func TestMultiCont0(t *testing.T) {}

// TestMultiCont1 tests multilevel continue with a bad iterator
// in the outermost loop exited by the continue.
func TestMultiCont1(t *testing.T) {}

// TestMultiCont2 tests multilevel continue with a bad iterator
// in a middle loop exited by the continue.
func TestMultiCont2(t *testing.T) {}

// TestMultiCont3 tests multilevel continue with a bad iterator
// in the innermost loop exited by the continue.
func TestMultiCont3(t *testing.T) {}

// TestMultiBreak0 tests multilevel break with a bad iterator
// in the outermost loop exited by the break (the outermost loop).
func TestMultiBreak0(t *testing.T) {}

// TestMultiBreak1 tests multilevel break with a bad iterator
// in an intermediate loop exited by the break.
func TestMultiBreak1(t *testing.T) {}

// TestMultiBreak2 tests multilevel break with two bad iterators
// in intermediate loops exited by the break.
func TestMultiBreak2(t *testing.T) {}

// TestMultiBreak3 tests multilevel break with the bad iterator
// in the innermost loop exited by the break.
func TestMultiBreak3(t *testing.T) {}

func TestPanickyIterator1(t *testing.T) {}

func TestPanickyIterator1Check(t *testing.T) {}

func TestPanickyIterator2(t *testing.T) {}

func TestPanickyIterator2Check(t *testing.T) {}

func TestPanickyIterator3(t *testing.T) {}

func TestPanickyIterator3Check(t *testing.T) {}

func TestPanickyIterator4(t *testing.T) {}

func TestPanickyIterator4Check(t *testing.T) {}

// veryBad tests that a loop nest behaves sensibly in the face of a
// "very bad" iterator.  In this case, "sensibly" means that the
// break out of X still occurs after the very bad iterator finally
// quits running (the control flow bread crumbs remain.)
func veryBad(s []int) []int {}

// veryBadCheck wraps a "very bad" iterator with Check,
// demonstrating that the very bad iterator also hides panics
// thrown by Check.
func veryBadCheck(s []int) []int {}

// okay is the not-bad version of veryBad.
// They should behave the same.
func okay(s []int) []int {}

// TestVeryBad1 checks the behavior of an extremely poorly behaved iterator.
func TestVeryBad1(t *testing.T) {}

// TestVeryBad2 checks the behavior of an extremely poorly behaved iterator.
func TestVeryBad2(t *testing.T) {}

// TestVeryBadCheck checks the behavior of an extremely poorly behaved iterator,
// which also suppresses the exceptions from "Check"
func TestVeryBadCheck(t *testing.T) {}

// TestOk is the nice version of the very bad iterator.
func TestOk(t *testing.T) {}

// testBreak1BadDefer checks that defer behaves properly even in
// the presence of loop bodies panicking out of bad iterators.
// (i.e., the instrumentation did not break defer in these loops)
func testBreak1BadDefer(t *testing.T) (result []int) {}

func TestBreak1BadDefer(t *testing.T) {}

// testReturn1 has no bad iterators.
func testReturn1(t *testing.T) (result []int, err any) {}

// testReturn2 has an outermost bad iterator
func testReturn2(t *testing.T) (result []int, err any) {}

// testReturn3 has an innermost bad iterator
func testReturn3(t *testing.T) (result []int, err any) {}

// testReturn4 has no bad iterators, but exercises  return variable rewriting
// differs from testReturn1 because deferred append to "result" does not change
// the return value in this case.
func testReturn4(t *testing.T) (_ []int, _ []int, err any) {}

// TestReturns checks that returns through bad iterators behave properly,
// for inner and outer bad iterators.
func TestReturns(t *testing.T) {}

// testGotoA1 tests loop-nest-internal goto, no bad iterators.
func testGotoA1(t *testing.T) (result []int, err any) {}

// testGotoA2 tests loop-nest-internal goto, outer bad iterator.
func testGotoA2(t *testing.T) (result []int, err any) {}

// testGotoA3 tests loop-nest-internal goto, inner bad iterator.
func testGotoA3(t *testing.T) (result []int, err any) {}

func TestGotoA(t *testing.T) {}

// testGotoB1 tests loop-nest-exiting goto, no bad iterators.
func testGotoB1(t *testing.T) (result []int, err any) {}

// testGotoB2 tests loop-nest-exiting goto, outer bad iterator.
func testGotoB2(t *testing.T) (result []int, err any) {}

// testGotoB3 tests loop-nest-exiting goto, inner bad iterator.
func testGotoB3(t *testing.T) (result []int, err any) {}

func TestGotoB(t *testing.T) {}

// once returns an iterator that runs its loop body once with the supplied value
func once[T any](x T) Seq[T] {}

// terrify converts an iterator into one that panics with the supplied string
// if/when the loop body terminates early (returns false, for break, goto, outer
// continue, or return).
func terrify[T any](s string, forall Seq[T]) Seq[T] {}

func use[T any](T) {}

// f runs a not-rangefunc iterator that recovers from a panic that follows execution of a return.
// what does f return?
func f() string {}

// g runs a rangefunc iterator that recovers from a panic that follows execution of a return.
// what does g return?
func g() string {}

// h runs a rangefunc iterator that recovers from a panic that follows execution of a return.
// the panic occurs in the rangefunc iterator itself.
// what does h return?
func h() (hashS string) {}

func j() (hashS string) {}

// k runs a rangefunc iterator that recovers from a panic that follows execution of a return.
// the panic occurs in the rangefunc iterator itself.
// k includes an additional mechanism to for making the return happen
// what does k return?
func k() (hashS string) {}

func m() (hashS string) {}

func n() string {}

type terrifyTestCase

func TestPanicReturns(t *testing.T) {}

// twice calls yield twice, the first time defer-recover-saving any panic,
// for re-panicking later if the second call to yield does not also panic.
// If the first call panicked, the second call ought to also panic because
// it was called after a panic-termination of the loop body.
func twice[T any](x, y T) Seq[T] {}

func TestRunBodyAfterPanic(t *testing.T) {}

func TestRunBodyAfterPanicCheck(t *testing.T) {}

func TestTwoLevelReturn(t *testing.T) {}

func TestTwoLevelReturnCheck(t *testing.T) {}

func Bug70035(s1, s2, s3 []string) string {}

func Test70035(t *testing.T) {}