Permalink
Browse files

Closure test.

  • Loading branch information...
1 parent ffe4581 commit c9e332f289683cf3eeec2dd1a786d0b8d4be8fd1 @athoune committed Jun 5, 2012
Showing with 19 additions and 2 deletions.
  1. +19 −2 topic_test.go
View
@@ -6,12 +6,24 @@ import (
)
func TestTopic(t *testing.T) {
- c := Suscribe(func(s string) { fmt.Println("C", s) })
+ cFlag := true
+ dFlag := true
+ c := Suscribe(func(s string) {
+ fmt.Println("C", s)
+ if cFlag {
+ cFlag = false
+ }
+ })
if c.id != 1 {
t.Log("bad counter")
t.Fail()
}
- d := Suscribe(func(s string) { fmt.Println("D", s) })
+ d := Suscribe(func(s string) {
+ fmt.Println("D", s)
+ if dFlag {
+ dFlag = false
+ }
+ })
if d.id != 2 {
t.Log("bad counter")
t.Fail()
@@ -20,4 +32,9 @@ func TestTopic(t *testing.T) {
c.Leave()
Publish("again")
d.Leave()
+ //[FIXME] a new channel must be used to wait all message
+ if cFlag {
+ t.Log("Trouble with closure")
+ t.Fail()
+ }
}

0 comments on commit c9e332f

Please sign in to comment.