// TestMissingOneWithPanic tests that we detect a single missing variant even
// if we have a trivial default case that panics.
TestMissingOneWithPanic tests that we detect a single missing variant even
if we have a trivial default case that panics.
// TestMissingOneWithPanic tests that we detect a single missing variant even // if we have a trivial default case that panics .
func TestMissingOneWithPanic(t *testing.T) {
	code := `
package main
//go-sumtype:decl T
type T interface { sealed() }
type A struct {}
func (a *A) sealed() {}
type B struct {}
func (b *B) sealed() {}
func main() {
	switch T(nil).(type) {
	case *A:
	default:
		panic("unreachable")
	}
}
`
	tmpdir, pkgs := setupPackages(t, code)
	defer teardownPackage(t, tmpdir)
	errs := run(pkgs)
	if !assert.Len(t, errs, 1) {
		t.FailNow()
	}
	assert.Equal(t, []string{"B"}, missingNames(t, errs[0]))
}
func TestMissingOneWithPanic ( t * testing . T ) { code := `
package main

//go-sumtype:decl T

type T interface { sealed() }

type A struct {}
func (a *A) sealed() {}

type B struct {}
func (b *B) sealed() {}

func main() {
	switch T(nil).(type) {
	case *A:
	default:
		panic("unreachable")
	}
}
` tmpdir , pkgs := setupPackages ( t , code ) defer teardownPackage ( t , tmpdir ) errs := run ( pkgs ) if ! assert . Len ( t , errs , 1 ) { t . FailNow ( ) } assert . Equal ( t , [ ] string { " " } , missingNames ( t , errs [ 0 ] ) ) }
TestMissingOneWithPanic tests that we detect a single missing variant even
if we have a trivial default case that panics.
TestMissingOneWithPanic tests that we detect a single missing variant even if we have a trivial default case that panics .