...
1
2
3
4
5 package a
6
7 import (
8 "context"
9 "log"
10 "os"
11 "testing"
12 "time"
13 )
14
15 var bg = context.Background()
16
17
18
19 func _() {
20 var _, cancel = context.WithCancel(bg)
21 if false {
22 _ = cancel
23 }
24 }
25
26 func _() {
27 _, cancel2 := context.WithDeadline(bg, time.Time{})
28 if false {
29 _ = cancel2
30 }
31 }
32
33 func _() {
34 var cancel3 func()
35 _, cancel3 = context.WithTimeout(bg, 0)
36 if false {
37 _ = cancel3
38 }
39 }
40
41 func _() {
42 ctx, _ := context.WithCancel(bg)
43 ctx, _ = context.WithTimeout(bg, 0)
44 ctx, _ = context.WithDeadline(bg, time.Time{})
45 _ = ctx
46 }
47
48 func _() {
49 _, cancel := context.WithCancel(bg)
50 defer cancel()
51 }
52
53 func _() {
54 _, cancel := context.WithCancel(bg)
55 if condition {
56 cancel()
57 }
58 return
59 }
60
61 func _() {
62 _, cancel := context.WithCancel(bg)
63 if condition {
64 cancel()
65 } else {
66
67 for {
68 print(0)
69 }
70 }
71 }
72
73 func _() {
74 _, cancel := context.WithCancel(bg)
75 if condition {
76 cancel()
77 } else {
78 for i := 0; i < 10; i++ {
79 print(0)
80 }
81 }
82 }
83
84 func _() {
85 _, cancel := context.WithCancel(bg)
86
87 switch someInt {
88 case 0:
89 new(testing.T).FailNow()
90 case 1:
91 log.Fatal()
92 case 2:
93 cancel()
94 case 3:
95 print("hi")
96 fallthrough
97 default:
98 os.Exit(1)
99 }
100 }
101
102 func _() {
103 _, cancel := context.WithCancel(bg)
104 switch someInt {
105 case 0:
106 new(testing.T).FailNow()
107 case 1:
108 log.Fatal()
109 case 2:
110 cancel()
111 case 3:
112 print("hi")
113 default:
114 os.Exit(1)
115 }
116 }
117
118 func _(ch chan int) {
119 _, cancel := context.WithCancel(bg)
120 select {
121 case <-ch:
122 new(testing.T).FailNow()
123 case ch <- 2:
124 print("hi")
125 case ch <- 1:
126 cancel()
127 default:
128 os.Exit(1)
129 }
130 }
131
132 func _(ch chan int) {
133 _, cancel := context.WithCancel(bg)
134
135 select {
136 case <-ch:
137 panic(0)
138 }
139 if false {
140 _ = cancel
141 }
142 }
143
144 func _() {
145 go func() {
146 ctx, cancel := context.WithCancel(bg)
147 if false {
148 _ = cancel
149 }
150 print(ctx)
151 }()
152 }
153
154 var condition bool
155 var someInt int
156
157
158 func _() {
159 var x struct{ f func() }
160 x.f()
161 }
162
163
164 func _() (ctx context.Context, cancel func()) {
165 ctx, cancel = context.WithCancel(bg)
166 return
167 }
168
169
170 var _ = func() (ctx context.Context, cancel func()) {
171 ctx, cancel = context.WithCancel(bg)
172 return
173 }
174
175
176 func _() {
177 var cancel func()
178
179 func() {
180 _, cancel = context.WithCancel(bg)
181 }()
182
183 cancel()
184 }
185
186 var cancel1 func()
187
188
189 func _() {
190
191 _, cancel1 = context.WithCancel(bg)
192 }
193
View as plain text