PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/trunk/Examples/test-suite/go/exception_order_runme.go

#
Go | 58 lines | 51 code | 7 blank | 0 comment | 10 complexity | 8744dc085a5078cd403670d7175a0f93 MD5 | raw file
 1package main
 2
 3import "strings"
 4import . "./exception_order"
 5
 6func main() {
 7	a := NewA()
 8
 9	func() {
10		defer func() {
11			e := recover()
12			if strings.Index(e.(string), "E1") == -1 {
13				panic(e.(string))
14			}
15		}()
16		a.Foo()
17	}()
18
19	func() {
20		defer func() {
21			e := recover()
22			if strings.Index(e.(string), "E2") == -1 {
23				panic(e.(string))
24			}
25		}()
26		a.Bar()
27	}()
28
29	func() {
30		defer func() {
31			e := recover()
32			if e.(string) != "postcatch unknown" {
33				panic("bad exception order")
34			}
35		}()
36		a.Foobar()
37	}()
38
39	func() {
40		defer func() {
41			e := recover()
42			if strings.Index(e.(string), "E1") == -1 {
43				panic(e.(string))
44			}
45		}()
46		a.Barfoo(1)
47	}()
48
49	func() {
50		defer func() {
51			e := recover()
52			if strings.Index(e.(string), "E2") == -1 {
53				panic(e.(string))
54			}
55		}()
56		a.Barfoo(2)
57	}()
58}