diff options
Diffstat (limited to 'src/internal')
| -rw-r--r-- | src/internal/synctest/synctest_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/internal/synctest/synctest_test.go b/src/internal/synctest/synctest_test.go index c0e126e3fc..7c8fd7ef9e 100644 --- a/src/internal/synctest/synctest_test.go +++ b/src/internal/synctest/synctest_test.go @@ -263,6 +263,46 @@ func TestChannelFromOutsideBubble(t *testing.T) { } } +func TestChannelMovedOutOfBubble(t *testing.T) { + for _, test := range []struct { + desc string + f func(chan struct{}) + wantPanic string + }{{ + desc: "receive", + f: func(ch chan struct{}) { + <-ch + }, + wantPanic: "receive on synctest channel from outside bubble", + }, { + desc: "send", + f: func(ch chan struct{}) { + ch <- struct{}{} + }, + wantPanic: "send on synctest channel from outside bubble", + }, { + desc: "close", + f: func(ch chan struct{}) { + close(ch) + }, + wantPanic: "close of synctest channel from outside bubble", + }} { + t.Run(test.desc, func(t *testing.T) { + donec := make(chan struct{}) + ch := make(chan chan struct{}) + go func() { + defer close(donec) + defer wantPanic(t, test.wantPanic) + test.f(<-ch) + }() + synctest.Run(func() { + ch <- make(chan struct{}) + }) + <-donec + }) + } +} + func TestTimerFromInsideBubble(t *testing.T) { for _, test := range []struct { desc string |
