llvm-project/llgo/test/llgoi/interfaces.test

23 lines
339 B
Plaintext

// RUN: llgoi < %s | FileCheck %s
import "errors"
err := errors.New("foo")
err
// CHECK: foo
err.(interface{Foo()})
// CHECK: panic: interface conversion
_, ok := err.(interface{Foo()})
ok
// CHECK: false
err.(interface{Error() string})
// CHECK: foo
iface, ok := err.(interface{Error() string})
iface
// CHECK: foo
ok
// CHECK: true