| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package a |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
import ( |
| 10 |
"hash/maphash" |
| 11 |
"log" |
| 12 |
"os" |
| 13 |
"runtime" |
| 14 |
"syscall" |
| 15 |
"testing" |
| 16 |
|
| 17 |
"lib" |
| 18 |
) |
| 19 |
|
| 20 |
var cond bool |
| 21 |
|
| 22 |
func a() { |
| 23 |
if cond { |
| 24 |
b() |
| 25 |
} else { |
| 26 |
for { |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
func b() { |
| 32 |
select {} |
| 33 |
} |
| 34 |
|
| 35 |
func f(x int) { |
| 36 |
switch x { |
| 37 |
case 0: |
| 38 |
os.Exit(0) |
| 39 |
case 1: |
| 40 |
panic(0) |
| 41 |
} |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
type T int |
| 46 |
|
| 47 |
func (T) method1() { |
| 48 |
a() |
| 49 |
} |
| 50 |
|
| 51 |
func (T) method2() { |
| 52 |
if cond { |
| 53 |
a() |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
func standardFunctions(x int) { |
| 60 |
t := new(testing.T) |
| 61 |
switch x { |
| 62 |
case 0: |
| 63 |
t.FailNow() |
| 64 |
case 1: |
| 65 |
t.Fatal() |
| 66 |
case 2: |
| 67 |
t.Fatalf("") |
| 68 |
case 3: |
| 69 |
t.Skip() |
| 70 |
case 4: |
| 71 |
t.SkipNow() |
| 72 |
case 5: |
| 73 |
t.Skipf("") |
| 74 |
case 6: |
| 75 |
log.Fatal() |
| 76 |
case 7: |
| 77 |
log.Fatalf("") |
| 78 |
case 8: |
| 79 |
log.Fatalln() |
| 80 |
case 9: |
| 81 |
os.Exit(0) |
| 82 |
case 10: |
| 83 |
syscall.Exit(0) |
| 84 |
case 11: |
| 85 |
runtime.Goexit() |
| 86 |
case 12: |
| 87 |
log.Panic() |
| 88 |
case 13: |
| 89 |
log.Panicln() |
| 90 |
case 14: |
| 91 |
log.Panicf("") |
| 92 |
default: |
| 93 |
panic(0) |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
func panicRecover() { |
| 98 |
defer func() { recover() }() |
| 99 |
panic(nil) |
| 100 |
} |
| 101 |
|
| 102 |
func noBody() |
| 103 |
|
| 104 |
func g() { |
| 105 |
lib.CanReturn() |
| 106 |
} |
| 107 |
|
| 108 |
func h() { |
| 109 |
lib.NoReturn() |
| 110 |
} |
| 111 |
|
| 112 |
func returns() { |
| 113 |
print(1) |
| 114 |
print(2) |
| 115 |
print(3) |
| 116 |
} |
| 117 |
|
| 118 |
func nobody() |
| 119 |
|
| 120 |
func hasPanic() { |
| 121 |
print(1) |
| 122 |
panic(2) |
| 123 |
print(3) |
| 124 |
} |
| 125 |
|
| 126 |
func hasSelect() { |
| 127 |
print(1) |
| 128 |
select {} |
| 129 |
print(3) |
| 130 |
} |
| 131 |
|
| 132 |
func infiniteLoop() { |
| 133 |
print(1) |
| 134 |
for { |
| 135 |
} |
| 136 |
print(3) |
| 137 |
} |
| 138 |
|
| 139 |
func ifElse(cond bool) { |
| 140 |
print(1) |
| 141 |
if cond { |
| 142 |
hasSelect() |
| 143 |
} else { |
| 144 |
infiniteLoop() |
| 145 |
} |
| 146 |
print(3) |
| 147 |
} |
| 148 |
|
| 149 |
func swtch(x int) { |
| 150 |
print(1) |
| 151 |
switch x { |
| 152 |
case 1: |
| 153 |
hasSelect() |
| 154 |
case 2: |
| 155 |
goexit() |
| 156 |
case 3: |
| 157 |
logFatal() |
| 158 |
case 4: |
| 159 |
osexit() |
| 160 |
default: |
| 161 |
panic(3) |
| 162 |
} |
| 163 |
} |
| 164 |
|
| 165 |
func _if(cond bool) { |
| 166 |
print(1) |
| 167 |
if cond { |
| 168 |
hasSelect() |
| 169 |
} |
| 170 |
print(3) |
| 171 |
} |
| 172 |
|
| 173 |
func logFatal() { |
| 174 |
print(1) |
| 175 |
log.Fatal("oops") |
| 176 |
print(2) |
| 177 |
} |
| 178 |
|
| 179 |
func testFatal(t *testing.T) { |
| 180 |
print(1) |
| 181 |
t.Fatal("oops") |
| 182 |
print(2) |
| 183 |
} |
| 184 |
|
| 185 |
func goexit() { |
| 186 |
print(1) |
| 187 |
runtime.Goexit() |
| 188 |
print(2) |
| 189 |
} |
| 190 |
|
| 191 |
func osexit() { |
| 192 |
print(1) |
| 193 |
os.Exit(0) |
| 194 |
print(2) |
| 195 |
} |
| 196 |
|
| 197 |
func intrinsic() { |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
maphash.Comparable[int](maphash.Seed{}, 0) |
| 203 |
} |