PageRenderTime 48ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Go | 66 lines | 59 code | 7 blank | 0 comment | 16 complexity | 4b4f5a17360b4d65cb18f3813971eb24 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. package main
  2. import "strings"
  3. import "./threads_exception"
  4. func main() {
  5. t := threads_exception.NewTest()
  6. error := true
  7. func() {
  8. defer func() {
  9. error = recover() == nil
  10. }()
  11. t.Unknown()
  12. }()
  13. if error {
  14. panic(0)
  15. }
  16. error = true
  17. func() {
  18. defer func() {
  19. error = strings.Index(recover().(string), "int exception") == -1
  20. }()
  21. t.Simple()
  22. }()
  23. if error {
  24. panic(0)
  25. }
  26. error = true
  27. func() {
  28. defer func() {
  29. error = recover().(string) != "I died."
  30. }()
  31. t.Message()
  32. }()
  33. if error {
  34. panic(0)
  35. }
  36. error = true
  37. func() {
  38. defer func() {
  39. e := recover().(string)
  40. error = strings.Index(e, "Exc exception") == -1
  41. }()
  42. t.Hosed()
  43. }()
  44. if error {
  45. panic(0)
  46. }
  47. for i := 1; i < 4; i++ {
  48. error = true
  49. func() {
  50. defer func() {
  51. error = recover() == nil
  52. }()
  53. t.Multi(i)
  54. }()
  55. if error {
  56. panic(0)
  57. }
  58. }
  59. }