Debian Codegraph @

matchers/receive_test.go

raw symbols SCIP
1 package matchers_testscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/
2
3 import (
4 "reflectscip-go gomod github.com/golang/go/src go1.21.4 reflect/"
5 "testingscip-go gomod github.com/golang/go/src go1.21.4 testing/"
6 "timescip-go gomod github.com/golang/go/src go1.21.4 time/"
7
8 "github.com/poy/onpar/matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/"
9 )
10
11 func TestReceiveSucceedsForABufferedChannelscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestReceiveSucceedsForABufferedChannel().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
12 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
13 c := make(chan bool, 1)
14 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.Receivescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/Receive().()
15
16 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveMatcher#Match().(c)
17 if err == nil {
18 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to not be nil")
19 }
20
21 c <- true
22 result, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveMatcher#Match().(c)
23 if err != nil {
24 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to be nil")
25 }
26
27 if !reflectscip-go gomod github.com/golang/go/src go1.21.4 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.21.4 reflect/DeepEqual().(result, true) {
28 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected %v to equal %v", result, true)
29 }
30 }
31
32 func TestReceiveWaitSucceedsForAnUnbufferedChannelInALoopscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestReceiveWaitSucceedsForAnUnbufferedChannelInALoop().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
33 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
34 c := make(chan bool)
35 done := make(chan struct{})
36 defer close(done)
37 go func() {
38 for {
39 select {
40 case c <- true:
41 case <-done:
42 return
43 default:
44 // Receive should still be able to get a value from c,
45 // even in this buggy loop. Onpar is for detecting
46 // bugs, after all.
47 }
48 }
49 }()
50
51 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.Receivescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/Receive().(matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ReceiveWaitscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveWait().(500 * timescip-go gomod github.com/golang/go/src go1.21.4 time/.Millisecondscip-go gomod github.com/golang/go/src go1.21.4 time/Millisecond.))
52 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveMatcher#Match().(c)
53 if err != nil {
54 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected err to be nil; got %s", err)
55 }
56 }
57
58 func TestReceiveWaitSucceedsEventuallyscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestReceiveWaitSucceedsEventually().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
59 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
60 c := make(chan bool)
61 go func() {
62 timescip-go gomod github.com/golang/go/src go1.21.4 time/.Sleepscip-go gomod github.com/golang/go/src go1.21.4 time/Sleep().(200 * timescip-go gomod github.com/golang/go/src go1.21.4 time/.Millisecondscip-go gomod github.com/golang/go/src go1.21.4 time/Millisecond.)
63 c <- true
64 }()
65
66 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.Receivescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/Receive().(matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ReceiveWaitscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveWait().(500 * timescip-go gomod github.com/golang/go/src go1.21.4 time/.Millisecondscip-go gomod github.com/golang/go/src go1.21.4 time/Millisecond.))
67 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveMatcher#Match().(c)
68 if err != nil {
69 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected err to be nil; got %s", err)
70 }
71 }
72
73 func TestReceiveFailsNotReadableChanscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestReceiveFailsNotReadableChan().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
74 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
75 c := make(chan int, 10)
76 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.Receivescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/Receive().()
77
78 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveMatcher#Match().(101)
79 if err == nil {
80 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to not be nil")
81 }
82
83 _, err = m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveMatcher#Match().(chan<- int(c))
84 if err == nil {
85 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to not be nil")
86 }
87 }
88
89 func TestReceiveFailsForClosedChannelscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestReceiveFailsForClosedChannel().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
90 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
91 c := make(chan bool, 1)
92 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.Receivescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/Receive().()
93 c <- true
94
95 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveMatcher#Match().(c)
96 if err != nil {
97 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to be nil")
98 }
99
100 close(c)
101 _, err = m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ReceiveMatcher#Match().(c)
102 if err == nil {
103 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to not be nil")
104 }
105 }