/trunk/Examples/test-suite/go/exception_order_runme.go
Go | 58 lines | 51 code | 7 blank | 0 comment | 15 complexity | 8744dc085a5078cd403670d7175a0f93 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- package main
- import "strings"
- import . "./exception_order"
- func main() {
- a := NewA()
- func() {
- defer func() {
- e := recover()
- if strings.Index(e.(string), "E1") == -1 {
- panic(e.(string))
- }
- }()
- a.Foo()
- }()
- func() {
- defer func() {
- e := recover()
- if strings.Index(e.(string), "E2") == -1 {
- panic(e.(string))
- }
- }()
- a.Bar()
- }()
- func() {
- defer func() {
- e := recover()
- if e.(string) != "postcatch unknown" {
- panic("bad exception order")
- }
- }()
- a.Foobar()
- }()
- func() {
- defer func() {
- e := recover()
- if strings.Index(e.(string), "E1") == -1 {
- panic(e.(string))
- }
- }()
- a.Barfoo(1)
- }()
- func() {
- defer func() {
- e := recover()
- if strings.Index(e.(string), "E2") == -1 {
- panic(e.(string))
- }
- }()
- a.Barfoo(2)
- }()
- }